D9793: Fall back to language name for translations lookup if locale name fails

Wolfgang Bauer noreply at phabricator.kde.org
Thu Jan 11 20:37:50 UTC 2018


wbauer added a comment.


  In https://phabricator.kde.org/D9793#189595, @safaalfulaij wrote:
  
  > > Why is this an issue?
  > >  There's no difference really in loading ar/LC_MESSAGES/xxx.qm and LC_MESSAGES/xxx_ar.qm (or something like that), i.e. you would have the same problem if all translations would be in the same folder.
  >
  > Well, we were to simplify this to one call of loadTranslation, but yes, not a big deal.
  
  
  No.
  
  The issue is that not every locale has a separate translation, so you need fallbacks. (e.g. de_AT -> de)
  But it could have one, so just using the general language in any case would be wrong too as you couldn't have different translations for the same general language. (think of British English vs. American English e.g., there is a separate en_GB translation for KDE Frameworks)
  That's unrelated to whether the translations are in separate folders or all in one though, the latter wouldn't change anything IMHO.
  
  >> The only relevant things I can see is that it replaces all occurences of '-' with '_' (which is necessary only because it gets the languages from QLocale::uiLanguages()), and that it doesn't cut off at the first '_', but creates entries cut off at every one. (i.e. "de_XX_YY" would yield "de_XX_YY", "de_XX" and "de" to try, IIUIC, while the current patch would only try "de_XX_YY" and "de")
  >> 
  >> I could do something similar, i.e. lookup translations in a while loop and cut off at the right-most '_' if a lookup fails until it succeeds.
  > 
  > Well, that would be great for an ideal world. We can live for now and check the locales that KDE is currently translated to, and just adapt to them.
  
  It only makes a difference if the locale/language is actually set to something like "ll_XX_YY" (i.e. more than one '_') though, and only if there actually is a "ll_XX" translation.
  
  But I will probably have a look at implementing that tomorrow...
  
  > Maybe later, I like full concept implementations, but yes, not needed.
  
  This is a bugfix for existing code though, not a new implementation. ;-)
  
  But it shouldn't be hard to add (even later), just call QLocale::uiLanguages() instead of QLocale::system() and loop over all strings in the list you get (after replacing '-' with '_').
  The rest of the code is still needed (unchanged) and would be inside that loop.

REPOSITORY
  R240 Extra CMake Modules

REVISION DETAIL
  https://phabricator.kde.org/D9793

To: wbauer, #frameworks
Cc: safaalfulaij, #build_system
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180111/df5b9e89/attachment.html>


More information about the Kde-frameworks-devel mailing list