mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed to get work again Chinese language , and load now Qt translations for widgets
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2520 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5e0c8e062e
commit
42184efe70
@ -437,7 +437,7 @@ TRANSLATIONS += \
|
||||
lang/retroshare_af.ts \
|
||||
lang/retroshare_gr.ts \
|
||||
lang/retroshare_it.ts \
|
||||
lang/retroshare_ja.ts \
|
||||
lang/retroshare_ja_JP.ts \
|
||||
lang/retroshare_ko.ts \
|
||||
lang/retroshare_pl.ts \
|
||||
lang/retroshare_pt.ts \
|
||||
|
@ -161,7 +161,7 @@
|
||||
<file>images/flags/fr.png</file>
|
||||
<file>images/flags/gr.png</file>
|
||||
<file>images/flags/it.png</file>
|
||||
<file>images/flags/ja.png</file>
|
||||
<file>images/flags/ja_JP.png</file>
|
||||
<file>images/flags/ko.png</file>
|
||||
<file>images/flags/pl.png</file>
|
||||
<file>images/flags/pt.png</file>
|
||||
|
BIN
retroshare-gui/src/gui/images/flags/ja_JP.png
Normal file
BIN
retroshare-gui/src/gui/images/flags/ja_JP.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 669 B |
@ -1,27 +1,27 @@
|
||||
<RCC>
|
||||
<qresource prefix="/lang">
|
||||
<file alias="af">retroshare_af.qm</file>
|
||||
<file alias="bg">retroshare_bg.qm</file>
|
||||
<file alias="en">retroshare_en.qm</file>
|
||||
<file alias="da">retroshare_da.qm</file>
|
||||
<file alias="de">retroshare_de.qm</file>
|
||||
<file alias="es">retroshare_es.qm</file>
|
||||
<file alias="fi">retroshare_fi.qm</file>
|
||||
<file alias="fr">retroshare_fr.qm</file>
|
||||
<file alias="cy">retroshare_cy.qm</file>
|
||||
<file alias="gr">retroshare_gr.qm</file>
|
||||
<file alias="it">retroshare_it.qm</file>
|
||||
<file alias="ja">retroshare_ja.qm</file>
|
||||
<file alias="ko">retroshare_ko.qm</file>
|
||||
<file alias="pl">retroshare_pl.qm</file>
|
||||
<file alias="pt">retroshare_pt.qm</file>
|
||||
<file alias="ru">retroshare_ru.qm</file>
|
||||
<file alias="tr">retroshare_tr.qm</file>
|
||||
<file alias="sl">retroshare_sl.qm</file>
|
||||
<file alias="sr">retroshare_sr.qm</file>
|
||||
<file alias="sv">retroshare_sv.qm</file>
|
||||
<file alias="zh_CN">retroshare_zh_CN.qm</file>
|
||||
<file alias="zh_TW">retroshare_zh_TW.qm</file>
|
||||
<file>retroshare_af.qm</file>
|
||||
<file>retroshare_bg.qm</file>
|
||||
<file>retroshare_en.qm</file>
|
||||
<file>retroshare_da.qm</file>
|
||||
<file>retroshare_de.qm</file>
|
||||
<file>retroshare_es.qm</file>
|
||||
<file>retroshare_fi.qm</file>
|
||||
<file>retroshare_fr.qm</file>
|
||||
<file>retroshare_cy.qm</file>
|
||||
<file>retroshare_gr.qm</file>
|
||||
<file>retroshare_it.qm</file>
|
||||
<file>retroshare_ja_JP.qm</file>
|
||||
<file>retroshare_ko.qm</file>
|
||||
<file>retroshare_pl.qm</file>
|
||||
<file>retroshare_pt.qm</file>
|
||||
<file>retroshare_ru.qm</file>
|
||||
<file>retroshare_tr.qm</file>
|
||||
<file>retroshare_sl.qm</file>
|
||||
<file>retroshare_sr.qm</file>
|
||||
<file>retroshare_sv.qm</file>
|
||||
<file>retroshare_zh_CN.qm</file>
|
||||
<file>retroshare_zh_TW.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
|
@ -20,43 +20,44 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include <QLibraryInfo>
|
||||
#include <rshare.h>
|
||||
|
||||
#include "languagesupport.h"
|
||||
|
||||
/** Static list of supported languages and codes. */
|
||||
QMap<QString, QString> LanguageSupport::_languages;
|
||||
|
||||
/** Initializes the list of available languages. */
|
||||
void
|
||||
LanguageSupport::initialize()
|
||||
QMap<QString, QString>
|
||||
LanguageSupport::languages()
|
||||
{
|
||||
_languages.clear();
|
||||
_languages.insert("af", "Afrikaans");
|
||||
_languages.insert("bg", "Bulgarien");
|
||||
_languages.insert("cy", "Welsh");
|
||||
_languages.insert("de", "Deutsch");
|
||||
_languages.insert("da", "Danish");
|
||||
_languages.insert("en", "English");
|
||||
_languages.insert("es", QString::fromUtf8("spanish"));
|
||||
_languages.insert("fr", QString::fromUtf8("Fran\303\247ais"));
|
||||
_languages.insert("fi", "suomi");
|
||||
_languages.insert("gr", "Greek");
|
||||
_languages.insert("it", "Italiano");
|
||||
_languages.insert("ja", QString::fromUtf8("\346\227\245\346\234\254\350\252\236"));
|
||||
_languages.insert("ko", "Korean");
|
||||
_languages.insert("pl", "Polish");
|
||||
_languages.insert("pt", "Portuguese");
|
||||
_languages.insert("ru", QString::fromUtf8("\320\240\321\203\321\201\321\201\320\272\320\270\320\271"));
|
||||
_languages.insert("sl", "slovenian");
|
||||
_languages.insert("sr", "Serbian");
|
||||
_languages.insert("sv", "svenska");
|
||||
_languages.insert("tr", QString::fromUtf8("T\303\274rk\303\247e"));
|
||||
_languages.insert("zh_CN", QString::fromUtf8("\347\256\200\344\275\223\345\255\227"));
|
||||
_languages.insert("zh_TW", QString::fromUtf8("\347\260\241\351\253\224\345\255\227"));
|
||||
|
||||
static QMap<QString, QString> languages;
|
||||
if (languages.isEmpty()) {
|
||||
languages.insert("af", "Afrikaans");
|
||||
languages.insert("bg", "Bulgarien");
|
||||
languages.insert("cy", "Welsh");
|
||||
languages.insert("de", "Deutsch");
|
||||
languages.insert("da", "Danish");
|
||||
languages.insert("en", "English");
|
||||
languages.insert("es", QString::fromUtf8("spanish"));
|
||||
languages.insert("fr", QString::fromUtf8("Fran\303\247ais"));
|
||||
languages.insert("fi", "suomi");
|
||||
languages.insert("gr", "Greek");
|
||||
languages.insert("it", "Italiano");
|
||||
languages.insert("ja_JP", QString::fromUtf8("\346\227\245\346\234\254\350\252\236"));
|
||||
languages.insert("ko", "Korean");
|
||||
languages.insert("pl", "Polish");
|
||||
languages.insert("pt", "Portuguese");
|
||||
languages.insert("ru", QString::fromUtf8("\320\240\321\203\321\201\321\201\320\272\320\270\320\271"));
|
||||
languages.insert("sl", "slovenian");
|
||||
languages.insert("sr", "Serbian");
|
||||
languages.insert("sv", "svenska");
|
||||
languages.insert("tr", QString::fromUtf8("T\303\274rk\303\247e"));
|
||||
languages.insert("zh_CN", QString::fromUtf8("\347\256\200\344\275\223\345\255\227"));
|
||||
languages.insert("zh_TW", QString::fromUtf8("\347\260\241\351\253\224\345\255\227"));
|
||||
}
|
||||
return languages;
|
||||
}
|
||||
|
||||
/** Returns the default language code for the system locale. */
|
||||
@ -75,58 +76,76 @@ LanguageSupport::defaultLanguageCode()
|
||||
|
||||
/** Returns the language code for a given language name. */
|
||||
QString
|
||||
LanguageSupport::languageCode(QString languageName)
|
||||
LanguageSupport::languageCode(const QString &languageName)
|
||||
{
|
||||
return _languages.key(languageName);
|
||||
return languages().key(languageName);
|
||||
}
|
||||
|
||||
/** Returns a list of all supported language codes. (e.g., "en"). */
|
||||
QStringList
|
||||
LanguageSupport::languageCodes()
|
||||
{
|
||||
return _languages.keys();
|
||||
return languages().keys();
|
||||
}
|
||||
|
||||
/** Returns the language name for a given language code. */
|
||||
QString
|
||||
LanguageSupport::languageName(QString languageCode)
|
||||
LanguageSupport::languageName(const QString &languageCode)
|
||||
{
|
||||
return _languages.value(languageCode);
|
||||
return languages().value(languageCode);
|
||||
}
|
||||
|
||||
/** Returns a list of all supported language names (e.g., "English"). */
|
||||
QStringList
|
||||
LanguageSupport::languageNames()
|
||||
{
|
||||
return _languages.values();
|
||||
}
|
||||
|
||||
/** Returns a list of all supported language codes and names. */
|
||||
QMap<QString, QString>
|
||||
LanguageSupport::languages()
|
||||
{
|
||||
return _languages;
|
||||
return languages().values();
|
||||
}
|
||||
|
||||
/** Returns true if we understand the given language code. */
|
||||
bool
|
||||
LanguageSupport::isValidLanguageCode(QString code)
|
||||
LanguageSupport::isValidLanguageCode(const QString &languageCode)
|
||||
{
|
||||
return languageCodes().contains(code.toLower());
|
||||
return languageCodes().contains(languageCode);
|
||||
}
|
||||
|
||||
/** Returns true if <b>languageCode</b> requires a right-to-left layout. */
|
||||
bool
|
||||
LanguageSupport::isRightToLeft(const QString &languageCode)
|
||||
{
|
||||
return (!languageCode.compare("ar", Qt::CaseInsensitive)
|
||||
|| !languageCode.compare("fa", Qt::CaseInsensitive)
|
||||
|| !languageCode.compare("he", Qt::CaseInsensitive));
|
||||
}
|
||||
/** Sets the application's translator to the specified language. */
|
||||
bool
|
||||
LanguageSupport::translate(QString langCode)
|
||||
LanguageSupport::translate(const QString &languageCode)
|
||||
{
|
||||
if (isValidLanguageCode(langCode)) {
|
||||
QTranslator *translator = new QTranslator();
|
||||
if (translator->load(QString(":/lang/") + langCode.toLower())) {
|
||||
QApplication::installTranslator(translator);
|
||||
return true;
|
||||
}
|
||||
delete translator;
|
||||
if (!isValidLanguageCode(languageCode))
|
||||
return false;
|
||||
if (languageCode == "en")
|
||||
return true;
|
||||
|
||||
/* Attempt to load the translations for Qt's internal widgets from their
|
||||
* installed Qt directory. */
|
||||
QTranslator *systemQtTranslator = new QTranslator(rApp);
|
||||
Q_CHECK_PTR(systemQtTranslator);
|
||||
|
||||
QString qtDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
||||
if (systemQtTranslator->load(qtDir + "/qt_" + languageCode + ".qm"))
|
||||
QApplication::installTranslator(systemQtTranslator);
|
||||
else
|
||||
delete systemQtTranslator;
|
||||
|
||||
/* Install a translator for RetroShare's UI widgets */
|
||||
QTranslator *retroshareTranslator = new QTranslator(rApp);
|
||||
Q_CHECK_PTR(retroshareTranslator);
|
||||
|
||||
if (retroshareTranslator->load(":/lang/retroshare_" + languageCode + ".qm")) {
|
||||
QApplication::installTranslator(retroshareTranslator);
|
||||
return true;
|
||||
}
|
||||
delete retroshareTranslator;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2006-2007, crypton
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2006-2007, crypton
|
||||
* Copyright (c) 2006, Matt Edman, Justin Hipple
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@ -30,30 +30,28 @@
|
||||
#include <QMap>
|
||||
|
||||
|
||||
|
||||
class LanguageSupport
|
||||
{
|
||||
public:
|
||||
/** Initializes the list of supported languages. */
|
||||
static void initialize();
|
||||
/** Returns the default language code for the system locale. */
|
||||
static QString defaultLanguageCode();
|
||||
/** Returns the language code for a given language name. */
|
||||
static QString languageCode(QString languageName);
|
||||
static QString languageCode(const QString &languageName);
|
||||
/** Returns a list of all supported language codes (e.g., "en"). */
|
||||
static QStringList languageCodes();
|
||||
/** Returns the language name for a given language code. */
|
||||
static QString languageName(QString languageCode);
|
||||
static QString languageName(const QString &languageCode);
|
||||
/** Returns a list of all supported language names (e.g., "English"). */
|
||||
static QStringList languageNames();
|
||||
/** Returns a list of all supported language codes and names. */
|
||||
static QMap<QString, QString> languages();
|
||||
/** Returns true if we understand the given language code. */
|
||||
static bool isValidLanguageCode(QString code);
|
||||
static bool isValidLanguageCode(const QString &languageCode);
|
||||
/** Returns true if <b>languageCode</b> requires a right-to-left layout. */
|
||||
static bool isRightToLeft(const QString &languageCode);
|
||||
/** Sets the application's translator to the specified language. */
|
||||
static bool translate(QString langCode);
|
||||
|
||||
private:
|
||||
static QMap<QString,QString> _languages; /**< List of support languages. */
|
||||
static bool translate(const QString &languageCode);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
BIN
retroshare-gui/src/lang/retroshare_ja_JP.qm
Normal file
BIN
retroshare-gui/src/lang/retroshare_ja_JP.qm
Normal file
Binary file not shown.
11133
retroshare-gui/src/lang/retroshare_ja_JP.ts
Normal file
11133
retroshare-gui/src/lang/retroshare_ja_JP.ts
Normal file
File diff suppressed because one or more lines are too long
@ -121,7 +121,7 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, QString dir)
|
||||
}
|
||||
|
||||
/** Initialize support for language translations. */
|
||||
LanguageSupport::initialize();
|
||||
//LanguageSupport::initialize();
|
||||
|
||||
/** Translate the GUI to the appropriate language. */
|
||||
setLanguage(_args.value(ARG_LANGUAGE));
|
||||
|
Loading…
Reference in New Issue
Block a user