diff options
author | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2013-07-31 18:00:13 -0600 |
---|---|---|
committer | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2013-07-31 18:00:13 -0600 |
commit | d972db7da75dee956a9cc2b4cbf96c2e3bb65d24 (patch) | |
tree | a200caea8b31c8911f319c1aea06bd05d67af634 | |
parent | 8798777c749cd7b344ea3dd469115dbc531381f4 (diff) | |
download | askbot-d972db7da75dee956a9cc2b4cbf96c2e3bb65d24.tar.gz askbot-d972db7da75dee956a9cc2b4cbf96c2e3bb65d24.tar.bz2 askbot-d972db7da75dee956a9cc2b4cbf96c2e3bb65d24.zip |
fixing stuff from the language feature, added start up procedures
-rw-r--r-- | askbot/conf/skin_general_settings.py | 51 | ||||
-rw-r--r-- | askbot/setup_templates/settings.py | 2 | ||||
-rw-r--r-- | askbot/setup_templates/settings.py.mustache | 2 | ||||
-rw-r--r-- | askbot/startup_procedures.py | 21 |
4 files changed, 30 insertions, 46 deletions
diff --git a/askbot/conf/skin_general_settings.py b/askbot/conf/skin_general_settings.py index 60da28a0..a46b4e63 100644 --- a/askbot/conf/skin_general_settings.py +++ b/askbot/conf/skin_general_settings.py @@ -30,51 +30,16 @@ settings.register( ) ) -LANGUAGE_CHOICES = ( - ('en', _("English")), - ('es', _("Spanish")), - ('ca', _("Catalan")), - ('de', _("German")), - ('el', _("Greek")), - ('fi', _("Finnish")), - ('fr', _("French")), - ('hi', _("Hindi")), - ('hu', _("Hungarian")), - ('it', _("Italian")), - ('ja', _("Japanese")), - ('ko', _("Korean")), - ('pt', _("Portuguese")), - ('pt_BR', _("Brazilian Portuguese")), - ('ro', _("Romanian")), - ('ru', _("Russian")), - ('sr', _("Serbian")), - ('tr', _("Turkish")), - ('vi', _("Vietnamese")), - ('zh_CN', _("Chinese")), - ('zh_TW', _("Chinese (Taiwan)")), +if not getattr(django_settings, 'ASKBOT_MULTILINGUAL', False): + settings.register( + values.StringValue( + GENERAL_SKIN_SETTINGS, + 'ASKBOT_LANGUAGE', + default = django_settings.LANGUAGE_CODE, + choices = django_settings.LANGUAGES, + description = _('Select Language'), ) - -def cleaned_language_code(language_code=django_settings.LANGUAGE_CODE): - '''makes shure that settings.LANGUAGE_CODE is on - the dictionary''' - if language_code in [code for code, name in LANGUAGE_CHOICES]: - return language_code - elif '_' in language_code: - lang, country = django_settings.LANGUAGE_CODE.split('_') - return cleaned_language_code(lang) - else: - #english as a default fallback - return 'en' - -settings.register( - values.StringValue( - GENERAL_SKIN_SETTINGS, - 'ASKBOT_LANGUAGE', - default = cleaned_language_code(), - choices = LANGUAGE_CHOICES, - description = _('Select Language'), ) -) settings.register( values.BooleanValue( diff --git a/askbot/setup_templates/settings.py b/askbot/setup_templates/settings.py index da38a3f1..c9778263 100644 --- a/askbot/setup_templates/settings.py +++ b/askbot/setup_templates/settings.py @@ -98,9 +98,9 @@ TEMPLATE_LOADERS = ( MIDDLEWARE_CLASSES = ( #'django.middleware.gzip.GZipMiddleware', - #'askbot.middleware.locale.LocaleMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', + 'askbot.middleware.locale.LocaleMiddleware', #'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', #'django.middleware.cache.FetchFromCacheMiddleware', diff --git a/askbot/setup_templates/settings.py.mustache b/askbot/setup_templates/settings.py.mustache index 7e617fc7..8cd32e48 100644 --- a/askbot/setup_templates/settings.py.mustache +++ b/askbot/setup_templates/settings.py.mustache @@ -102,9 +102,9 @@ TEMPLATE_LOADERS = ( MIDDLEWARE_CLASSES = ( #'django.middleware.gzip.GZipMiddleware', - #'askbot.middleware.locale.LocaleMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', + 'askbot.middleware.locale.LocaleMiddleware', #'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', #'django.middleware.cache.FetchFromCacheMiddleware', diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py index b25cdf56..316b5f46 100644 --- a/askbot/startup_procedures.py +++ b/askbot/startup_procedures.py @@ -889,6 +889,24 @@ def test_secret_key(): 'Please change your SECRET_KEY setting, the current is not secure' ]) +def test_locale_middlewares(): + is_multilang = getattr(django_settings, 'ASKBOT_MULTILINGUAL', False) + django_locale_middleware = 'django.middleware.locale.LocaleMiddleware' + askbot_locale_middleware = 'askbot.middleware.locale.LocaleMiddleware' + errors = list() + + if is_multilang: + if askbot_locale_middleware in django_settings.MIDDLEWARE_CLASSES: + errors.append("Please remove '%s' from your MIDDLEWARE_CLASSES" % askbot_locale_middleware) + if django_locale_middleware not in django_settings.MIDDLEWARE_CLASSES: + errors.append("Please add '%s' to your MIDDLEWARE_CLASSES" % django_locale_middleware) + else: + if askbot_locale_middleware not in django_settings.MIDDLEWARE_CLASSES: + errors.append("Please add '%s' to your MIDDLEWARE_CLASSES" % askbot_locale_middleware) + if django_locale_middleware in django_settings.MIDDLEWARE_CLASSES: + errors.append("Please remove '%s' from your MIDDLEWARE_CLASSES" % django_locale_middleware) + + print_errors(errors) def test_multilingual(): is_multilang = getattr(django_settings, 'ASKBOT_MULTILINGUAL', False) @@ -952,7 +970,8 @@ def run_startup_tests(): #test_postgres() test_messages_framework() test_middleware() - test_multilingual() + #test_multilingual() + test_locale_middlewares() #test_csrf_cookie_domain() test_secret_key() test_service_url_prefix() |