Exemplo n.º 1
0
    def test_list_newsletter_langs(self):
        """Should return all languages for specified list of newsletters."""
        result = utils.get_languages_for_newsletters(["join-mozilla", "beta"])
        good_set = {"en", "es"}
        self.assertSetEqual(good_set, result)

        result = utils.get_languages_for_newsletters(["firefox-tips", "beta"])
        good_set = {"en", "fr", "de", "pt", "ru"}
        self.assertSetEqual(good_set, result)
Exemplo n.º 2
0
    def test_list_newsletter_langs(self):
        """Should return all languages for specified list of newsletters."""
        result = utils.get_languages_for_newsletters(['join-mozilla', 'beta'])
        good_set = {'en', 'es'}
        self.assertSetEqual(good_set, result)

        result = utils.get_languages_for_newsletters(['firefox-tips', 'beta'])
        good_set = {'en', 'fr', 'de', 'pt', 'ru'}
        self.assertSetEqual(good_set, result)
Exemplo n.º 3
0
def get_lang_choices(newsletters=None):
    """
     Return a localized list of choices for language.

     List looks like: [[lang_code, lang_name], [lang_code, lang_name], ...]

     :param newsletters: Either a comma separated string or a list of newsletter ids.
    """
    lang_choices = []
    languages = utils.get_languages_for_newsletters(newsletters)

    for lang in languages:
        if lang in product_details.languages:
            lang_name = product_details.languages[lang]['native']
        else:
            try:
                locale = [
                    loc for loc in product_details.languages.keys()
                    if loc.startswith(lang)
                ][0]
            except IndexError:
                continue
            lang_name = product_details.languages[locale]['native']
        lang_choices.append([lang, strip_parenthetical(lang_name)])
    return sorted(lang_choices, key=itemgetter(1))
Exemplo n.º 4
0
def get_lang_choices(newsletters=None):
    """
     Return a localized list of choices for language.

     List looks like: [[lang_code, lang_name], [lang_code, lang_name], ...]

     :param newsletters: Either a comma separated string or a list of newsletter ids.
    """
    lang_choices = []
    languages = utils.get_languages_for_newsletters(newsletters)

    for lang in languages:
        if lang in product_details.languages:
            lang_name = product_details.languages[lang]['native']
        else:
            try:
                locale = [loc for loc in product_details.languages.keys()
                          if loc.startswith(lang)][0]
            except IndexError:
                continue
            lang_name = product_details.languages[locale]['native']
        lang_choices.append([lang, strip_parenthetical(lang_name)])
    return sorted(lang_choices, key=itemgetter(1))
Exemplo n.º 5
0
 def test_works_with_bad_newsletter(self):
     """If given a bad newsletter name, should still return a set."""
     result = utils.get_languages_for_newsletters(['join-mozilla', 'eldudarino'])
     good_set = {'en', 'es'}
     self.assertSetEqual(good_set, result)
Exemplo n.º 6
0
 def test_single_newsletter_langs(self):
     """Should return languages for a single newsletter."""
     result = utils.get_languages_for_newsletters('join-mozilla')
     good_set = {'en', 'es'}
     self.assertSetEqual(good_set, result)
Exemplo n.º 7
0
 def test_newsletter_langs(self):
     """Without args should return all langs."""
     result = utils.get_languages_for_newsletters()
     good_set = {'en', 'es', 'fr', 'de', 'pt', 'ru'}
     self.assertSetEqual(good_set, result)
Exemplo n.º 8
0
 def test_newsletter_langs(self):
     """Without args should return all langs."""
     result = utils.get_languages_for_newsletters()
     good_set = {"en", "es", "fr", "de", "pt", "ru"}
     self.assertSetEqual(good_set, result)