Did I find the right examples for you? yes no Crawl my project Python Jobs
All Samples(258) | Call(258) | Derive(0) | Import(0)
Create a `Locale` instance for the given locale identifier. >>> l = Locale.parse('de-DE', sep='-') >>> l.display_name u'Deutsch (Deutschland)' If the `identifier` parameter is not a string, but actually a `Locale` object, that object is returned: >>> Locale.parse(l) Locale('de', territory='DE') This also can perform resolving of likely subtags which it does by default. This is for instance useful to figure out the most likely locale for a territory you can use ``'und'`` as the language tag: >>> Locale.parse('und_AT') Locale('de', territory='AT') :param identifier: the locale identifier string :param sep: optional component separator :param resolve_likely_subtags: if this is specified then a locale will have its likely subtag resolved if the locale otherwise does not exist. For instance ``zh_TW`` by itself is not a locale that exists but Babel can automatically expand it to the full form of ``zh_hant_TW``. Note that this expansion is only taking place if no locale exists otherwise. For instance there is a locale ``en`` that can exist by itself. :raise `ValueError`: if the string does not appear to be a valid locale identifier :raise `UnknownLocaleError`: if no locale data is available for the requested locale
src/t/r/Tribus-0.1.dev20131207073801/tribus/common/setup/maint.py Tribus(Download)
def get_locale_list(self): django_locales = set([i[0].replace('_', '-').lower() for i in settings.LANGUAGES]) babel_locales = set([j.replace('_', '-').lower() for j in locale_identifiers()]) sphinx_locales = set([k.replace('_', '-').lower() for k in chm_locales.keys()]) locales = [str(Locale.parse(identifier=l, sep='-')) for l in django_locales & babel_locales & sphinx_locales]
src/p/l/Plurk_Solace-0.1/solace/i18n/__init__.py Plurk_Solace(Download)
""" try: key = str(Locale.parse(locale)) except UnknownLocaleError: return None
for locale, quality in choices: try: locale = Locale.parse(locale, sep='-') except UnknownLocaleError: continue if str(locale) in enabled and \ find_catalog(locale) is not None: return locale return Locale.parse(settings.DEFAULT_LANGUAGE)
def load_translations(locale): """Return the translations for the locale.""" locale = Locale.parse(locale) key = str(locale) rv = _translations.get(key)
for locale in os.listdir(LOCALE_PATH): try: l = Locale.parse(locale) except (ValueError, UnknownLocaleError): continue
src/s/o/solace-HEAD/solace/i18n/__init__.py solace(Download)
""" try: key = str(Locale.parse(locale)) except UnknownLocaleError: return None
for locale, quality in choices: try: locale = Locale.parse(locale, sep='-') except UnknownLocaleError: continue if str(locale) in enabled and \ find_catalog(locale) is not None: return locale return Locale.parse(settings.DEFAULT_LANGUAGE)
def load_translations(locale): """Return the translations for the locale.""" locale = Locale.parse(locale) key = str(locale) rv = _translations.get(key)
for locale in os.listdir(LOCALE_PATH): try: l = Locale.parse(locale) except (ValueError, UnknownLocaleError): continue
src/a/l/AllSpeak-0.5.1/allspeak/__init__.py AllSpeak(Download)
if isinstance(locale, basestring): locale = locale.replace('_', '-') locale = Locale.parse(locale, sep='-') request.locale = locale return request.locale
src/k/a/KalaPy-0.4.2/kalapy/i18n/utils.py KalaPy(Download)
if locale is None: try: locale = Locale.parse(request.accept_languages.best, sep='-') request.babel_locale = locale except: locale = Locale.parse(settings.DEFAULT_LOCALE)
src/k/a/kalapy-HEAD/kalapy/i18n/utils.py kalapy(Download)
if locale is None: try: locale = Locale.parse(request.accept_languages.best, sep='-') request.babel_locale = locale except: locale = Locale.parse(settings.DEFAULT_LOCALE)
src/h/u/hue-HEAD/desktop/core/ext-py/BabelDjango-0.2.2/babeldjango/middleware.py hue(Download)
def process_request(self, request): try: code = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE) locale = Locale.parse(code, sep='-') except (ValueError, UnknownLocaleError):
src/h/o/hortonworks-sandbox-HEAD/desktop/core/ext-py/BabelDjango-0.2.2/babeldjango/middleware.py hortonworks-sandbox(Download)
def process_request(self, request): try: code = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE) locale = Locale.parse(code, sep='-') except (ValueError, UnknownLocaleError):
src/a/l/AllSpeak-0.5.1/allspeak/utils.py AllSpeak(Download)
if isinstance(locale, basestring): locale = locale.replace('_', '-') return Locale.parse(locale, sep='-') if isinstance(locale, tuple): return Locale(*locale)
src/d/j/django-babel-0.3.3/django_babel/middleware.py django-babel(Download)
def process_request(self, request): try: code = getattr(request, 'LANGUAGE_CODE', get_language()) locale = Locale.parse(code, sep='-') except (ValueError, UnknownLocaleError):
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next