feat: Superset language

A nice language flag will be added to the superset sidebar when the
LMS/CMS have a different language.
This commit is contained in:
Régis Behmo 2022-03-17 10:49:03 +01:00
parent ee3dbb912f
commit bab403c361
3 changed files with 29 additions and 3 deletions

View File

@ -106,9 +106,7 @@ Cairn allows you to collect and view just any metric from your Open edX platform
- Number of unique viewers
- Average watch time
- Total watch time
- Second-per-second statistics:
- Number of unique viewers
- Total number of views
- Second-per-second statistics: Number of unique viewers, Total number of views
Data-based access control
@ -226,6 +224,7 @@ Postgresql/Superset settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ``CAIRN_RUN_POSTGRESQL`` (default: ``true``): set to ``false`` to run your own Postgresql cluster separately from Cairn. Postgresql is the database that stores all data related to Superset, which is the Cairn frontend.
- ``CAIRN_SUPERSET_LANGUAGE_CODE`` (default: ``"{{ LANGUAGE_CODE[:2] }}"``): 2-letter code of the default language for the Superset frontend. View the list of all supported languages `here <https://github.com/apache/superset/blob/dc575080d7e43d40b1734bb8f44fdc291cb95b11/superset/config.py#L324>`__. When different than "en", users will have the opportunity to switch from English to this language via a flag icon in the top-right corner.
- ``CAIRN_SUPERSET_DOCKER_IMAGE`` (default: ``"{{ DOCKER_REGISTRY }}overhangio/cairn-superset:{{ CAIRN_VERSION }}"``): name of the Docker image that runs Postgresql.
- ``CAIRN_POSTGRESQL_DATABASE`` (default: ``"superset"``): name of the Postgresql database.
- ``CAIRN_POSTGRESQL_USERNAME`` (default: ``"superset"``): Postgresql username.

View File

@ -31,6 +31,7 @@ config = {
"POSTGRESQL_DATABASE": "superset",
"POSTGRESQL_USERNAME": "superset",
"SUPERSET_DOCKER_IMAGE": "{{ DOCKER_REGISTRY }}overhangio/cairn-superset:{{ CAIRN_VERSION }}",
"SUPERSET_LANGUAGE_CODE": "{{ LANGUAGE_CODE[:2] }}",
},
}

View File

@ -15,6 +15,32 @@ DATA_CACHE_CONFIG = {
}
CACHE_CONFIG = DATA_CACHE_CONFIG
# Languages
# https://github.com/apache/superset/blob/dc575080d7e43d40b1734bb8f44fdc291cb95b11/superset/config.py#L324
available_languages = {
"en": {"flag": "us", "name": "English"},
"es": {"flag": "es", "name": "Spanish"},
"it": {"flag": "it", "name": "Italian"},
"fr": {"flag": "fr", "name": "French"},
"zh": {"flag": "cn", "name": "Chinese"},
"ja": {"flag": "jp", "name": "Japanese"},
"de": {"flag": "de", "name": "German"},
"pt": {"flag": "pt", "name": "Portuguese"},
"pt_BR": {"flag": "br", "name": "Brazilian Portuguese"},
"ru": {"flag": "ru", "name": "Russian"},
"ko": {"flag": "kr", "name": "Korean"},
"sl": {"flag": "si", "name": "Slovenian"},
}
{#- https://github.com/apache/superset/blob/master/docs/docs/contributing/translations.mdx#enabling-language-selection #}
enabled_language_codes = ["en"]
LANGUAGES = {}
if "{{ CAIRN_SUPERSET_LANGUAGE_CODE }}" in available_languages:
enabled_language_codes.append("{{ CAIRN_SUPERSET_LANGUAGE_CODE }}")
# Set the platform default language/locale
BABEL_DEFAULT_LOCALE = "{{ CAIRN_SUPERSET_LANGUAGE_CODE }}"
for code in enabled_language_codes:
LANGUAGES[code] = available_languages[code]
# Borrowed from superset/docker/pythonpath_dev/superset_config.py
REDIS_HOST = "redis"
REDIS_PORT = "6379"