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 ; \
|
||||
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 ; \
|
||||
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
|
||||
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()
|
||||
|
||||
|
||||
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):
|
||||
'''Generate pot file from lib/layouts/*.layout and *.inc'''
|
||||
output = open(output, 'w')
|
||||
'''Generate pot file from lib/layouts/*.{layout,inc,module}'''
|
||||
out = open(output, 'w')
|
||||
Style = re.compile(r'^Style\s+(.*)')
|
||||
# include ???LabelString???, but exclude comment lines
|
||||
LabelString = re.compile(r'^[^#]*LabelString\S*\s+(.*)')
|
||||
GuiName = re.compile(r'\s*GuiName\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:
|
||||
input = open(src)
|
||||
for lineno, line in enumerate(input.readlines()):
|
||||
if Style.match(line):
|
||||
(string,) = Style.match(line).groups()
|
||||
string = string.replace('_', ' ')
|
||||
elif LabelString.match(line):
|
||||
(string,) = LabelString.match(line).groups()
|
||||
elif GuiName.match(line):
|
||||
(string,) = GuiName.match(line).groups()
|
||||
elif ListName.match(line):
|
||||
(string,) = ListName.match(line).groups()
|
||||
else:
|
||||
readingDescription = False
|
||||
descStartLine = -1
|
||||
descLines = []
|
||||
lineno = 0
|
||||
for line in open(src).readlines():
|
||||
lineno += 1
|
||||
if readingDescription:
|
||||
res = DescEnd.search(line)
|
||||
if res != None:
|
||||
readingDescription = False
|
||||
desc = " ".join(descLines)
|
||||
print >> out, '#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
|
||||
(relativePath(src, base), lineno + 1, desc)
|
||||
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('"', '')
|
||||
if string != "":
|
||||
print >> output, '#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
|
||||
print >> out, '#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
|
||||
(relativePath(src, base), lineno + 1, string)
|
||||
input.close()
|
||||
output.close()
|
||||
continue
|
||||
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):
|
||||
@ -227,7 +270,7 @@ if __name__ == '__main__':
|
||||
base = value
|
||||
elif opt in ['-t', '--type']:
|
||||
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.'
|
||||
sys.exit(1)
|
||||
if input_type == 'ui':
|
||||
|
@ -174,7 +174,7 @@ namespace {
|
||||
LyXModule const * const mod = moduleList[modName];
|
||||
if (!mod)
|
||||
return _("Module not found!");
|
||||
return from_ascii(mod->getDescription());
|
||||
return _(mod->getDescription());
|
||||
}
|
||||
|
||||
|
||||
@ -1962,7 +1962,7 @@ void GuiDocument::updateAvailableModules()
|
||||
int const mSize = modInfoList.size();
|
||||
for (int i = 0; i < mSize; ++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();
|
||||
for (int i = 0; i < sSize; ++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)
|
||||
{
|
||||
insertRows(i, 1);
|
||||
|
@ -66,8 +66,8 @@ public:
|
||||
void setUIString(QModelIndex const & index, QString const & value)
|
||||
{ setData(index, value); };
|
||||
///
|
||||
void setUIString(int const i, std::string const & value)
|
||||
{ setUIString(index(i), toqstr(value)); };
|
||||
void setUIString(int const i, QString const & value)
|
||||
{ setUIString(index(i), value); };
|
||||
///
|
||||
void setIDString(QModelIndex const & index, QString const & value)
|
||||
{ setData(index, value, Qt::UserRole); };
|
||||
@ -81,12 +81,12 @@ public:
|
||||
virtual std::string getIDString(int const i) const
|
||||
{ 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);
|
||||
/* The following functions are currently unused but are retained here in
|
||||
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); };
|
||||
///
|
||||
void setIDString(int const i, QString const & value)
|
||||
@ -96,6 +96,9 @@ public:
|
||||
///
|
||||
void insertRow(int const i, QString const & uiString,
|
||||
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
|
||||
bool containsID(QVariant const &) const;
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user