Ticket #3594: javascript_translation_test_case.patch

File javascript_translation_test_case.patch, 3.1 KB (added by Aku Kotkavuo, 15 years ago)

Updated attached test case to assert that fallback languages other than English still work

  • tests/regressiontests/views/locale/en/LC_MESSAGES/djangojs.po

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
     
    1 # SOME DESCRIPTIVE TITLE.
    2 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
    3 # This file is distributed under the same license as the PACKAGE package.
    4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
    5 #
    6 #, fuzzy
    7 msgid ""
    8 msgstr ""
    9 "Project-Id-Version: PACKAGE VERSION\n"
    10 "Report-Msgid-Bugs-To: \n"
    11 "POT-Creation-Date: 2007-09-15 16:45+0200\n"
    12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    14 "Language-Team: LANGUAGE <LL@li.org>\n"
    15 "MIME-Version: 1.0\n"
    16 "Content-Type: text/plain; charset=UTF-8\n"
    17 "Content-Transfer-Encoding: 8bit\n"
    18 
    19 msgid "this is to be translated"
    20 msgstr "this is to be translated in english"
    21  No newline at end of file
  • tests/regressiontests/views/tests/i18n.py

     
    2020
    2121    def test_jsi18n(self):
    2222        """The javascript_catalog can be deployed with language settings"""
    23         for lang_code in ['es', 'fr', 'en']:
     23        for lang_code in ['es', 'fr']:
    2424            activate(lang_code)
    2525            catalog = gettext.translation('djangojs', locale_dir, [lang_code])
    2626            trans_txt = catalog.ugettext('this is to be translated')
     
    2828            # in response content must to be a line like that:
    2929            # catalog['this is to be translated'] = 'same_that_trans_txt'
    3030            self.assertContains(response, trans_txt, 1)
     31
     32    def test_jsi18n_with_missing_en_files(self):
     33        """
     34        The javascript_catalog shouldn't load the fallback language in the
     35        case that the current selected language is actually the one translated
     36        from, and hence missing translation files completely.
     37
     38        This happens easily when you're translating from English to other
     39        languages and you've set settings.LANGUAGE_CODE to some other language
     40        than English.
     41        """
     42        settings.LANGUAGE_CODE = 'es'
     43        activate('en-us')
     44        response = self.client.get('/views/jsi18n/')
     45        self.assertNotContains(response, 'esto tiene que ser traducido')
     46
     47    def test_jsi18n_fallback_language(self):
     48        """
     49        Let's make sure that the fallback language is still working properly
     50        in cases where the selected language cannot be found.
     51        """
     52        settings.LANGUAGE_CODE = 'fr'
     53        activate('fi')
     54        response = self.client.get('/views/jsi18n/')
     55        self.assertContains(response, 'il faut le traduire')
Back to Top