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

Wolfgang Bauer noreply at phabricator.kde.org
Wed Jan 10 15:47:44 UTC 2018


wbauer created this revision.
wbauer added a reviewer: Frameworks.
wbauer added a project: Frameworks.
Restricted Application added a project: Build System.
Restricted Application added a subscriber: Build System.
wbauer requested review of this revision.

REVISION SUMMARY
  For locales like de_AT, the current code only looks in share/locale/de_AT/ and share/locale/de-AT/ for translation catalogs, but not in share/locale/de/ where they most likely are.
  That's because bcp47Name() returns "de-AT" for de_AT (though in the case of de_DE e.g. it does return "de").
  
  This patch instead tries to fall back to the general language by taking the part of the locale name before the first '_'.

TEST PLAN
  Rebuilt kwidgetsaddons with this change.
  Unset $LANGUAGE (if set) and set $LANG=de_AT.UTF-8 (or set $LANGUAGE=de_AT in the first place)
  Ran systemsettings5 and enter some module.
  
  Without this patch the Help/Default/Reset/Apply buttons are untranslated because the kwidgetsaddons translations are not loaded (according to strace or added debug output they are only looked up in share/locale/de_AT/ and share/locale/de-AT/, they are in share/locale/de/ on my system).
  With this patch the buttons are translated, the translations are now loaded from share/locale/de/ (after trying share/locale/de_AT/ and failing).
  
  Also ran "kdesu xxx". "Password:", "Remember password", "Cancel" were untranslated in the password dialog before, they are translated to german now.
  
  Tests that passed before still pass.
  The new/modified test passes now too, it fails with the original code.

REPOSITORY
  R240 Extra CMake Modules

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

AFFECTED FILES
  modules/ECMQmLoader.cpp.in
  tests/ECMPoQmToolsTest/check.cmake.in

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


More information about the Kde-frameworks-devel mailing list