Improve list of available languages for UI l10n.

Add a new tag HasGuiSupport to language file. Add it for all l10ns
that we currently ship. The po files that are unused are not currently
tagged as available, but this could be done, since the code later
checks that the translation is actually there.

This new information is used in GuiPrefs when populating the language
combox.

The new scheme implies that adding a new language is now a two-step
process:
* the language code has to be added to po/LINGUAS, as before;
* one of the entries of the lib/language file has to be selected as
  reference and be given the "HasGuiSupport true" property.
This commit is contained in:
Jean-Marc Lasgouttes 2015-05-07 17:20:23 +02:00
parent f70e78487e
commit 88609b3984
5 changed files with 82 additions and 30 deletions

View File

@ -1,14 +1,14 @@
Localization/Translation FAQ
(2007-2011)
by Ran Rutenberg, Pavel Sanda, Michael Gerz
PART I - Interface translation
------------------------------
This file is mainly intended for those who have no or little experience using
This file is mainly intended for those who have no or little experience using
.po files, but want to contribute by translating the LyX interface (i.e. menu
and dialog items, console messages) into their native language.
@ -34,10 +34,10 @@ can follow http://www.lyx.org/HowToUseGIT page.
2) HOW DO I EDIT PO FILES?
PO files can be edited with any text editor available for your system (e.g.
Vim, NotePad etc.). Yet another option is to use a specialized editor for .po
files. You can e.g. use the editors "poEdit" or "jEdit", Linux users can
additionally use e.g. "kbabel". Using these editors usually makes things easier
PO files can be edited with any text editor available for your system (e.g.
Vim, NotePad etc.). Yet another option is to use a specialized editor for .po
files. You can e.g. use the editors "poEdit" or "jEdit", Linux users can
additionally use e.g. "kbabel". Using these editors usually makes things easier
as they have many tools to assist the translator.
@ -58,16 +58,16 @@ translation for them.
'&' stands for underlined characters (shortcut) in dialog boxes.
'|' stands for underlined characters in menus.
These chars should be somehow used in your translations, however you'll have to
invent your own working shortcuts for dialog and menu entries and resolve
possible conflicts of the same shortcut chars in one menu...
These chars should be somehow used in your translations, however you'll have to
invent your own working shortcuts for dialog and menu entries and resolve
possible conflicts of the same shortcut chars in one menu...
Note also that there are already used global shortcuts (such as p k x c m s a)
and you should avoid using these characters for first-level menu shortcuts.
'$' and '%' are usually used as handlers for formatting or variables to be
inserted into the strings. Character sequences like %1$s or %1$d MUST also
appear in your translations! Please take them exactly as they are or you may
'$' and '%' are usually used as handlers for formatting or variables to be
inserted into the strings. Character sequences like %1$s or %1$d MUST also
appear in your translations! Please take them exactly as they are or you may
experience crashes when running LyX.
[[Context]] is used to distinguish otherwise identical strings, which could
@ -82,7 +82,7 @@ msgstr "Algoritmus \\arabic{theorem}"
5) WHAT IS pocheck.pl AND HOW DO I USE IT?
This is a small script located in the "po" directory of the source that helps
This is a small script located in the "po" directory of the source that helps
you find common errors in your translation. In order to use this script you
need the script language Perl installed.
Run ./pocheck.pl -h to see all possible switches.
@ -94,16 +94,23 @@ In order to test your translation you need to obtain the LyX sources
(from the git repository) and replace the existing .po with yours.
Afterwards, you should compile and optionally install LyX (check the
INSTALL file for your OS). Note that, as of LyX 2.1, it is not
necessary anymore to install anything. In order to run LyX with your
translation, change the current language in Preferences dialog or use
the appropriate LANG variable:
necessary anymore to install anything.
In order to run LyX with your translation, change the current language
in Preferences dialog or use the appropriate LANG variable:
On Linux: LANG=xx_CC lyx
On Windows, you need to change the lyx.bat file and write: set LANG=xx_CC
xx stands for your language code. CC stands for your country code. So to get,
xx stands for your language code. CC stands for your country code. So to get,
e.g., Czech, the code is "cs_CZ".
Another possibility is to use the Preferences dialog to set LyX UI to
use your language. Note that, as of LyX 2.2, a newly introduced
language will not appear in the languages combox unless it corresponds
to an entry of the lib/languages file that has a "HasGuiSupport true"
property. See this file for more details.
The most comfortable way to see your updated translation while
editing, is running (in linux) "make xx.gmo" in the po directory to
compile updated xx.po translation and then run LyX.
@ -113,7 +120,7 @@ For advanced users - if you want to remerge your files against current source:
- on Linux: execute the command: make update-po
- on Windows: either build the update-po target in MSVC
or run the command: msbuild po\update-po.vcxproj
(depending on the directory you are in)
(depending on the directory you are in)
7) HOW TO CONTRIBUTE MY WORK?

View File

@ -6,6 +6,7 @@
#
# Language <lyxname>
# GuiName "<Gui Name>"
# HasGuiSupport <true|false>
# BabelName <babelname>
# PolyglossiaName <polyglossianame>
# PolyglossiaOpts "<language-specific options>"
@ -31,6 +32,13 @@
#
# * Omitted elements will be treated as empty (if string) or "false"
# (if boolean).
# * When HasGuiSupport is true, the language is candidate to appear in
# the list of possible GUI languages in the Preferences dialog. It
# will actually appear there only if a corresponding .mo file can be
# found among the translations. When several languages correspond to
# the same translation -- like English, English (US) and English
# (UK) -- try to select the entry that is most generic -- here
# English.
# * The QuoteStyle arguments correspond to the following styles:
# - danish: >>text<< >text< (inward guillemets)
# - english: ``text'' `text' (66_99)
@ -141,6 +149,7 @@ End
# to switch the language the way of the ArabTeX-package
Language arabic_arabtex
GuiName "Arabic (ArabTeX)"
HasGuiSupport true
BabelName arabtex
QuoteStyle french
Encoding cp1256
@ -206,6 +215,7 @@ End
Language bahasa
GuiName "Indonesian"
HasGuiSupport true
BabelName bahasa
PolyglossiaName bahasai
QuoteStyle english
@ -224,6 +234,7 @@ End
Language basque
GuiName "Basque"
HasGuiSupport true
BabelName basque
PolyglossiaName basque
QuoteStyle french
@ -246,6 +257,7 @@ End
Language brazilian
GuiName "Portuguese (Brazil)"
HasGuiSupport true
BabelName brazil
PolyglossiaName brazil
QuoteStyle english
@ -305,6 +317,7 @@ End
Language catalan
GuiName "Catalan"
HasGuiSupport true
BabelName catalan
PolyglossiaName catalan
PolyglossiaOpts "babelshorthands=true"
@ -316,6 +329,7 @@ End
# uses CJK package
Language chinese-simplified
GuiName "Chinese (simplified)"
HasGuiSupport true
Encoding euc-cn
QuoteStyle english
LangCode zh_CN
@ -325,6 +339,7 @@ End
# uses CJK package
Language chinese-traditional
GuiName "Chinese (traditional)"
HasGuiSupport true
QuoteStyle english
Encoding utf8-cjk
LangCode zh_TW
@ -350,6 +365,7 @@ End
Language czech
GuiName "Czech"
HasGuiSupport true
BabelName czech
PolyglossiaName czech
QuoteStyle german
@ -359,6 +375,7 @@ End
Language danish
GuiName "Danish"
HasGuiSupport true
BabelName danish
PolyglossiaName danish
QuoteStyle danish
@ -376,6 +393,7 @@ End
Language dutch
GuiName "Dutch"
HasGuiSupport true
BabelName dutch
PolyglossiaName dutch
PolyglossiaOpts "babelshorthands=true"
@ -386,6 +404,7 @@ End
Language english
GuiName "English"
HasGuiSupport true
BabelName english
PolyglossiaName english
QuoteStyle english
@ -434,6 +453,7 @@ End
Language finnish
GuiName "Finnish"
HasGuiSupport true
BabelName finnish
PolyglossiaName finnish
QuoteStyle swedish
@ -444,6 +464,7 @@ End
# We redefine \og and \fg (guillemets) for older french language definitions
Language french
GuiName "French"
HasGuiSupport true
BabelName french
PolyglossiaName french
QuoteStyle french
@ -459,6 +480,7 @@ End
Language galician
GuiName "Galician"
HasGuiSupport true
BabelName galician
PolyglossiaName galician
QuoteStyle french
@ -493,6 +515,7 @@ End
Language ngerman
GuiName "German"
HasGuiSupport true
BabelName ngerman
PolyglossiaName german
PolyglossiaOpts "babelshorthands=true"
@ -532,6 +555,7 @@ End
Language greek
GuiName "Greek"
HasGuiSupport true
BabelName greek
PolyglossiaName greek
QuoteStyle french
@ -555,6 +579,7 @@ End
Language hebrew
GuiName "Hebrew"
HasGuiSupport true
BabelName hebrew
PolyglossiaName hebrew
Encoding cp1255
@ -599,6 +624,7 @@ End
# language. We therefore the name of its hunspell dictionary.
Language interlingua
GuiName "Interlingua"
HasGuiSupport true
BabelName interlingua
PolyglossiaName interlingua
Encoding iso8859-15
@ -616,6 +642,7 @@ End
Language italian
GuiName "Italian"
HasGuiSupport true
BabelName italian
PolyglossiaName italian
QuoteStyle french
@ -630,6 +657,7 @@ End
# InternalEncoding to true.
Language japanese
GuiName "Japanese"
HasGuiSupport true
BabelName japanese
Encoding jis-platex
LangCode ja_JP
@ -729,6 +757,7 @@ End
Language magyar
GuiName "Hungarian"
HasGuiSupport true
BabelName magyar
PolyglossiaName magyar
QuoteStyle polish
@ -767,6 +796,7 @@ End
Language norsk
GuiName "Norwegian (Bokmaal)"
HasGuiSupport true
BabelName norsk
PolyglossiaName norsk
QuoteStyle french
@ -776,6 +806,7 @@ End
Language nynorsk
GuiName "Norwegian (Nynorsk)"
HasGuiSupport true
BabelName nynorsk
PolyglossiaName nynorsk
QuoteStyle french
@ -804,6 +835,7 @@ End
Language polish
GuiName "Polish"
HasGuiSupport true
BabelName polish
PolyglossiaName polish
QuoteStyle polish
@ -813,6 +845,7 @@ End
Language portuguese
GuiName "Portuguese"
HasGuiSupport true
BabelName portuges
PolyglossiaName portuges
QuoteStyle english
@ -822,6 +855,7 @@ End
Language romanian
GuiName "Romanian"
HasGuiSupport true
BabelName romanian
PolyglossiaName romanian
QuoteStyle polish
@ -831,6 +865,7 @@ End
Language russian
GuiName "Russian"
HasGuiSupport true
BabelName russian
PolyglossiaName russian
QuoteStyle french
@ -867,6 +902,7 @@ End
Language serbian
GuiName "Serbian"
HasGuiSupport true
BabelName serbianc
PolyglossiaName serbian
QuoteStyle german
@ -887,6 +923,7 @@ End
Language slovak
GuiName "Slovak"
HasGuiSupport true
BabelName slovak
PolyglossiaName slovak
QuoteStyle german
@ -905,6 +942,7 @@ End
Language spanish
GuiName "Spanish"
HasGuiSupport true
BabelName spanish
PolyglossiaName spanish
QuoteStyle french
@ -930,6 +968,7 @@ End
Language swedish
GuiName "Swedish"
HasGuiSupport true
BabelName swedish
PolyglossiaName swedish
QuoteStyle swedish
@ -984,6 +1023,7 @@ End
Language turkish
GuiName "Turkish"
HasGuiSupport true
BabelName turkish
PolyglossiaName turkish
QuoteStyle french
@ -1008,6 +1048,7 @@ End
Language ukrainian
GuiName "Ukrainian"
HasGuiSupport true
BabelName ukrainian
PolyglossiaName ukrainian
QuoteStyle french

View File

@ -74,6 +74,7 @@ bool Language::readLanguage(Lexer & lex)
LA_END,
LA_FONTENC,
LA_GUINAME,
LA_HAS_GUI_SUPPORT,
LA_INTERNAL_ENC,
LA_LANG_CODE,
LA_LANG_VARIETY,
@ -94,6 +95,7 @@ bool Language::readLanguage(Lexer & lex)
{ "end", LA_END },
{ "fontencoding", LA_FONTENC },
{ "guiname", LA_GUINAME },
{ "hasguisupport", LA_HAS_GUI_SUPPORT },
{ "internalencoding", LA_INTERNAL_ENC },
{ "langcode", LA_LANG_CODE },
{ "langvariety", LA_LANG_VARIETY },
@ -153,6 +155,9 @@ bool Language::readLanguage(Lexer & lex)
case LA_GUINAME:
lex >> display_;
break;
case LA_HAS_GUI_SUPPORT:
lex >> has_gui_support_;
break;
case LA_INTERNAL_ENC:
lex >> internal_enc_;
break;

View File

@ -33,7 +33,7 @@ class Language {
public:
///
Language() : rightToLeft_(false), encoding_(0), internal_enc_(false),
as_babel_options_(false) {}
as_babel_options_(false), has_gui_support_(false) {}
/// LyX language name
std::string const lang() const { return lang_; }
/// Babel language name
@ -81,6 +81,8 @@ public:
std::string const fontenc() const { return fontenc_; }
/// This language needs to be passed to babel itself (not the class)
bool asBabelOptions() const { return as_babel_options_; }
/// This language correspongs to a translation of the GUI
bool hasGuiSupport() const { return has_gui_support_; }
///
bool read(Lexer & lex);
///
@ -127,6 +129,8 @@ private:
///
bool as_babel_options_;
///
bool has_gui_support_;
///
TranslationMap layoutTranslations_;
};
@ -158,7 +162,6 @@ public:
const_iterator begin() const { return languagelist.begin(); }
///
const_iterator end() const { return languagelist.end(); }
///
private:
///

View File

@ -2309,19 +2309,16 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
startCommandED->setValidator(new NoNewLineValidator(startCommandED));
endCommandED->setValidator(new NoNewLineValidator(endCommandED));
uiLanguageCO->clear();
QAbstractItemModel * language_model = guiApp->languageModel();
// FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
language_model->sort(0);
defaultDecimalPointLE->setInputMask("X; ");
defaultDecimalPointLE->setMaxLength(1);
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::IN]), Length::IN);
set<string> added;
QAbstractItemModel * language_model = guiApp->languageModel();
language_model->sort(0);
uiLanguageCO->blockSignals(true);
uiLanguageCO->clear();
uiLanguageCO->addItem(qt_("Default"), toqstr("auto"));
for (int i = 0; i != language_model->rowCount(); ++i) {
QModelIndex index = language_model->index(i, 0);
@ -2335,11 +2332,10 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
if (name != form->rc().gui_language
&& name != lyxrc.gui_language
&& (!Messages::available(lang->code())
|| added.find(lang->code()) != added.end()))
continue;
added.insert(lang->code());
|| !lang->hasGuiSupport()))
continue;
uiLanguageCO->addItem(index.data(Qt::DisplayRole).toString(),
index.data(Qt::UserRole).toString());
index.data(Qt::UserRole).toString());
}
uiLanguageCO->blockSignals(false);
}