+ Language-specific stuff now lives in language.hh/.cc

+ Dictionary tooltips and dictionary info now show localized language names.
This commit is contained in:
Konstantin Isakov 2009-05-24 16:38:08 +00:00
parent b7b527f09c
commit ea1da19196
7 changed files with 1838 additions and 439 deletions

View file

@ -116,7 +116,8 @@ HEADERS += folding.hh \
russiantranslit.hh \ russiantranslit.hh \
german.hh \ german.hh \
website.hh \ website.hh \
orderandprops.hh orderandprops.hh \
language.hh
FORMS += groups.ui \ FORMS += groups.ui \
dictgroupwidget.ui \ dictgroupwidget.ui \
mainwindow.ui \ mainwindow.ui \
@ -184,7 +185,8 @@ SOURCES += folding.cc \
russiantranslit.cc \ russiantranslit.cc \
german.cc \ german.cc \
website.cc \ website.cc \
orderandprops.cc orderandprops.cc \
language.cc
win32 { win32 {
SOURCES += mouseover_win32/ThTypes.c SOURCES += mouseover_win32/ThTypes.c
HEADERS += mouseover_win32/ThTypes.h HEADERS += mouseover_win32/ThTypes.h

View file

@ -6,6 +6,7 @@
#include "instances.hh" #include "instances.hh"
#include "config.hh" #include "config.hh"
#include "langcoder.hh" #include "langcoder.hh"
#include "language.hh"
#include <QMenu> #include <QMenu>
#include <QDir> #include <QDir>
@ -107,8 +108,8 @@ QVariant DictListModel::data( QModelIndex const & index, int role ) const
{ {
QString tt = "<b>" + QString::fromUtf8( item->getName().c_str() ) + "</b>"; QString tt = "<b>" + QString::fromUtf8( item->getName().c_str() ) + "</b>";
QString lfrom( LangCoder::decode( item->getLangFrom() ) ); QString lfrom( Language::localizedNameForId( item->getLangFrom() ) );
QString lto( LangCoder::decode( item->getLangTo() ) ); QString lto( Language::localizedNameForId( item->getLangTo() ) );
if ( !lfrom.isEmpty() ) if ( !lfrom.isEmpty() )
{ {
if ( lfrom == lto ) if ( lfrom == lto )

View file

@ -7,6 +7,8 @@
#include "iconv.hh" #include "iconv.hh"
#include "folding.hh" #include "folding.hh"
#include "wstring_qt.hh" #include "wstring_qt.hh"
#include "language.hh"
#include "langcoder.hh"
#include <QRunnable> #include <QRunnable>
#include <QThreadPool> #include <QThreadPool>
#include <QSemaphore> #include <QSemaphore>
@ -636,219 +638,17 @@ vector< DataFiles > findDataFiles( QString const & path )
// Try making up good readable name from dictBaseId // Try making up good readable name from dictBaseId
QString localizedName;
if ( dictBaseId.size() == 2 )
localizedName = Language::localizedNameForId( LangCoder::code2toInt( dictBaseId.toAscii().data() ) );
QString dictName = dictId; QString dictName = dictId;
bool readableNameSucceeded = true; if ( localizedName.size() )
#define TRY_LANG( code, translation ) if ( dictBaseId == ( code ) ) dictName = ( translation ); else
// The following list was taken from the Wikipedia article
// "List of ISO 639-1 codes"
TRY_LANG( "aa", QCoreApplication::translate( "Hunspell", "Afar" ) )
TRY_LANG( "ab", QCoreApplication::translate( "Hunspell", "Abkhazian" ) )
TRY_LANG( "ae", QCoreApplication::translate( "Hunspell", "Avestan" ) )
TRY_LANG( "af", QCoreApplication::translate( "Hunspell", "Afrikaans" ) )
TRY_LANG( "ak", QCoreApplication::translate( "Hunspell", "Akan" ) )
TRY_LANG( "am", QCoreApplication::translate( "Hunspell", "Amharic" ) )
TRY_LANG( "an", QCoreApplication::translate( "Hunspell", "Aragonese" ) )
TRY_LANG( "ar", QCoreApplication::translate( "Hunspell", "Arabic" ) )
TRY_LANG( "as", QCoreApplication::translate( "Hunspell", "Assamese" ) )
TRY_LANG( "av", QCoreApplication::translate( "Hunspell", "Avaric" ) )
TRY_LANG( "ay", QCoreApplication::translate( "Hunspell", "Aymara" ) )
TRY_LANG( "az", QCoreApplication::translate( "Hunspell", "Azerbaijani" ) )
TRY_LANG( "ba", QCoreApplication::translate( "Hunspell", "Bashkir" ) )
TRY_LANG( "be", QCoreApplication::translate( "Hunspell", "Belarusian" ) )
TRY_LANG( "bg", QCoreApplication::translate( "Hunspell", "Bulgarian" ) )
TRY_LANG( "bh", QCoreApplication::translate( "Hunspell", "Bihari" ) )
TRY_LANG( "bi", QCoreApplication::translate( "Hunspell", "Bislama" ) )
TRY_LANG( "bm", QCoreApplication::translate( "Hunspell", "Bambara" ) )
TRY_LANG( "bn", QCoreApplication::translate( "Hunspell", "Bengali" ) )
TRY_LANG( "bo", QCoreApplication::translate( "Hunspell", "Tibetan" ) )
TRY_LANG( "br", QCoreApplication::translate( "Hunspell", "Breton" ) )
TRY_LANG( "bs", QCoreApplication::translate( "Hunspell", "Bosnian" ) )
TRY_LANG( "ca", QCoreApplication::translate( "Hunspell", "Catalan" ) )
TRY_LANG( "ce", QCoreApplication::translate( "Hunspell", "Chechen" ) )
TRY_LANG( "ch", QCoreApplication::translate( "Hunspell", "Chamorro" ) )
TRY_LANG( "co", QCoreApplication::translate( "Hunspell", "Corsican" ) )
TRY_LANG( "cr", QCoreApplication::translate( "Hunspell", "Cree" ) )
TRY_LANG( "cs", QCoreApplication::translate( "Hunspell", "Czech" ) )
TRY_LANG( "cu", QCoreApplication::translate( "Hunspell", "Church Slavic" ) )
TRY_LANG( "cv", QCoreApplication::translate( "Hunspell", "Chuvash" ) )
TRY_LANG( "cy", QCoreApplication::translate( "Hunspell", "Welsh" ) )
TRY_LANG( "da", QCoreApplication::translate( "Hunspell", "Danish" ) )
TRY_LANG( "de", QCoreApplication::translate( "Hunspell", "German" ) )
TRY_LANG( "dv", QCoreApplication::translate( "Hunspell", "Divehi" ) )
TRY_LANG( "dz", QCoreApplication::translate( "Hunspell", "Dzongkha" ) )
TRY_LANG( "ee", QCoreApplication::translate( "Hunspell", "Ewe" ) )
TRY_LANG( "el", QCoreApplication::translate( "Hunspell", "Greek" ) )
TRY_LANG( "en", QCoreApplication::translate( "Hunspell", "English" ) )
TRY_LANG( "eo", QCoreApplication::translate( "Hunspell", "Esperanto" ) )
TRY_LANG( "es", QCoreApplication::translate( "Hunspell", "Spanish" ) )
TRY_LANG( "et", QCoreApplication::translate( "Hunspell", "Estonian" ) )
TRY_LANG( "eu", QCoreApplication::translate( "Hunspell", "Basque" ) )
TRY_LANG( "fa", QCoreApplication::translate( "Hunspell", "Persian" ) )
TRY_LANG( "ff", QCoreApplication::translate( "Hunspell", "Fulah" ) )
TRY_LANG( "fi", QCoreApplication::translate( "Hunspell", "Finnish" ) )
TRY_LANG( "fj", QCoreApplication::translate( "Hunspell", "Fijian" ) )
TRY_LANG( "fo", QCoreApplication::translate( "Hunspell", "Faroese" ) )
TRY_LANG( "fr", QCoreApplication::translate( "Hunspell", "French" ) )
TRY_LANG( "fy", QCoreApplication::translate( "Hunspell", "Western Frisian" ) )
TRY_LANG( "ga", QCoreApplication::translate( "Hunspell", "Irish" ) )
TRY_LANG( "gd", QCoreApplication::translate( "Hunspell", "Scottish Gaelic" ) )
TRY_LANG( "gl", QCoreApplication::translate( "Hunspell", "Galician" ) )
TRY_LANG( "gn", QCoreApplication::translate( "Hunspell", "Guarani" ) )
TRY_LANG( "gu", QCoreApplication::translate( "Hunspell", "Gujarati" ) )
TRY_LANG( "gv", QCoreApplication::translate( "Hunspell", "Manx" ) )
TRY_LANG( "ha", QCoreApplication::translate( "Hunspell", "Hausa" ) )
TRY_LANG( "he", QCoreApplication::translate( "Hunspell", "Hebrew" ) )
TRY_LANG( "hi", QCoreApplication::translate( "Hunspell", "Hindi" ) )
TRY_LANG( "ho", QCoreApplication::translate( "Hunspell", "Hiri Motu" ) )
TRY_LANG( "hr", QCoreApplication::translate( "Hunspell", "Croatian" ) )
TRY_LANG( "ht", QCoreApplication::translate( "Hunspell", "Haitian" ) )
TRY_LANG( "hu", QCoreApplication::translate( "Hunspell", "Hungarian" ) )
TRY_LANG( "hy", QCoreApplication::translate( "Hunspell", "Armenian" ) )
TRY_LANG( "hz", QCoreApplication::translate( "Hunspell", "Herero" ) )
TRY_LANG( "ia", QCoreApplication::translate( "Hunspell", "Interlingua" ) )
TRY_LANG( "id", QCoreApplication::translate( "Hunspell", "Indonesian" ) )
TRY_LANG( "ie", QCoreApplication::translate( "Hunspell", "Interlingue" ) )
TRY_LANG( "ig", QCoreApplication::translate( "Hunspell", "Igbo" ) )
TRY_LANG( "ii", QCoreApplication::translate( "Hunspell", "Sichuan Yi" ) )
TRY_LANG( "ik", QCoreApplication::translate( "Hunspell", "Inupiaq" ) )
TRY_LANG( "io", QCoreApplication::translate( "Hunspell", "Ido" ) )
TRY_LANG( "is", QCoreApplication::translate( "Hunspell", "Icelandic" ) )
TRY_LANG( "it", QCoreApplication::translate( "Hunspell", "Italian" ) )
TRY_LANG( "iu", QCoreApplication::translate( "Hunspell", "Inuktitut" ) )
TRY_LANG( "ja", QCoreApplication::translate( "Hunspell", "Japanese" ) )
TRY_LANG( "jv", QCoreApplication::translate( "Hunspell", "Javanese" ) )
TRY_LANG( "ka", QCoreApplication::translate( "Hunspell", "Georgian" ) )
TRY_LANG( "kg", QCoreApplication::translate( "Hunspell", "Kongo" ) )
TRY_LANG( "ki", QCoreApplication::translate( "Hunspell", "Kikuyu" ) )
TRY_LANG( "kj", QCoreApplication::translate( "Hunspell", "Kwanyama" ) )
TRY_LANG( "kk", QCoreApplication::translate( "Hunspell", "Kazakh" ) )
TRY_LANG( "kl", QCoreApplication::translate( "Hunspell", "Kalaallisut" ) )
TRY_LANG( "km", QCoreApplication::translate( "Hunspell", "Khmer" ) )
TRY_LANG( "kn", QCoreApplication::translate( "Hunspell", "Kannada" ) )
TRY_LANG( "ko", QCoreApplication::translate( "Hunspell", "Korean" ) )
TRY_LANG( "kr", QCoreApplication::translate( "Hunspell", "Kanuri" ) )
TRY_LANG( "ks", QCoreApplication::translate( "Hunspell", "Kashmiri" ) )
TRY_LANG( "ku", QCoreApplication::translate( "Hunspell", "Kurdish" ) )
TRY_LANG( "kv", QCoreApplication::translate( "Hunspell", "Komi" ) )
TRY_LANG( "kw", QCoreApplication::translate( "Hunspell", "Cornish" ) )
TRY_LANG( "ky", QCoreApplication::translate( "Hunspell", "Kirghiz" ) )
TRY_LANG( "la", QCoreApplication::translate( "Hunspell", "Latin" ) )
TRY_LANG( "lb", QCoreApplication::translate( "Hunspell", "Luxembourgish" ) )
TRY_LANG( "lg", QCoreApplication::translate( "Hunspell", "Ganda" ) )
TRY_LANG( "li", QCoreApplication::translate( "Hunspell", "Limburgish" ) )
TRY_LANG( "ln", QCoreApplication::translate( "Hunspell", "Lingala" ) )
TRY_LANG( "lo", QCoreApplication::translate( "Hunspell", "Lao" ) )
TRY_LANG( "lt", QCoreApplication::translate( "Hunspell", "Lithuanian" ) )
TRY_LANG( "lu", QCoreApplication::translate( "Hunspell", "Luba-Katanga" ) )
TRY_LANG( "lv", QCoreApplication::translate( "Hunspell", "Latvian" ) )
TRY_LANG( "mg", QCoreApplication::translate( "Hunspell", "Malagasy" ) )
TRY_LANG( "mh", QCoreApplication::translate( "Hunspell", "Marshallese" ) )
TRY_LANG( "mi", QCoreApplication::translate( "Hunspell", "Maori" ) )
TRY_LANG( "mk", QCoreApplication::translate( "Hunspell", "Macedonian" ) )
TRY_LANG( "ml", QCoreApplication::translate( "Hunspell", "Malayalam" ) )
TRY_LANG( "mn", QCoreApplication::translate( "Hunspell", "Mongolian" ) )
TRY_LANG( "mr", QCoreApplication::translate( "Hunspell", "Marathi" ) )
TRY_LANG( "ms", QCoreApplication::translate( "Hunspell", "Malay" ) )
TRY_LANG( "mt", QCoreApplication::translate( "Hunspell", "Maltese" ) )
TRY_LANG( "my", QCoreApplication::translate( "Hunspell", "Burmese" ) )
TRY_LANG( "na", QCoreApplication::translate( "Hunspell", "Nauru" ) )
TRY_LANG( "nb", QCoreApplication::translate( "Hunspell", "Norwegian Bokmal" ) )
TRY_LANG( "nd", QCoreApplication::translate( "Hunspell", "North Ndebele" ) )
TRY_LANG( "ne", QCoreApplication::translate( "Hunspell", "Nepali" ) )
TRY_LANG( "ng", QCoreApplication::translate( "Hunspell", "Ndonga" ) )
TRY_LANG( "nl", QCoreApplication::translate( "Hunspell", "Dutch" ) )
TRY_LANG( "nn", QCoreApplication::translate( "Hunspell", "Norwegian Nynorsk" ) )
TRY_LANG( "no", QCoreApplication::translate( "Hunspell", "Norwegian" ) )
TRY_LANG( "nr", QCoreApplication::translate( "Hunspell", "South Ndebele" ) )
TRY_LANG( "nv", QCoreApplication::translate( "Hunspell", "Navajo" ) )
TRY_LANG( "ny", QCoreApplication::translate( "Hunspell", "Chichewa" ) )
// This looks really like a fake, and it is a fake - because
// the one very "intelligent" MSVC compiler does not understand if...else
// with more than 128 cases :(
#ifdef _MSC_VER
readableNameSucceeded = false;
if (readableNameSucceeded == false)
{
#endif
TRY_LANG( "oc", QCoreApplication::translate( "Hunspell", "Occitan" ) )
TRY_LANG( "oj", QCoreApplication::translate( "Hunspell", "Ojibwa" ) )
TRY_LANG( "om", QCoreApplication::translate( "Hunspell", "Oromo" ) )
TRY_LANG( "or", QCoreApplication::translate( "Hunspell", "Oriya" ) )
TRY_LANG( "os", QCoreApplication::translate( "Hunspell", "Ossetian" ) )
TRY_LANG( "pa", QCoreApplication::translate( "Hunspell", "Panjabi" ) )
TRY_LANG( "pi", QCoreApplication::translate( "Hunspell", "Pali" ) )
TRY_LANG( "pl", QCoreApplication::translate( "Hunspell", "Polish" ) )
TRY_LANG( "ps", QCoreApplication::translate( "Hunspell", "Pashto" ) )
TRY_LANG( "pt", QCoreApplication::translate( "Hunspell", "Portuguese" ) )
TRY_LANG( "qu", QCoreApplication::translate( "Hunspell", "Quechua" ) )
TRY_LANG( "rm", QCoreApplication::translate( "Hunspell", "Raeto-Romance" ) )
TRY_LANG( "rn", QCoreApplication::translate( "Hunspell", "Kirundi" ) )
TRY_LANG( "ro", QCoreApplication::translate( "Hunspell", "Romanian" ) )
TRY_LANG( "ru", QCoreApplication::translate( "Hunspell", "Russian" ) )
TRY_LANG( "rw", QCoreApplication::translate( "Hunspell", "Kinyarwanda" ) )
TRY_LANG( "sa", QCoreApplication::translate( "Hunspell", "Sanskrit" ) )
TRY_LANG( "sc", QCoreApplication::translate( "Hunspell", "Sardinian" ) )
TRY_LANG( "sd", QCoreApplication::translate( "Hunspell", "Sindhi" ) )
TRY_LANG( "se", QCoreApplication::translate( "Hunspell", "Northern Sami" ) )
TRY_LANG( "sg", QCoreApplication::translate( "Hunspell", "Sango" ) )
TRY_LANG( "sh", QCoreApplication::translate( "Hunspell", "Serbo-Croatian" ) )
TRY_LANG( "si", QCoreApplication::translate( "Hunspell", "Sinhala" ) )
TRY_LANG( "sk", QCoreApplication::translate( "Hunspell", "Slovak" ) )
TRY_LANG( "sl", QCoreApplication::translate( "Hunspell", "Slovenian" ) )
TRY_LANG( "sm", QCoreApplication::translate( "Hunspell", "Samoan" ) )
TRY_LANG( "sn", QCoreApplication::translate( "Hunspell", "Shona" ) )
TRY_LANG( "so", QCoreApplication::translate( "Hunspell", "Somali" ) )
TRY_LANG( "sq", QCoreApplication::translate( "Hunspell", "Albanian" ) )
TRY_LANG( "sr", QCoreApplication::translate( "Hunspell", "Serbian" ) )
TRY_LANG( "ss", QCoreApplication::translate( "Hunspell", "Swati" ) )
TRY_LANG( "st", QCoreApplication::translate( "Hunspell", "Southern Sotho" ) )
TRY_LANG( "su", QCoreApplication::translate( "Hunspell", "Sundanese" ) )
TRY_LANG( "sv", QCoreApplication::translate( "Hunspell", "Swedish" ) )
TRY_LANG( "sw", QCoreApplication::translate( "Hunspell", "Swahili" ) )
TRY_LANG( "ta", QCoreApplication::translate( "Hunspell", "Tamil" ) )
TRY_LANG( "te", QCoreApplication::translate( "Hunspell", "Telugu" ) )
TRY_LANG( "tg", QCoreApplication::translate( "Hunspell", "Tajik" ) )
TRY_LANG( "th", QCoreApplication::translate( "Hunspell", "Thai" ) )
TRY_LANG( "ti", QCoreApplication::translate( "Hunspell", "Tigrinya" ) )
TRY_LANG( "tk", QCoreApplication::translate( "Hunspell", "Turkmen" ) )
TRY_LANG( "tl", QCoreApplication::translate( "Hunspell", "Tagalog" ) )
TRY_LANG( "tn", QCoreApplication::translate( "Hunspell", "Tswana" ) )
TRY_LANG( "to", QCoreApplication::translate( "Hunspell", "Tonga" ) )
TRY_LANG( "tr", QCoreApplication::translate( "Hunspell", "Turkish" ) )
TRY_LANG( "ts", QCoreApplication::translate( "Hunspell", "Tsonga" ) )
TRY_LANG( "tt", QCoreApplication::translate( "Hunspell", "Tatar" ) )
TRY_LANG( "tw", QCoreApplication::translate( "Hunspell", "Twi" ) )
TRY_LANG( "ty", QCoreApplication::translate( "Hunspell", "Tahitian" ) )
TRY_LANG( "ug", QCoreApplication::translate( "Hunspell", "Uighur" ) )
TRY_LANG( "uk", QCoreApplication::translate( "Hunspell", "Ukrainian" ) )
TRY_LANG( "ur", QCoreApplication::translate( "Hunspell", "Urdu" ) )
TRY_LANG( "uz", QCoreApplication::translate( "Hunspell", "Uzbek" ) )
TRY_LANG( "ve", QCoreApplication::translate( "Hunspell", "Venda" ) )
TRY_LANG( "vi", QCoreApplication::translate( "Hunspell", "Vietnamese" ) )
TRY_LANG( "vo", QCoreApplication::translate( "Hunspell", "Volapuk" ) )
TRY_LANG( "wa", QCoreApplication::translate( "Hunspell", "Walloon" ) )
TRY_LANG( "wo", QCoreApplication::translate( "Hunspell", "Wolof" ) )
TRY_LANG( "xh", QCoreApplication::translate( "Hunspell", "Xhosa" ) )
TRY_LANG( "yi", QCoreApplication::translate( "Hunspell", "Yiddish" ) )
TRY_LANG( "yo", QCoreApplication::translate( "Hunspell", "Yoruba" ) )
TRY_LANG( "za", QCoreApplication::translate( "Hunspell", "Zhuang" ) )
TRY_LANG( "zh", QCoreApplication::translate( "Hunspell", "Chinese" ) )
TRY_LANG( "zu", QCoreApplication::translate( "Hunspell", "Zulu" ) )
readableNameSucceeded = false; // This ends the last else, so it's conditional
#ifdef _MSC_VER
}
#endif
if ( readableNameSucceeded )
{ {
dictName = localizedName;
if ( dictId.size() > 2 && ( dictId[ 2 ] == '-' || dictId[ 2 ] == '_' ) && if ( dictId.size() > 2 && ( dictId[ 2 ] == '-' || dictId[ 2 ] == '_' ) &&
dictId.mid( 3 ).toLower() != dictBaseId ) dictId.mid( 3 ).toLower() != dictBaseId )
dictName += " (" + dictId.mid( 3 ) + ")"; dictName += " (" + dictId.mid( 3 ) + ")";

258
src/language.cc Normal file
View file

@ -0,0 +1,258 @@
#include "language.hh"
#include "langcoder.hh"
#include <map>
#include <QCoreApplication>
namespace Language {
namespace {
using std::map;
struct Db
{
static Db const & instance();
map< QString, QString > const & getIso2ToEnglish() const
{ return iso2ToEnglish; }
map< QString, QString > const & getIso2ToLocalized() const
{ return iso2ToLocalized; }
private:
map< QString, QString > iso2ToEnglish, iso2ToLocalized;
Db();
void addEntry( QString const & iso2, QString const & english,
QString const & localized );
};
Db const & Db::instance()
{
static Db v;
return v;
}
void Db::addEntry( QString const & iso2, QString const & english,
QString const & localized )
{
iso2ToEnglish[ iso2 ] = english;
iso2ToLocalized[ iso2 ] = localized;
}
Db::Db()
{
addEntry( "aa", "Afar", QCoreApplication::translate( "Language", "Afar" ) );
addEntry( "ab", "Abkhazian", QCoreApplication::translate( "Language", "Abkhazian" ) );
addEntry( "ae", "Avestan", QCoreApplication::translate( "Language", "Avestan" ) );
addEntry( "af", "Afrikaans", QCoreApplication::translate( "Language", "Afrikaans" ) );
addEntry( "ak", "Akan", QCoreApplication::translate( "Language", "Akan" ) );
addEntry( "am", "Amharic", QCoreApplication::translate( "Language", "Amharic" ) );
addEntry( "an", "Aragonese", QCoreApplication::translate( "Language", "Aragonese" ) );
addEntry( "ar", "Arabic", QCoreApplication::translate( "Language", "Arabic" ) );
addEntry( "as", "Assamese", QCoreApplication::translate( "Language", "Assamese" ) );
addEntry( "av", "Avaric", QCoreApplication::translate( "Language", "Avaric" ) );
addEntry( "ay", "Aymara", QCoreApplication::translate( "Language", "Aymara" ) );
addEntry( "az", "Azerbaijani", QCoreApplication::translate( "Language", "Azerbaijani" ) );
addEntry( "ba", "Bashkir", QCoreApplication::translate( "Language", "Bashkir" ) );
addEntry( "be", "Belarusian", QCoreApplication::translate( "Language", "Belarusian" ) );
addEntry( "bg", "Bulgarian", QCoreApplication::translate( "Language", "Bulgarian" ) );
addEntry( "bh", "Bihari", QCoreApplication::translate( "Language", "Bihari" ) );
addEntry( "bi", "Bislama", QCoreApplication::translate( "Language", "Bislama" ) );
addEntry( "bm", "Bambara", QCoreApplication::translate( "Language", "Bambara" ) );
addEntry( "bn", "Bengali", QCoreApplication::translate( "Language", "Bengali" ) );
addEntry( "bo", "Tibetan", QCoreApplication::translate( "Language", "Tibetan" ) );
addEntry( "br", "Breton", QCoreApplication::translate( "Language", "Breton" ) );
addEntry( "bs", "Bosnian", QCoreApplication::translate( "Language", "Bosnian" ) );
addEntry( "ca", "Catalan", QCoreApplication::translate( "Language", "Catalan" ) );
addEntry( "ce", "Chechen", QCoreApplication::translate( "Language", "Chechen" ) );
addEntry( "ch", "Chamorro", QCoreApplication::translate( "Language", "Chamorro" ) );
addEntry( "co", "Corsican", QCoreApplication::translate( "Language", "Corsican" ) );
addEntry( "cr", "Cree", QCoreApplication::translate( "Language", "Cree" ) );
addEntry( "cs", "Czech", QCoreApplication::translate( "Language", "Czech" ) );
addEntry( "cu", "Church Slavic", QCoreApplication::translate( "Language", "Church Slavic" ) );
addEntry( "cv", "Chuvash", QCoreApplication::translate( "Language", "Chuvash" ) );
addEntry( "cy", "Welsh", QCoreApplication::translate( "Language", "Welsh" ) );
addEntry( "da", "Danish", QCoreApplication::translate( "Language", "Danish" ) );
addEntry( "de", "German", QCoreApplication::translate( "Language", "German" ) );
addEntry( "dv", "Divehi", QCoreApplication::translate( "Language", "Divehi" ) );
addEntry( "dz", "Dzongkha", QCoreApplication::translate( "Language", "Dzongkha" ) );
addEntry( "ee", "Ewe", QCoreApplication::translate( "Language", "Ewe" ) );
addEntry( "el", "Greek", QCoreApplication::translate( "Language", "Greek" ) );
addEntry( "en", "English", QCoreApplication::translate( "Language", "English" ) );
addEntry( "eo", "Esperanto", QCoreApplication::translate( "Language", "Esperanto" ) );
addEntry( "es", "Spanish", QCoreApplication::translate( "Language", "Spanish" ) );
addEntry( "et", "Estonian", QCoreApplication::translate( "Language", "Estonian" ) );
addEntry( "eu", "Basque", QCoreApplication::translate( "Language", "Basque" ) );
addEntry( "fa", "Persian", QCoreApplication::translate( "Language", "Persian" ) );
addEntry( "ff", "Fulah", QCoreApplication::translate( "Language", "Fulah" ) );
addEntry( "fi", "Finnish", QCoreApplication::translate( "Language", "Finnish" ) );
addEntry( "fj", "Fijian", QCoreApplication::translate( "Language", "Fijian" ) );
addEntry( "fo", "Faroese", QCoreApplication::translate( "Language", "Faroese" ) );
addEntry( "fr", "French", QCoreApplication::translate( "Language", "French" ) );
addEntry( "fy", "Western Frisian", QCoreApplication::translate( "Language", "Western Frisian" ) );
addEntry( "ga", "Irish", QCoreApplication::translate( "Language", "Irish" ) );
addEntry( "gd", "Scottish Gaelic", QCoreApplication::translate( "Language", "Scottish Gaelic" ) );
addEntry( "gl", "Galician", QCoreApplication::translate( "Language", "Galician" ) );
addEntry( "gn", "Guarani", QCoreApplication::translate( "Language", "Guarani" ) );
addEntry( "gu", "Gujarati", QCoreApplication::translate( "Language", "Gujarati" ) );
addEntry( "gv", "Manx", QCoreApplication::translate( "Language", "Manx" ) );
addEntry( "ha", "Hausa", QCoreApplication::translate( "Language", "Hausa" ) );
addEntry( "he", "Hebrew", QCoreApplication::translate( "Language", "Hebrew" ) );
addEntry( "hi", "Hindi", QCoreApplication::translate( "Language", "Hindi" ) );
addEntry( "ho", "Hiri Motu", QCoreApplication::translate( "Language", "Hiri Motu" ) );
addEntry( "hr", "Croatian", QCoreApplication::translate( "Language", "Croatian" ) );
addEntry( "ht", "Haitian", QCoreApplication::translate( "Language", "Haitian" ) );
addEntry( "hu", "Hungarian", QCoreApplication::translate( "Language", "Hungarian" ) );
addEntry( "hy", "Armenian", QCoreApplication::translate( "Language", "Armenian" ) );
addEntry( "hz", "Herero", QCoreApplication::translate( "Language", "Herero" ) );
addEntry( "ia", "Interlingua", QCoreApplication::translate( "Language", "Interlingua" ) );
addEntry( "id", "Indonesian", QCoreApplication::translate( "Language", "Indonesian" ) );
addEntry( "ie", "Interlingue", QCoreApplication::translate( "Language", "Interlingue" ) );
addEntry( "ig", "Igbo", QCoreApplication::translate( "Language", "Igbo" ) );
addEntry( "ii", "Sichuan Yi", QCoreApplication::translate( "Language", "Sichuan Yi" ) );
addEntry( "ik", "Inupiaq", QCoreApplication::translate( "Language", "Inupiaq" ) );
addEntry( "io", "Ido", QCoreApplication::translate( "Language", "Ido" ) );
addEntry( "is", "Icelandic", QCoreApplication::translate( "Language", "Icelandic" ) );
addEntry( "it", "Italian", QCoreApplication::translate( "Language", "Italian" ) );
addEntry( "iu", "Inuktitut", QCoreApplication::translate( "Language", "Inuktitut" ) );
addEntry( "ja", "Japanese", QCoreApplication::translate( "Language", "Japanese" ) );
addEntry( "jv", "Javanese", QCoreApplication::translate( "Language", "Javanese" ) );
addEntry( "ka", "Georgian", QCoreApplication::translate( "Language", "Georgian" ) );
addEntry( "kg", "Kongo", QCoreApplication::translate( "Language", "Kongo" ) );
addEntry( "ki", "Kikuyu", QCoreApplication::translate( "Language", "Kikuyu" ) );
addEntry( "kj", "Kwanyama", QCoreApplication::translate( "Language", "Kwanyama" ) );
addEntry( "kk", "Kazakh", QCoreApplication::translate( "Language", "Kazakh" ) );
addEntry( "kl", "Kalaallisut", QCoreApplication::translate( "Language", "Kalaallisut" ) );
addEntry( "km", "Khmer", QCoreApplication::translate( "Language", "Khmer" ) );
addEntry( "kn", "Kannada", QCoreApplication::translate( "Language", "Kannada" ) );
addEntry( "ko", "Korean", QCoreApplication::translate( "Language", "Korean" ) );
addEntry( "kr", "Kanuri", QCoreApplication::translate( "Language", "Kanuri" ) );
addEntry( "ks", "Kashmiri", QCoreApplication::translate( "Language", "Kashmiri" ) );
addEntry( "ku", "Kurdish", QCoreApplication::translate( "Language", "Kurdish" ) );
addEntry( "kv", "Komi", QCoreApplication::translate( "Language", "Komi" ) );
addEntry( "kw", "Cornish", QCoreApplication::translate( "Language", "Cornish" ) );
addEntry( "ky", "Kirghiz", QCoreApplication::translate( "Language", "Kirghiz" ) );
addEntry( "la", "Latin", QCoreApplication::translate( "Language", "Latin" ) );
addEntry( "lb", "Luxembourgish", QCoreApplication::translate( "Language", "Luxembourgish" ) );
addEntry( "lg", "Ganda", QCoreApplication::translate( "Language", "Ganda" ) );
addEntry( "li", "Limburgish", QCoreApplication::translate( "Language", "Limburgish" ) );
addEntry( "ln", "Lingala", QCoreApplication::translate( "Language", "Lingala" ) );
addEntry( "lo", "Lao", QCoreApplication::translate( "Language", "Lao" ) );
addEntry( "lt", "Lithuanian", QCoreApplication::translate( "Language", "Lithuanian" ) );
addEntry( "lu", "Luba-Katanga", QCoreApplication::translate( "Language", "Luba-Katanga" ) );
addEntry( "lv", "Latvian", QCoreApplication::translate( "Language", "Latvian" ) );
addEntry( "mg", "Malagasy", QCoreApplication::translate( "Language", "Malagasy" ) );
addEntry( "mh", "Marshallese", QCoreApplication::translate( "Language", "Marshallese" ) );
addEntry( "mi", "Maori", QCoreApplication::translate( "Language", "Maori" ) );
addEntry( "mk", "Macedonian", QCoreApplication::translate( "Language", "Macedonian" ) );
addEntry( "ml", "Malayalam", QCoreApplication::translate( "Language", "Malayalam" ) );
addEntry( "mn", "Mongolian", QCoreApplication::translate( "Language", "Mongolian" ) );
addEntry( "mr", "Marathi", QCoreApplication::translate( "Language", "Marathi" ) );
addEntry( "ms", "Malay", QCoreApplication::translate( "Language", "Malay" ) );
addEntry( "mt", "Maltese", QCoreApplication::translate( "Language", "Maltese" ) );
addEntry( "my", "Burmese", QCoreApplication::translate( "Language", "Burmese" ) );
addEntry( "na", "Nauru", QCoreApplication::translate( "Language", "Nauru" ) );
addEntry( "nb", "Norwegian Bokmal", QCoreApplication::translate( "Language", "Norwegian Bokmal" ) );
addEntry( "nd", "North Ndebele", QCoreApplication::translate( "Language", "North Ndebele" ) );
addEntry( "ne", "Nepali", QCoreApplication::translate( "Language", "Nepali" ) );
addEntry( "ng", "Ndonga", QCoreApplication::translate( "Language", "Ndonga" ) );
addEntry( "nl", "Dutch", QCoreApplication::translate( "Language", "Dutch" ) );
addEntry( "nn", "Norwegian Nynorsk", QCoreApplication::translate( "Language", "Norwegian Nynorsk" ) );
addEntry( "no", "Norwegian", QCoreApplication::translate( "Language", "Norwegian" ) );
addEntry( "nr", "South Ndebele", QCoreApplication::translate( "Language", "South Ndebele" ) );
addEntry( "nv", "Navajo", QCoreApplication::translate( "Language", "Navajo" ) );
addEntry( "ny", "Chichewa", QCoreApplication::translate( "Language", "Chichewa" ) );
addEntry( "oc", "Occitan", QCoreApplication::translate( "Language", "Occitan" ) );
addEntry( "oj", "Ojibwa", QCoreApplication::translate( "Language", "Ojibwa" ) );
addEntry( "om", "Oromo", QCoreApplication::translate( "Language", "Oromo" ) );
addEntry( "or", "Oriya", QCoreApplication::translate( "Language", "Oriya" ) );
addEntry( "os", "Ossetian", QCoreApplication::translate( "Language", "Ossetian" ) );
addEntry( "pa", "Panjabi", QCoreApplication::translate( "Language", "Panjabi" ) );
addEntry( "pi", "Pali", QCoreApplication::translate( "Language", "Pali" ) );
addEntry( "pl", "Polish", QCoreApplication::translate( "Language", "Polish" ) );
addEntry( "ps", "Pashto", QCoreApplication::translate( "Language", "Pashto" ) );
addEntry( "pt", "Portuguese", QCoreApplication::translate( "Language", "Portuguese" ) );
addEntry( "qu", "Quechua", QCoreApplication::translate( "Language", "Quechua" ) );
addEntry( "rm", "Raeto-Romance", QCoreApplication::translate( "Language", "Raeto-Romance" ) );
addEntry( "rn", "Kirundi", QCoreApplication::translate( "Language", "Kirundi" ) );
addEntry( "ro", "Romanian", QCoreApplication::translate( "Language", "Romanian" ) );
addEntry( "ru", "Russian", QCoreApplication::translate( "Language", "Russian" ) );
addEntry( "rw", "Kinyarwanda", QCoreApplication::translate( "Language", "Kinyarwanda" ) );
addEntry( "sa", "Sanskrit", QCoreApplication::translate( "Language", "Sanskrit" ) );
addEntry( "sc", "Sardinian", QCoreApplication::translate( "Language", "Sardinian" ) );
addEntry( "sd", "Sindhi", QCoreApplication::translate( "Language", "Sindhi" ) );
addEntry( "se", "Northern Sami", QCoreApplication::translate( "Language", "Northern Sami" ) );
addEntry( "sg", "Sango", QCoreApplication::translate( "Language", "Sango" ) );
addEntry( "sh", "Serbo-Croatian", QCoreApplication::translate( "Language", "Serbo-Croatian" ) );
addEntry( "si", "Sinhala", QCoreApplication::translate( "Language", "Sinhala" ) );
addEntry( "sk", "Slovak", QCoreApplication::translate( "Language", "Slovak" ) );
addEntry( "sl", "Slovenian", QCoreApplication::translate( "Language", "Slovenian" ) );
addEntry( "sm", "Samoan", QCoreApplication::translate( "Language", "Samoan" ) );
addEntry( "sn", "Shona", QCoreApplication::translate( "Language", "Shona" ) );
addEntry( "so", "Somali", QCoreApplication::translate( "Language", "Somali" ) );
addEntry( "sq", "Albanian", QCoreApplication::translate( "Language", "Albanian" ) );
addEntry( "sr", "Serbian", QCoreApplication::translate( "Language", "Serbian" ) );
addEntry( "ss", "Swati", QCoreApplication::translate( "Language", "Swati" ) );
addEntry( "st", "Southern Sotho", QCoreApplication::translate( "Language", "Southern Sotho" ) );
addEntry( "su", "Sundanese", QCoreApplication::translate( "Language", "Sundanese" ) );
addEntry( "sv", "Swedish", QCoreApplication::translate( "Language", "Swedish" ) );
addEntry( "sw", "Swahili", QCoreApplication::translate( "Language", "Swahili" ) );
addEntry( "ta", "Tamil", QCoreApplication::translate( "Language", "Tamil" ) );
addEntry( "te", "Telugu", QCoreApplication::translate( "Language", "Telugu" ) );
addEntry( "tg", "Tajik", QCoreApplication::translate( "Language", "Tajik" ) );
addEntry( "th", "Thai", QCoreApplication::translate( "Language", "Thai" ) );
addEntry( "ti", "Tigrinya", QCoreApplication::translate( "Language", "Tigrinya" ) );
addEntry( "tk", "Turkmen", QCoreApplication::translate( "Language", "Turkmen" ) );
addEntry( "tl", "Tagalog", QCoreApplication::translate( "Language", "Tagalog" ) );
addEntry( "tn", "Tswana", QCoreApplication::translate( "Language", "Tswana" ) );
addEntry( "to", "Tonga", QCoreApplication::translate( "Language", "Tonga" ) );
addEntry( "tr", "Turkish", QCoreApplication::translate( "Language", "Turkish" ) );
addEntry( "ts", "Tsonga", QCoreApplication::translate( "Language", "Tsonga" ) );
addEntry( "tt", "Tatar", QCoreApplication::translate( "Language", "Tatar" ) );
addEntry( "tw", "Twi", QCoreApplication::translate( "Language", "Twi" ) );
addEntry( "ty", "Tahitian", QCoreApplication::translate( "Language", "Tahitian" ) );
addEntry( "ug", "Uighur", QCoreApplication::translate( "Language", "Uighur" ) );
addEntry( "uk", "Ukrainian", QCoreApplication::translate( "Language", "Ukrainian" ) );
addEntry( "ur", "Urdu", QCoreApplication::translate( "Language", "Urdu" ) );
addEntry( "uz", "Uzbek", QCoreApplication::translate( "Language", "Uzbek" ) );
addEntry( "ve", "Venda", QCoreApplication::translate( "Language", "Venda" ) );
addEntry( "vi", "Vietnamese", QCoreApplication::translate( "Language", "Vietnamese" ) );
addEntry( "vo", "Volapuk", QCoreApplication::translate( "Language", "Volapuk" ) );
addEntry( "wa", "Walloon", QCoreApplication::translate( "Language", "Walloon" ) );
addEntry( "wo", "Wolof", QCoreApplication::translate( "Language", "Wolof" ) );
addEntry( "xh", "Xhosa", QCoreApplication::translate( "Language", "Xhosa" ) );
addEntry( "yi", "Yiddish", QCoreApplication::translate( "Language", "Yiddish" ) );
addEntry( "yo", "Yoruba", QCoreApplication::translate( "Language", "Yoruba" ) );
addEntry( "za", "Zhuang", QCoreApplication::translate( "Language", "Zhuang" ) );
addEntry( "zh", "Chinese", QCoreApplication::translate( "Language", "Chinese" ) );
addEntry( "zu", "Zulu", QCoreApplication::translate( "Language", "Zulu" ) );
}
}
QString englishNameForId( Id id )
{
map< QString, QString >::const_iterator i =
Db::instance().getIso2ToEnglish().find( LangCoder::intToCode2( id ) );
if ( i == Db::instance().getIso2ToEnglish().end() )
return QString();
return i->second;
}
QString localizedNameForId( Id id )
{
map< QString, QString >::const_iterator i =
Db::instance().getIso2ToLocalized().find( LangCoder::intToCode2( id ) );
if ( i == Db::instance().getIso2ToLocalized().end() )
return QString();
return i->second;
}
}

37
src/language.hh Normal file
View file

@ -0,0 +1,37 @@
/* This file is (c) 2008-2009 Konstantin Isakov <ikm@users.berlios.de>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef __LANGUAGE_HH_INCLUDED__
#define __LANGUAGE_HH_INCLUDED__
#include <QString>
/// Language-specific stuff - codes, names, ids etc.
namespace Language {
/// This identifies any language uniquely within the program. It also has
/// two special meanings - Unknown and Any.
typedef quint32 Id;
enum
{
/// Value for Id which signifies that the language is unknown or unspecified.
Unknown = 0,
/// Value for Id which signifies that the language can be any, or all of them.
Any = 0xFFffFFff
};
/// Returns name in English for the given Id. If the Id is incorrect, or has
/// Unknown/Any values, returns empty string.
QString englishNameForId( Id );
/// Returns name for the given Id, translated to the current UI language.
/// If the Id is incorrect, or has Unknown/Any values, returns empty string.
QString localizedNameForId( Id );
// All other functions are to be used from LangCoder, which is supposed to
// be migrated here over time.
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,7 @@
#include "orderandprops.hh" #include "orderandprops.hh"
#include "instances.hh" #include "instances.hh"
#include "langcoder.hh" #include "langcoder.hh"
#include "language.hh"
OrderAndProps::OrderAndProps( QWidget * parent, OrderAndProps::OrderAndProps( QWidget * parent,
Config::Group const & dictionaryOrder, Config::Group const & dictionaryOrder,
@ -73,9 +74,9 @@ void OrderAndProps::disableDictionaryDescription()
} }
namespace { namespace {
QString makeLangText( quint32 langId ) QString makeLangText( Language::Id langId )
{ {
QString name = LangCoder::decode( langId ); QString name = Language::localizedNameForId( langId );
if ( name.isEmpty() ) if ( name.isEmpty() )
return name; return name;