nativeLanguageName is too verbose
-
Hi,
I am currently trying to implement a list of languages that the user can choose when they want to change the localization of our program.The QLocales are created using the available .qm filenames, which works perfectly fine.
The problem I'm having is that the nativeLanguageString of some QLocales can end up really ugly, when used in combination with the native country name.
QLocale locale = QLocale("en"); myString = locale.nativeLanguageName() + " (" + locale.nativeCountryName() + ")";
I would expect to see something like "English (United States)"
But instead the result is "American English (United States)"I already found out that
QLocale::languageToString(locale)
will return "English", which apparently is hardcoded as english string in the Qt souce code.So my main question is:
Is there a way to make this look better in its native language?
Or what is the commonly recommended way to show language selections to the user?Best regards,
Megamouse -
Hi,
I am currently trying to implement a list of languages that the user can choose when they want to change the localization of our program.The QLocales are created using the available .qm filenames, which works perfectly fine.
The problem I'm having is that the nativeLanguageString of some QLocales can end up really ugly, when used in combination with the native country name.
QLocale locale = QLocale("en"); myString = locale.nativeLanguageName() + " (" + locale.nativeCountryName() + ")";
I would expect to see something like "English (United States)"
But instead the result is "American English (United States)"I already found out that
QLocale::languageToString(locale)
will return "English", which apparently is hardcoded as english string in the Qt souce code.So my main question is:
Is there a way to make this look better in its native language?
Or what is the commonly recommended way to show language selections to the user?Best regards,
Megamouse@Megamouse said in nativeLanguageName is too verbose:
nativeLanguageName()
From the method source code, it looks the "ugly" name comes from the system locale (based on underlying OS) if Qt was configured to use system locale, or from a built-in table if not.
See that the method comment already make you aware of the possible return values:
Returns a native name of the language for the locale. For example
"Schwiizertüütsch" for Swiss-German locale.
-
Hi,
I am currently trying to implement a list of languages that the user can choose when they want to change the localization of our program.The QLocales are created using the available .qm filenames, which works perfectly fine.
The problem I'm having is that the nativeLanguageString of some QLocales can end up really ugly, when used in combination with the native country name.
QLocale locale = QLocale("en"); myString = locale.nativeLanguageName() + " (" + locale.nativeCountryName() + ")";
I would expect to see something like "English (United States)"
But instead the result is "American English (United States)"I already found out that
QLocale::languageToString(locale)
will return "English", which apparently is hardcoded as english string in the Qt souce code.So my main question is:
Is there a way to make this look better in its native language?
Or what is the commonly recommended way to show language selections to the user?Best regards,
Megamouse@Megamouse said in nativeLanguageName is too verbose:
Or what is the commonly recommended way to show language selections to the user?
If the list of possible languages to select from is "short", which should be the case since you're are already creating locales using the available .qm filenames you could use a QMap<QLocale, QString> structure for instance and provide the whatever fancy name you want for a particular locale.
-
@Pablo-J-Rogina I'm not adding the files.
It's an open source software, so anyone can add their own language to their local build. But we don't ship translations ourselves.That's why a map is not feasible, unless someone has a map of language code to all the language names in their native tongue (ideally plus optional country).
I'm tempted to simply go with the "ugly" verbose solution and hope that someone who gets triggered enough fixes it elegantly in the future.
-
@Pablo-J-Rogina I'm not adding the files.
It's an open source software, so anyone can add their own language to their local build. But we don't ship translations ourselves.That's why a map is not feasible, unless someone has a map of language code to all the language names in their native tongue (ideally plus optional country).
I'm tempted to simply go with the "ugly" verbose solution and hope that someone who gets triggered enough fixes it elegantly in the future.
@Megamouse said in nativeLanguageName is too verbose:
That's why a map is not feasible, unless someone has a map of language code to all the language names
Taking a second look at the "requirements", you could add one string in your open source code that's the "nativeLanguageName" and so, everyone adding a new language will have that string to translate in the set of strings to translate. So whenever a language file is loaded, the "nice" native language name is already there...