diff --git a/development/scons/SConstruct b/development/scons/SConstruct index b0aef42654..8becd1272a 100644 --- a/development/scons/SConstruct +++ b/development/scons/SConstruct @@ -1762,7 +1762,7 @@ if 'update_po' in BUILD_TARGETS: ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files + src_tex2lyx_files ] ) Alias('update_po', POTFILES_in) - # build language_l10n.pot, ui_l10n.pot, layouts_l10n.pot, qt4_l10n.pot, external_l10n, formats_l10n + # build language_l10n.pot, encodings_10n.pot, ui_l10n.pot, layouts_l10n.pot, qt4_l10n.pot, external_l10n, formats_l10n # and combine them to lyx.po env['LYX_POT'] = 'python $TOP_SRCDIR/po/lyx_pot.py' lyx_po = env.Command('$BUILDDIR/po/lyx.po', @@ -1775,6 +1775,8 @@ if 'update_po' in BUILD_TARGETS: '$LYX_POT -b $TOP_SRCDIR -t layouts -o $TARGET $SOURCES'), env.Command('$BUILDDIR/po/languages_l10n.pot', '$TOP_SRCDIR/lib/languages', '$LYX_POT -b $TOP_SRCDIR -t languages -o $TARGET $SOURCES'), + env.Command('$BUILDDIR/po/encodings_l10n.pot', '$TOP_SRCDIR/lib/encodings', + '$LYX_POT -b $TOP_SRCDIR -t encodings -o $TARGET $SOURCES'), env.Command('$BUILDDIR/po/ui_l10n.pot', ['$TOP_SRCDIR/lib/ui/%s' % x for x in lib_ui_files], '$LYX_POT -b $TOP_SRCDIR -t ui -o $TARGET $SOURCES'), diff --git a/lib/encodings b/lib/encodings index ee65d183c3..66d571231e 100644 --- a/lib/encodings +++ b/lib/encodings @@ -7,117 +7,117 @@ # These are marked with the "variable" keyword. # Fixed width encodings are marked with the "fixed" keyword. -# Syntax: Encoding fixed|variable End +# Syntax: Encoding fixed|variable End # encodings used by inputenc.sty -Encoding utf8 utf8 UTF-8 variable inputenc +Encoding utf8 utf8 "Unicode (utf8)" UTF-8 variable inputenc End # This one is used by many CJK packages. utf8 is supposed to be the successor, # but does not have all features of utf8x yet. -Encoding utf8x utf8x UTF-8 variable inputenc +Encoding utf8x utf8x "Unicode (ucs-extended) (utf8x)" UTF-8 variable inputenc End # This encoding is used to typeset Armenian using the armTeX package -Encoding armscii8 armscii8 ARMSCII-8 fixed inputenc +Encoding armscii8 armscii8 "Armenian (ArmSCII8)" ARMSCII-8 fixed inputenc End -Encoding iso8859-1 latin1 ISO-8859-1 fixed inputenc +Encoding iso8859-1 latin1 "Western European (ISO 8859-1)" ISO-8859-1 fixed inputenc End -Encoding iso8859-2 latin2 ISO-8859-2 fixed inputenc +Encoding iso8859-2 latin2 "Central European (ISO 8859-2)" ISO-8859-2 fixed inputenc End -Encoding iso8859-3 latin3 ISO-8859-3 fixed inputenc +Encoding iso8859-3 latin3 "Middle European (ISO 8859-3)" ISO-8859-3 fixed inputenc End -Encoding iso8859-4 latin4 ISO-8859-4 fixed inputenc +Encoding iso8859-4 latin4 "Baltic (ISO 8859-4)" ISO-8859-4 fixed inputenc End -Encoding iso8859-5 iso88595 ISO-8859-5 fixed inputenc +Encoding iso8859-5 iso88595 "Cyrillic (ISO 8859-5)" ISO-8859-5 fixed inputenc End # Not standard, see http://tug.ctan.org/tex-archive/language/arabic/arabi/arabi/texmf/latex/arabi/ -Encoding iso8859-6 8859-6 ISO-8859-6 fixed inputenc +Encoding iso8859-6 8859-6 "Arabic (ISO 8859-6)" ISO-8859-6 fixed inputenc End -Encoding iso8859-7 iso-8859-7 ISO-8859-7 fixed inputenc +Encoding iso8859-7 iso-8859-7 "Greek (ISO 8859-7)" ISO-8859-7 fixed inputenc End -Encoding iso8859-8 8859-8 ISO-8859-8 fixed inputenc +Encoding iso8859-8 8859-8 "Hebrew (ISO 8859-8)" ISO-8859-8 fixed inputenc End -Encoding iso8859-9 latin5 ISO-8859-9 fixed inputenc +Encoding iso8859-9 latin5 "Turkish (ISO 8859-9)" ISO-8859-9 fixed inputenc End # Not standard, see http://www.vtex.lt/tex/littex/index.html -Encoding iso8859-13 l7xenc ISO-8859-13 fixed inputenc +Encoding iso8859-13 l7xenc "Baltic (ISO 8859-13)" ISO-8859-13 fixed inputenc End -Encoding iso8859-15 latin9 ISO-8859-15 fixed inputenc +Encoding iso8859-15 latin9 "Western European (ISO 8859-15)" ISO-8859-15 fixed inputenc End -Encoding iso8859-16 latin10 ISO-8859-16 fixed inputenc +Encoding iso8859-16 latin10 "South-Eastern European (ISO 8859-16)" ISO-8859-16 fixed inputenc End -Encoding cp437 cp437 CP437 fixed inputenc +Encoding cp437 cp437 "DOS (CP 437)" CP437 fixed inputenc End # cp437, but on position 225 is sz instead of beta -Encoding cp437de cp437de CP437 fixed inputenc +Encoding cp437de cp437de "DOS-de (CP 437-de)" CP437 fixed inputenc End -Encoding cp850 cp850 CP850 fixed inputenc +Encoding cp850 cp850 "Western European (CP 850)" CP850 fixed inputenc End -Encoding cp852 cp852 CP852 fixed inputenc +Encoding cp852 cp852 "Central European (CP 852)" CP852 fixed inputenc End -Encoding cp855 cp855 CP855 fixed inputenc +Encoding cp855 cp855 "Cyrillic (CP 855)" CP855 fixed inputenc End -Encoding cp858 cp858 CP858 fixed inputenc +Encoding cp858 cp858 "Western European (CP 858)" CP858 fixed inputenc End -Encoding cp862 cp862 CP862 fixed inputenc +Encoding cp862 cp862 "Hebrew (CP 862)" CP862 fixed inputenc End -Encoding cp865 cp865 CP865 fixed inputenc +Encoding cp865 cp865 "Nordic languages (CP 865)" CP865 fixed inputenc End -Encoding cp866 cp866 CP866 fixed inputenc +Encoding cp866 cp866 "Cyrillic (CP 866)" CP866 fixed inputenc End -Encoding cp1250 cp1250 CP1250 fixed inputenc +Encoding cp1250 cp1250 "Central European (CP 1250)" CP1250 fixed inputenc End -Encoding cp1251 cp1251 CP1251 fixed inputenc +Encoding cp1251 cp1251 "Cyrillic (CP 1251)" CP1251 fixed inputenc End -Encoding cp1252 cp1252 CP1252 fixed inputenc +Encoding cp1252 cp1252 "Western European (CP 1252)" CP1252 fixed inputenc End -Encoding cp1255 cp1255 CP1255 fixed inputenc +Encoding cp1255 cp1255 "Hebrew (CP 1255)" CP1255 fixed inputenc End # Not standard, see http://tug.ctan.org/tex-archive/language/arabic/arabi/arabi/texmf/latex/arabi/ -Encoding cp1256 cp1256 CP1256 fixed inputenc +Encoding cp1256 cp1256 "Arabic (CP 1256)" CP1256 fixed inputenc End -Encoding cp1257 cp1257 CP1257 fixed inputenc +Encoding cp1257 cp1257 "Baltic (CP 1257)" CP1257 fixed inputenc End -Encoding koi8 koi8-r KOI8-R fixed inputenc +Encoding koi8 koi8-r "Cyrillic (KOI8-R)" KOI8-R fixed inputenc End -Encoding koi8-u koi8-u KOI8-U fixed inputenc +Encoding koi8-u koi8-u "Cyrillic (KOI8-U)" KOI8-U fixed inputenc End -Encoding pt154 pt154 PT154 fixed inputenc +Encoding pt154 pt154 "Cyrillic (pt 154)" PT154 fixed inputenc End -Encoding pt254 pt254 PT254 fixed inputenc +Encoding pt254 pt254 "Cyrillic (pt 254)" PT254 fixed inputenc End # encodings used by CJK.sty @@ -131,68 +131,68 @@ End # of TeX control characters like {, } and \ can occur in the second byte: # For traditional chinese -#Encoding big5 Bg5 BIG5 variable CJK +#Encoding big5 Bg5 "Chinese (traditional) (Big5)" BIG5 variable CJK #End # For japanese -#Encoding shift-jis SJIS SJIS variable CJK +#Encoding shift-jis SJIS "Japanese (CJK) (SJIS)" SJIS variable CJK #End # The following encodings need hardcoded support of the encodable unicode # range, but are known by iconv: # For simplified chinese -Encoding euc-cn GB EUC-CN variable CJK +Encoding euc-cn GB "Chinese (simplified) (EUC-CN)" EUC-CN variable CJK End # For simplified chinese -Encoding gbk GBK GBK variable CJK +Encoding gbk GBK "Chinese (simplified) (GBK)" GBK variable CJK End # For japanese -Encoding jis JIS ISO-2022-JP variable CJK +Encoding jis JIS "Japanese (CJK) (JIS)" ISO-2022-JP variable CJK End # For korean -Encoding euc-kr KS EUC-KR variable CJK +Encoding euc-kr KS "Korean (EUC-KR)" EUC-KR variable CJK End # The CJK package has yet another name for utf8... -Encoding utf8-cjk UTF8 UTF-8 variable CJK +Encoding utf8-cjk UTF8 "Unicode (CJK) (utf8)" UTF-8 variable CJK End # For traditional chinese -Encoding euc-tw EUC-TW EUC-TW variable CJK +Encoding euc-tw EUC-TW "Chinese (traditional) (EUC-TW)" EUC-TW variable CJK End # For japanese -Encoding euc-jp EUC-JP EUC-JP variable CJK +Encoding euc-jp EUC-JP "Japanese (CJK) (EUC-JP)" EUC-JP variable CJK End # encodings that do not use a package # Traditional Japanese TeX programs require neither CJK nor inputenc # package. -Encoding euc-jp-plain EUC-JP-pLaTeX EUC-JP variable none +Encoding euc-jp-plain EUC-JP-pLaTeX "Japanese (non-CJK) (EUC-JP)" EUC-JP variable none End -Encoding jis-plain JIS-pLaTeX ISO-2022-JP variable none +Encoding jis-plain JIS-pLaTeX "Japanese (non-CJK) (JIS)" ISO-2022-JP variable none End -Encoding shift-jis-plain SJIS-pLaTeX CP932 variable none +Encoding shift-jis-plain SJIS-pLaTeX "Japanese (non-CJK) (SJIS)" CP932 variable none End # This one needs hardcoded support, since the inputenc package does not know # tis620-0, and thailatex sets up babel directly to use tis620-0, so the # LaTeX name is never output to .tex files (but needed for the hardcoded # tis620-0 support). -Encoding tis620-0 tis620-0 TIS620-0 fixed none +Encoding tis620-0 tis620-0 "Thai (TIS 620-0)" TIS620-0 fixed none End # A plain utf8 encoding that does not use the inputenc package. # Such an encoding is required for XeTeX. -Encoding utf8-plain utf8-plain UTF-8 variable none +Encoding utf8-plain utf8-plain "Unicode (XeTeX) (utf8)" UTF-8 variable none End # Pure 7bit ASCII encoding (partially hardcoded in LyX) -Encoding ascii ascii ascii fixed none +Encoding ascii ascii "ASCII" ascii fixed none End diff --git a/po/Rules-lyx b/po/Rules-lyx index f46aa5734d..4c853320f7 100644 --- a/po/Rules-lyx +++ b/po/Rules-lyx @@ -16,7 +16,7 @@ ${srcdir}/POTFILES.in: $(POTFILE_IN_DEPS) sort | uniq ) > $@-t \ && mv $@-t $@ -l10n_pots: qt4_l10n.pot layouts_l10n.pot languages_l10n.pot ui_l10n.pot external_l10n.pot formats_l10n.pot +l10n_pots: qt4_l10n.pot layouts_l10n.pot languages_l10n.pot encodings_l10n.pot ui_l10n.pot external_l10n.pot formats_l10n.pot cat $^ | \ msguniq -o $(DOMAIN).po && rm -f $^ @@ -33,6 +33,9 @@ layouts_l10n.pot: $(top_srcdir)/lib/layouts/*.layout $(top_srcdir)/lib/layouts/* languages_l10n.pot: $(top_srcdir)/lib/languages python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t languages ${top_srcdir}/lib/languages +encodings_l10n.pot: $(top_srcdir)/lib/encodings + python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t encodings ${top_srcdir}/lib/encodings + ui_l10n.pot: $(top_srcdir)/lib/ui/*.ui $(top_srcdir)/lib/ui/*.inc LC_ALL=C ; export LC_ALL ; \ python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t ui ${top_srcdir}/lib/ui/*.ui ${top_srcdir}/lib/ui/*.inc diff --git a/po/lyx_pot.py b/po/lyx_pot.py index d1b4bdba69..551f009533 100755 --- a/po/lyx_pot.py +++ b/po/lyx_pot.py @@ -282,6 +282,29 @@ def formats_l10n(input_files, output, base): output.close() +def encodings_l10n(input_files, output, base): + '''Generate pot file from lib/encodings''' + output = open(output, 'w') + # assuming only one encodings file + # Encoding utf8 utf8 "Unicode (utf8)" UTF-8 variable inputenc + reg = re.compile('Encoding [\w-]+\s+[\w-]+\s+"([\w \-\(\)]+)"\s+[\w-]+\s+(fixed|variable)\s+\w+.*') + input = open(input_files[0]) + for lineno, line in enumerate(input.readlines()): + if not line.startswith('Encoding'): + continue + if reg.match(line): + print >> output, '#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \ + (relativePath(input_files[0], base), lineno+1, reg.match(line).groups()[0]) + else: + print "Error: Unable to handle line:" + print line + # No need to abort if the parsing fails + # sys.exit(1) + input.close() + output.close() + + + Usage = ''' lyx_pot.py [-b|--base top_src_dir] [-o|--output output_file] [-h|--help] -t|--type input_type input_files @@ -295,6 +318,7 @@ where layouts: lib/layouts/* qt4: qt4 ui files languages: file lib/languages + encodings: file lib/encodings external: external templates file formats: formats predefined in lib/configure.py ''' @@ -316,7 +340,7 @@ if __name__ == '__main__': base = value elif opt in ['-t', '--type']: input_type = value - if input_type not in ['ui', 'layouts', 'modules', 'qt4', 'languages', 'external', 'formats'] or output is None: + if input_type not in ['ui', 'layouts', 'modules', 'qt4', 'languages', 'encodings', 'external', 'formats'] or output is None: print 'Wrong input type or output filename.' sys.exit(1) if input_type == 'ui': @@ -329,6 +353,8 @@ if __name__ == '__main__': external_l10n(args, output, base) elif input_type == 'formats': formats_l10n(args, output, base) + elif input_type == 'encodings': + encodings_l10n(args, output, base) else: languages_l10n(args, output, base) diff --git a/src/Encoding.cpp b/src/Encoding.cpp index 398a7d16b6..7aee70c9b8 100644 --- a/src/Encoding.cpp +++ b/src/Encoding.cpp @@ -269,9 +269,9 @@ const char * EncodingException::what() const throw() } -Encoding::Encoding(string const & n, string const & l, string const & i, - bool f, Encoding::Package p) - : name_(n), latexName_(l), iconvName_(i), fixedwidth_(f), package_(p) +Encoding::Encoding(string const & n, string const & l, string const & g, + string const & i, bool f, Encoding::Package p) + : name_(n), latexName_(l), guiName_(g), iconvName_(i), fixedwidth_(f), package_(p) { if (n == "ascii") { // ASCII can encode 128 code points and nothing else @@ -731,6 +731,8 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile) lex.next(); string const latexname = lex.getString(); lex.next(); + string const guiname = lex.getString(); + lex.next(); string const iconvname = lex.getString(); lex.next(); string const width = lex.getString(); @@ -756,7 +758,7 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile) LYXERR(Debug::INFO, "Reading encoding " << name); encodinglist[name] = Encoding(name, latexname, - iconvname, fixedwidth, package); + guiname, iconvname, fixedwidth, package); if (lex.lex() != et_end) lex.printError("Missing end"); diff --git a/src/Encoding.h b/src/Encoding.h index 069431b22f..0024c8e592 100644 --- a/src/Encoding.h +++ b/src/Encoding.h @@ -51,7 +51,8 @@ public: Encoding() {} /// Encoding(std::string const & n, std::string const & l, - std::string const & i, bool f, Package p); + std::string const & g, std::string const & i, + bool f, Package p); /// void init() const; /// @@ -59,6 +60,8 @@ public: /// std::string const & latexName() const { return latexName_; } /// + std::string const & guiName() const { return guiName_; } + /// std::string const & iconvName() const { return iconvName_; } /** * Convert \p c to something that LaTeX can understand. @@ -79,6 +82,8 @@ private: /// std::string latexName_; /// + std::string guiName_; + /// std::string iconvName_; /// Is this a fixed width encoding? bool fixedwidth_; diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 1a7780cbdd..15b51d3cf4 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -796,12 +796,14 @@ GuiDocument::GuiDocument(GuiView & lv) langModule->languageCO->setModel(language_model); // Always put the default encoding in the first position. - // It is special because the displayed text is translated. langModule->encodingCO->addItem(qt_("LaTeX default")); + QStringList encodinglist; Encodings::const_iterator it = encodings.begin(); Encodings::const_iterator const end = encodings.end(); for (; it != end; ++it) - langModule->encodingCO->addItem(toqstr(it->latexName())); + encodinglist.append(qt_(it->guiName())); + encodinglist.sort(); + langModule->encodingCO->addItems(encodinglist); langModule->quoteStyleCO->addItem(qt_("``text''")); langModule->quoteStyleCO->addItem(qt_("''text''")); @@ -1481,9 +1483,25 @@ void GuiDocument::apply(BufferParams & params) int i = langModule->encodingCO->currentIndex(); if (i == 0) params.inputenc = "default"; - else - params.inputenc = - fromqstr(langModule->encodingCO->currentText()); + else { + QString const enc_gui = + langModule->encodingCO->currentText(); + Encodings::const_iterator it = encodings.begin(); + Encodings::const_iterator const end = encodings.end(); + bool found = false; + for (; it != end; ++it) { + if (qt_(it->guiName()) == enc_gui) { + params.inputenc = it->latexName(); + found = true; + break; + } + } + if (!found) { + // should not happen + lyxerr << "GuiDocument::apply: Unknown encoding! Resetting to default" << endl; + params.inputenc = "default"; + } + } } InsetQuotes::QuoteLanguage lga = InsetQuotes::EnglishQuotes; @@ -1796,8 +1814,17 @@ void GuiDocument::paramsToDialog(BufferParams const & params) if (params.inputenc == "default") { langModule->encodingCO->setCurrentIndex(0); } else { + string enc_gui; + Encodings::const_iterator it = encodings.begin(); + Encodings::const_iterator const end = encodings.end(); + for (; it != end; ++it) { + if (it->latexName() == params.inputenc) { + enc_gui = it->guiName(); + break; + } + } int const i = langModule->encodingCO->findText( - toqstr(params.inputenc)); + qt_(enc_gui)); if (i >= 0) langModule->encodingCO->setCurrentIndex(i); else