mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
I18n for modules. This would seem to complete the module implementation. Test away.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22558 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
421fa672a7
commit
f03329a19c
@ -402,9 +402,10 @@ qt4_l10n.pot: $(top_srcdir)/src/frontends/qt4/ui/*.ui
|
|||||||
LC_ALL=C ; export LC_ALL ; \
|
LC_ALL=C ; export LC_ALL ; \
|
||||||
python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t qt4 ${top_srcdir}/src/frontends/qt4/ui/*.ui
|
python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t qt4 ${top_srcdir}/src/frontends/qt4/ui/*.ui
|
||||||
|
|
||||||
layouts_l10n.pot: $(top_srcdir)/lib/layouts/*.layout $(top_srcdir)/lib/layouts/*.inc
|
layouts_l10n.pot: $(top_srcdir)/lib/layouts/*.layout $(top_srcdir)/lib/layouts/*.inc \
|
||||||
|
$(top_srcdir)/lib/layouts/*.module
|
||||||
LC_ALL=C ; export LC_ALL ; \
|
LC_ALL=C ; export LC_ALL ; \
|
||||||
python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t layouts ${top_srcdir}/lib/layouts/*.layout ${top_srcdir}/lib/layouts/*.inc
|
python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t layouts ${top_srcdir}/lib/layouts/*.layout ${top_srcdir}/lib/layouts/*.inc ${top_srcdir}/lib/layouts/*.module
|
||||||
|
|
||||||
languages_l10n.pot: $(top_srcdir)/lib/languages
|
languages_l10n.pot: $(top_srcdir)/lib/languages
|
||||||
python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t languages ${top_srcdir}/lib/languages
|
python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t languages ${top_srcdir}/lib/languages
|
||||||
|
@ -63,34 +63,77 @@ def ui_l10n(input_files, output, base):
|
|||||||
output.close()
|
output.close()
|
||||||
|
|
||||||
|
|
||||||
|
def writeString(outfile, infile, basefile, lineno, string):
|
||||||
|
string = string.replace('\\', '\\\\').replace('"', '')
|
||||||
|
if string == "":
|
||||||
|
return
|
||||||
|
print >> outfile, '#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
|
||||||
|
(relativePath(infile, basefile), lineno, string)
|
||||||
|
|
||||||
def layouts_l10n(input_files, output, base):
|
def layouts_l10n(input_files, output, base):
|
||||||
'''Generate pot file from lib/layouts/*.layout and *.inc'''
|
'''Generate pot file from lib/layouts/*.{layout,inc,module}'''
|
||||||
output = open(output, 'w')
|
out = open(output, 'w')
|
||||||
Style = re.compile(r'^Style\s+(.*)')
|
Style = re.compile(r'^Style\s+(.*)')
|
||||||
# include ???LabelString???, but exclude comment lines
|
# include ???LabelString???, but exclude comment lines
|
||||||
LabelString = re.compile(r'^[^#]*LabelString\S*\s+(.*)')
|
LabelString = re.compile(r'^[^#]*LabelString\S*\s+(.*)')
|
||||||
GuiName = re.compile(r'\s*GuiName\s+(.*)')
|
GuiName = re.compile(r'\s*GuiName\s+(.*)')
|
||||||
ListName = re.compile(r'\s*ListName\s+(.*)')
|
ListName = re.compile(r'\s*ListName\s+(.*)')
|
||||||
|
NameRE = re.compile(r'DeclareLyXModule.*{(.*)}')
|
||||||
|
DescBegin = re.compile(r'#+\s*DescriptionBegin\s*$')
|
||||||
|
DescEnd = re.compile(r'#+\s*DescriptionEnd\s*$')
|
||||||
|
|
||||||
for src in input_files:
|
for src in input_files:
|
||||||
input = open(src)
|
readingDescription = False
|
||||||
for lineno, line in enumerate(input.readlines()):
|
descStartLine = -1
|
||||||
if Style.match(line):
|
descLines = []
|
||||||
(string,) = Style.match(line).groups()
|
lineno = 0
|
||||||
string = string.replace('_', ' ')
|
for line in open(src).readlines():
|
||||||
elif LabelString.match(line):
|
lineno += 1
|
||||||
(string,) = LabelString.match(line).groups()
|
if readingDescription:
|
||||||
elif GuiName.match(line):
|
res = DescEnd.search(line)
|
||||||
(string,) = GuiName.match(line).groups()
|
if res != None:
|
||||||
elif ListName.match(line):
|
readingDescription = False
|
||||||
(string,) = ListName.match(line).groups()
|
desc = " ".join(descLines)
|
||||||
else:
|
print >> out, '#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
|
||||||
|
(relativePath(src, base), lineno + 1, desc)
|
||||||
continue
|
continue
|
||||||
|
descLines.append(line[1:].strip())
|
||||||
|
continue
|
||||||
|
res = DescBegin.search(line)
|
||||||
|
if res != None:
|
||||||
|
readingDescription = True
|
||||||
|
descStartLine = lineno
|
||||||
|
continue
|
||||||
|
res = NameRE.search(line)
|
||||||
|
if res != None:
|
||||||
|
string = res.group(1)
|
||||||
string = string.replace('\\', '\\\\').replace('"', '')
|
string = string.replace('\\', '\\\\').replace('"', '')
|
||||||
if string != "":
|
if string != "":
|
||||||
print >> output, '#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
|
print >> out, '#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
|
||||||
(relativePath(src, base), lineno+1, string)
|
(relativePath(src, base), lineno + 1, string)
|
||||||
input.close()
|
continue
|
||||||
output.close()
|
res = Style.search(line)
|
||||||
|
if res != None:
|
||||||
|
string = res.group(1)
|
||||||
|
string = string.replace('_', ' ')
|
||||||
|
writeString(out, src, base, lineno, string)
|
||||||
|
continue
|
||||||
|
res = LabelString.search(line)
|
||||||
|
if res != None:
|
||||||
|
string = res.group(1)
|
||||||
|
writeString(out, src, base, lineno, string)
|
||||||
|
continue
|
||||||
|
res = GuiName.search(line)
|
||||||
|
if res != None:
|
||||||
|
string = res.group(1)
|
||||||
|
writeString(out, src, base, lineno, string)
|
||||||
|
continue
|
||||||
|
res = ListName.search(line)
|
||||||
|
if res != None:
|
||||||
|
string = res.group(1)
|
||||||
|
writeString(out, src, base, lineno, string)
|
||||||
|
continue
|
||||||
|
out.close()
|
||||||
|
|
||||||
|
|
||||||
def qt4_l10n(input_files, output, base):
|
def qt4_l10n(input_files, output, base):
|
||||||
@ -227,7 +270,7 @@ if __name__ == '__main__':
|
|||||||
base = value
|
base = value
|
||||||
elif opt in ['-t', '--type']:
|
elif opt in ['-t', '--type']:
|
||||||
input_type = value
|
input_type = value
|
||||||
if input_type not in ['ui', 'layouts', 'qt4', 'languages', 'external'] or output is None:
|
if input_type not in ['ui', 'layouts', 'modules', 'qt4', 'languages', 'external'] or output is None:
|
||||||
print 'Wrong input type or output filename.'
|
print 'Wrong input type or output filename.'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if input_type == 'ui':
|
if input_type == 'ui':
|
||||||
|
@ -174,7 +174,7 @@ namespace {
|
|||||||
LyXModule const * const mod = moduleList[modName];
|
LyXModule const * const mod = moduleList[modName];
|
||||||
if (!mod)
|
if (!mod)
|
||||||
return _("Module not found!");
|
return _("Module not found!");
|
||||||
return from_ascii(mod->getDescription());
|
return _(mod->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1962,7 +1962,7 @@ void GuiDocument::updateAvailableModules()
|
|||||||
int const mSize = modInfoList.size();
|
int const mSize = modInfoList.size();
|
||||||
for (int i = 0; i < mSize; ++i) {
|
for (int i = 0; i < mSize; ++i) {
|
||||||
modInfoStruct const & modInfo = modInfoList[i];
|
modInfoStruct const & modInfo = modInfoList[i];
|
||||||
available_model_.insertRow(i, modInfo.name, modInfo.id);
|
available_model_.insertRow(i, qt_(modInfo.name), modInfo.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1975,7 +1975,7 @@ void GuiDocument::updateSelectedModules()
|
|||||||
int const sSize = selModList.size();
|
int const sSize = selModList.size();
|
||||||
for (int i = 0; i < sSize; ++i) {
|
for (int i = 0; i < sSize; ++i) {
|
||||||
modInfoStruct const & modInfo = selModList[i];
|
modInfoStruct const & modInfo = selModList[i];
|
||||||
selected_model_.insertRow(i, modInfo.name, modInfo.id);
|
selected_model_.insertRow(i, qt_(modInfo.name), modInfo.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ bool GuiIdListModel::removeRows(int row, int count,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiIdListModel::insertRow(int const i, std::string const & uiString,
|
void GuiIdListModel::insertRow(int const i, QString const & uiString,
|
||||||
std::string const & idString)
|
std::string const & idString)
|
||||||
{
|
{
|
||||||
insertRows(i, 1);
|
insertRows(i, 1);
|
||||||
|
@ -66,8 +66,8 @@ public:
|
|||||||
void setUIString(QModelIndex const & index, QString const & value)
|
void setUIString(QModelIndex const & index, QString const & value)
|
||||||
{ setData(index, value); };
|
{ setData(index, value); };
|
||||||
///
|
///
|
||||||
void setUIString(int const i, std::string const & value)
|
void setUIString(int const i, QString const & value)
|
||||||
{ setUIString(index(i), toqstr(value)); };
|
{ setUIString(index(i), value); };
|
||||||
///
|
///
|
||||||
void setIDString(QModelIndex const & index, QString const & value)
|
void setIDString(QModelIndex const & index, QString const & value)
|
||||||
{ setData(index, value, Qt::UserRole); };
|
{ setData(index, value, Qt::UserRole); };
|
||||||
@ -81,12 +81,12 @@ public:
|
|||||||
virtual std::string getIDString(int const i) const
|
virtual std::string getIDString(int const i) const
|
||||||
{ return fromqstr(getIDString(index(i))); };
|
{ return fromqstr(getIDString(index(i))); };
|
||||||
///
|
///
|
||||||
void insertRow(int const i, std::string const & uiString,
|
void insertRow(int const i, QString const & uiString,
|
||||||
std::string const & idString);
|
std::string const & idString);
|
||||||
/* The following functions are currently unused but are retained here in
|
/* The following functions are currently unused but are retained here in
|
||||||
case they should at some point be useful.
|
case they should at some point be useful.
|
||||||
///
|
///
|
||||||
void setUIString(int const i, QString const & value)
|
void setUIString(int const i, std::string const & value)
|
||||||
{ setUIString(index(i), value); };
|
{ setUIString(index(i), value); };
|
||||||
///
|
///
|
||||||
void setIDString(int const i, QString const & value)
|
void setIDString(int const i, QString const & value)
|
||||||
@ -96,6 +96,9 @@ public:
|
|||||||
///
|
///
|
||||||
void insertRow(int const i, QString const & uiString,
|
void insertRow(int const i, QString const & uiString,
|
||||||
QString const & idString);
|
QString const & idString);
|
||||||
|
///
|
||||||
|
void insertRow(int const i, std::string const & uiString,
|
||||||
|
std::string const & idString);
|
||||||
/// Returns whether the model contains an item with the given ID
|
/// Returns whether the model contains an item with the given ID
|
||||||
bool containsID(QVariant const &) const;
|
bool containsID(QVariant const &) const;
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user