Esempio n. 1
0
    def test_lookup_language_with_i18n_false(self):
        # Make sure we can handle the 'null' USE_I18N=False implementation of
        # get_supported_language_variant returning 'en-us' rather than 'en',
        # despite 'en-us' not being in LANGUAGES.
        # https://github.com/wagtail/wagtail/issues/6539

        self.assertEqual(get_supported_content_language_variant("en-us"), "en")
Esempio n. 2
0
    def __init__(self, model_string, language_code=None):
        if language_code is None:
            language_code = get_supported_content_language_variant(
                settings.LANGUAGE_CODE)

        def forwards(apps, schema_editor):
            model = apps.get_model(model_string)
            Locale = apps.get_model("wagtailcore.Locale")

            locale = Locale.objects.get(language_code=language_code)
            bootstrap_translatable_model(model, locale)

        def backwards(apps, schema_editor):
            pass

        super().__init__(forwards, backwards)
Esempio n. 3
0
 def get_for_language(self, language_code):
     """
     Gets a Locale from a language code.
     """
     return self.get(language_code=get_supported_content_language_variant(
         language_code))
Esempio n. 4
0
 def test_language_code_not_in_languages(self):
     # Ensure we can handle a LANGUAGE_CODE setting that isn't defined in LANGUAGES -
     # in this case get_content_languages has to cope with not being able to retrieve
     # a display name for the language
     self.assertEqual(get_supported_content_language_variant("zz"), "zz")
     self.assertEqual(get_supported_content_language_variant("zz-gb"), "zz")
Esempio n. 5
0
def initial_locale(apps, schema_editor):
    Locale = apps.get_model("wagtailcore.Locale")

    Locale.objects.create(language_code=get_supported_content_language_variant(
        settings.LANGUAGE_CODE), )