Esempio n. 1
0
    choose_language_code

UTC = babel.dates.UTC
ROME = babel.dates.get_timezone("Europe/Rome")

FRENCH_CATALOG = Catalog(locale="fr")
FRENCH_CATALOG.add("%s KiB", "%s Kio")
FRENCH_CATALOG.add("%s MiB", "%s Mio")
FRENCH_CATALOG.add("%s GiB", "%s Gio")
FRENCH_CATALOG.add("%s TiB", "%s Tio")
FRENCH_CATALOG_BUF = BytesIO()
write_mo(FRENCH_CATALOG_BUF, FRENCH_CATALOG)
FRENCH_CATALOG_BUF.seek(0)

ENGLISH = DEFAULT_TRANSLATION
BRITISH_ENGLISH = Translation("en_GB")
FRENCH = Translation("fr", mofile=FRENCH_CATALOG_BUF)
HINDI = Translation("hi")
ITALIAN = Translation("it")
NORWEGIAN = Translation("no")
CHINESE = Translation("zh_CN")


class TestIdentifier(unittest.TestCase):
    def test_language_only(self):
        self.assertEqual(ENGLISH.identifier, "en")
        self.assertEqual(ITALIAN.identifier, "it")

    def test_language_and_country(self):
        self.assertEqual(BRITISH_ENGLISH.identifier, "en-GB")
Esempio n. 2
0
from future.builtins import *

import os.path
import unittest
from datetime import datetime, timedelta

import babel.dates

from cms.locale import Translation, DEFAULT_TRANSLATION, filter_language_codes, \
    choose_language_code

UTC = babel.dates.UTC
ROME = babel.dates.get_timezone("Europe/Rome")

ENGLISH = DEFAULT_TRANSLATION
BRITISH_ENGLISH = Translation("en_GB")
FRENCH = Translation("fr")
HINDI = Translation("hi")
ITALIAN = Translation("it")
NORWEGIAN = Translation("no")
CHINESE = Translation("zh_CN")


class TestIdentifier(unittest.TestCase):
    def test_language_only(self):
        self.assertEqual(ENGLISH.identifier, "en")
        self.assertEqual(ITALIAN.identifier, "it")

    def test_language_and_country(self):
        self.assertEqual(BRITISH_ENGLISH.identifier, "en-GB")