Example #1
0
def get_names():
    from six.moves.urllib.request import Request
    import json
    request = Request(MOMENT_COMPONENT_JSON_URL)
    moment_component_files = json.loads(retry_urlopen(request).decode())["files"]
    moment_supported_langs_set = set([name.replace("locale/", "").replace(".js", "")
                              for name in moment_component_files
                              if name.startswith("locale/")])

    from django.conf.locale import LANG_INFO
    django_supported_langs = set(list(LANG_INFO.keys()))

    moment_already_supported = (
        moment_supported_langs_set.intersection(django_supported_langs))

    known_fallbacks = {
        # For Chinese
        'zh-hans': "zh-cn",
        'zh-my': "zh-cn",
        'zh-sg': "zh-cn",
        'zh-hant': "zh-tw",  # or 'zh-hk'
        'zh-mo': "zh-tw",

        # For Spanish
        'es-ar': "es",
        'es-co': "es",
        'es-mx': "es",
        'es-ni': "es",
        'es-ve': "es",
    }

    for l in known_fallbacks.keys():
        try:
            assert l not in moment_already_supported
        except:
            raise ValueError("'%s' is now supported by moment.js, "
                             "please remove it from known_fallbacks" % l)

    not_supported = (
        django_supported_langs
            .difference(moment_supported_langs_set)
            .difference(set(list(known_fallbacks.keys())))
            .difference({"en", "en-us"}))

    print(repr(known_fallbacks))
    print(repr(sorted(list(not_supported))))
Example #2
0
    def test_all_locales(self):
        formatter = ExcelDateFormatter()

        for lang in LANG_INFO.keys():
            with self.subTest(lang), translation.override(lang):
                self.assertNotEqual(formatter.get(), "")
Example #3
0
METHOD_CHOICES = (
    ('google', 'Google App Engine'),
    ('gunicorn', 'Gunicorn'),
    ('mod_python', 'mod_python'),
    ('mod_wsgi', 'mod_wsgi'),
    ('fastcgi', 'FastCGI'),
    ('dev', 'Django Development Server'),
    ('scgi', 'Simple CGI (scgi)'),
    ('tornado', 'Tornado'),
    ('wsgi', 'wsgi'),
    ('uwsgi', 'uWSGI'),
    ('paas', 'PAAS (Heroku, GAE, Gondor, etc'),
)

LANGUAGE_CHOICES = []
for language in LANG_INFO.keys():
    LANGUAGE_CHOICES.append((LANG_INFO[language]['code'], LANG_INFO[language]['name']))


class Website(models.Model):
    title = models.CharField(max_length=100)
    url = models.URLField(unique=True)
    slug = models.SlugField(editable=False, blank=True, null=True, max_length=250)
    owner = models.ForeignKey(User, blank=True, null=True, editable=False)
    description = models.TextField()
    tags = TagField(blank=True, null=True)
    verified = models.BooleanField(blank=True, default=False, editable=False)
    created = models.DateTimeField(blank=True, null=True, editable=False)
    
    comment_count = models.IntegerField(blank=True, null=True, editable=False)
    num_votes = models.IntegerField(blank=True, null=True, editable=False)
Example #4
0
METHOD_CHOICES = (
    ('google', 'Google App Engine'),
    ('gunicorn', 'Gunicorn'),
    ('mod_python', 'mod_python'),
    ('mod_wsgi', 'mod_wsgi'),
    ('fastcgi', 'FastCGI'),
    ('dev', 'Django Development Server'),
    ('scgi', 'Simple CGI (scgi)'),
    ('tornado', 'Tornado'),
    ('wsgi', 'wsgi'),
    ('uwsgi', 'uWSGI'),
    ('paas', 'PAAS (Heroku, GAE, Gondor, etc'),
)

LANGUAGE_CHOICES = []
for language in LANG_INFO.keys():
    LANGUAGE_CHOICES.append(
        (LANG_INFO[language]['code'], LANG_INFO[language]['name']))


class Website(models.Model):
    title = models.CharField(max_length=100)
    url = models.URLField(unique=True)
    slug = models.SlugField(editable=False,
                            blank=True,
                            null=True,
                            max_length=250)
    owner = models.ForeignKey(User, blank=True, null=True, editable=False)
    description = models.TextField()
    tags = TagField(blank=True, null=True)
    verified = models.BooleanField(blank=True, default=False, editable=False)