def testLocales(self): zh_hk = QLocale(QLocale.Chinese, QLocale.HongKong) en_us = QLocale(QLocale.English, QLocale.UnitedStates) self.assertEquals(QLocale.Chinese, zh_hk.language()) self.assertEquals(QLocale.HongKong, zh_hk.country()) self.assertEquals(QLocale.English, en_us.language()) self.assertEquals(QLocale.UnitedStates, en_us.country()) appLangs = {} appLangs[zh_hk] = "zh_hk" self.assertEquals(appLangs[zh_hk], "zh_hk")
def __buildLanguageDictionary(self): """Builds the language dictionary used by the application. The dictionary is constructed with the locale code as key, and a list containing the language name (and possibly the country name) as value. The information is based on the ``i18n``entries in the ``resources.py`` module, where the alias for a one translation file is locale code for the translation. If the translation file is named ``luma_nn_NO.ts`` the corresponding alias for this file will be ``nb_NO``. Further more ``nb`` will map to ``QLocale.NorwegianBokmal``and ``NO`` will map to ``QLocale.Norway``, resulting in the following entry in the dictionary:: langDict = { ..., 'en' : ['English'], # Default is allways included 'nb_NO' : ['Norwegian', 'Norway'], ... } """ for i18n in self.__translationPath: if i18n == 'hx': self.__availableLanguages[i18n] = ['leet', '10100111001'] else: locale = QLocale(i18n) language = QLocale.languageToString(locale.language()) country = QLocale.countryToString(locale.country()) self.__availableLanguages[i18n] = [language, country]
def __buildLanguageDictionary(self): """Builds the language dictionary used by the application. The dictionary is constructed with the locale code as key, and a list containing the language name (and possibly the country name) as value. The information is based on the ``i18n``entries in the ``resources.py`` module, where the alias for a one translation file is locale code for the translation. If the translation file is named ``luma_nn_NO.ts`` the corresponding alias for this file will be ``nb_NO``. Further more ``nb`` will map to ``QLocale.NorwegianBokmal``and ``NO`` will map to ``QLocale.Norway``, resulting in the following entry in the dictionary:: langDict = { ..., 'en' : ['English'], # Default is allways included 'nb_NO' : ['Norwegian', 'Norway'], ... } """ for i18n in self.__translationPath: if i18n == "hx": self.__availableLanguages[i18n] = ["leet", "10100111001"] else: locale = QLocale(i18n) language = QLocale.languageToString(locale.language()) country = QLocale.countryToString(locale.country()) self.__availableLanguages[i18n] = [language, country]
def getLanguage(self): locale_app = QLocale() locale_os = QLocale.system() info = [] var = QLocale.languageToString(locale_app.language()) return var