Exemplo n.º 1
0
 def get_locale(self):
     for locale_code, langname in LANGUAGENAMES.items():
         if langname == self.get_uh_setting('Language'):
             return locale_code
     # TODO : better way to find 'System default' ?
     default_locale, default_encoding = locale.getdefaultlocale()
     return default_locale.split('_')[0]
Exemplo n.º 2
0
	def get_locale(self):
		for locale_code, langname in LANGUAGENAMES.items():
			if langname == self.get_uh_setting('Language'):
				return locale_code
		# TODO : better way to find 'System default' ?
		default_locale, default_encoding = locale.getdefaultlocale()
		return default_locale.split('_')[0]
Exemplo n.º 3
0
	def get_locale(self):
		for locale_code, langname in LANGUAGENAMES.items():
			if langname == self.get_uh_setting('Language'):
				return locale_code
		default_locale, default_encoding = locale.getdefaultlocale()
		try:
			return default_locale.split('_')[0]
		except:
			# If default locale could not be detected use 'EN' as fallback
			return "en"
Exemplo n.º 4
0
	def get_locale(self):
		for locale_code, langname in LANGUAGENAMES.items():
			if langname == self.get_uh_setting('Language'):
				if not langname == 'System default':
					return locale_code
		try:
			default_locale, default_encoding = locale.getdefaultlocale()
			return default_locale.split('_')[0]
		except ValueError: # OS X sometimes returns 'UTF-8' as locale, which is a ValueError
			# If default locale could not be detected use 'EN' as fallback
			return "en"
Exemplo n.º 5
0
	def get_locale(self):
		for locale_code, langname in LANGUAGENAMES.items():
			if langname == self.get_uh_setting('Language'):
				if not langname == 'System default':
					return locale_code
		try:
			default_locale, default_encoding = locale.getdefaultlocale()
			return default_locale.split('_')[0]
		except (ValueError, AttributeError):
			# OS X sometimes returns 'UTF-8' as locale, which is a ValueError.
			# If no locale is set at all, the split will fail, which is an AttributeError.
			# Use 'EN' as fallback in both cases since we cannot reasonably detect the locale.
			return "en"
Exemplo n.º 6
0
 def get_locale(self):
     for locale_code, langname in LANGUAGENAMES.items():
         if langname == self.get_uh_setting('Language'):
             if not langname == 'System default':
                 return locale_code
     try:
         default_locale, default_encoding = locale.getdefaultlocale()
         return default_locale.split('_')[0]
     except (ValueError, AttributeError):
         # OS X sometimes returns 'UTF-8' as locale, which is a ValueError.
         # If no locale is set at all, the split will fail, which is an AttributeError.
         # Use 'EN' as fallback in both cases since we cannot reasonably detect the locale.
         return "en"