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 locale(value): """ Returns a a string with information about a QLocale. @param value QLocale @returns str: Formatted as 'language, country' """ return '{}, {}'.format(QLocale.languageToString(value.language()), QLocale.countryToString(value.country()))
def generateDict(verbose=False): # As per the Qt4.7 documentation the QLocale.Language enumeration # ranges from 1 to 214: # http://doc.trolltech.com/4.7/qlocale.html#Language-enum lines = ['locales = {\n'] for l in xrange(1, 214): lang = QLocale.languageToString(l) for c in QLocale.countriesForLanguage(l): code = QLocale(l, c).name() country = QLocale.countryToString(c) if verbose: print code, lang, country line = " '{0}' : ['{1}', '{2}'],\n" lines.append(line.format(code, lang, country)) lines.append('}\n\n') return lines
def generateDict(verbose=False): # As per the Qt4.7 documentation the QLocale.Language enumeration # ranges from 1 to 214: # http://doc.trolltech.com/4.7/qlocale.html#Language-enum lines = ['locales = {\n'] for l in xrange(1, 214): lang = QLocale.languageToString(l) for c in QLocale.countriesForLanguage(l): code = QLocale(l, c).name() country = QLocale.countryToString(c) if verbose: print code, lang, country line = " '{0}' : ['{1}', '{2}'],\n" lines.append(line.format(code, lang, country)) lines.append('}\n\n') return lines