When I set the current language to Arabic in my UI, just for testing purposes, I see that some English strings (displayed in a language selection dialog, if you're wondering why) are rendered in a way I'm not sure will be appropriate. With the non-Arabic translations, for example, a string that would display as "English (United Kingdom)" will be rendered as "(English (United Kingdom" when the Arabic translator is loaded.
Does anyone know an appropriate way to handle this?
These strings are added to a QComboBox by asking a QTranslator for the translation of the word "English" (something I've used as a hook for finding the name of the language provided by the translation (just as the 'i18n' example did)):
Translator test;
QStringList translations
= test.
availableTranslations();
foreach (translation, translations) {
// Remove .qm suffix
translation.chop(3);
test.load(translation);
languageCombo->addItem(test.languageName(), translation);
}
Client* client = Client::instance();
languageCombo->setCurrentIndex(
languageCombo->findText(client->translator()->languageName()));
QComboBox* languageCombo = new QComboBox(this);
Translator test;
QStringList translations = test.availableTranslations();
QString translation;
foreach (translation, translations) {
// Remove .qm suffix
translation.chop(3);
test.load(translation);
languageCombo->addItem(test.languageName(), translation);
}
Client* client = Client::instance();
languageCombo->setCurrentIndex(
languageCombo->findText(client->translator()->languageName()));
To copy to clipboard, switch view to plain text mode
Where languageName() just has:
return translate("Translator", SourceLanguage, 0, -1);
return translate("Translator", SourceLanguage, 0, -1);
To copy to clipboard, switch view to plain text mode
Where SourceLanguage is just
static const char* SourceLanguage = QT_TRANSLATE_NOOP("Translator", "English");
static const char* SourceLanguage = QT_TRANSLATE_NOOP("Translator", "English");
To copy to clipboard, switch view to plain text mode
Any insights much appreciated.
Bookmarks