From af098e4805b83dd2f0b569438f9118c16b47b5f6 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Mon, 25 Apr 2016 18:14:42 +0200 Subject: [PATCH] Locale for non-QT UI strings Some parts of strings did not use the proper locale. For example, date and time strings was always output with the US locale. This fixes it. There are still some cases where localisation is not implemented, and could be changed from str(string) to locale.str(string). --- src/bitmessageqt/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index cb3b5e75..cac530fc 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -44,6 +44,7 @@ from about import * from help import * from iconglossary import * from connect import * +import locale as pythonlocale import sys from time import strftime, localtime, gmtime import time @@ -99,6 +100,17 @@ def change_translation(locale): qsystranslator.load(translationpath) QtGui.QApplication.installTranslator(qsystranslator) + lang = l10n.getTranslationLanguage() + if "_" not in lang: + lang += "_" + lang.upper() + if ".utf8" not in lang.lower(): + lang += ".utf8" + try: + pythonlocale.setlocale(pythonlocale.LC_ALL, lang) + except: + logger.error("Failed to set locale to %s", lang) + pass + class MyForm(settingsmixin.SMainWindow): # sound type constants