From 900345aa95d95d4fa259700ea57788ecbcb82a1c Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 18 Mar 2024 11:53:26 +0100 Subject: [PATCH 1/7] add default lang ca --- trustchain_idhub/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trustchain_idhub/settings.py b/trustchain_idhub/settings.py index f2fdc51..bdab762 100644 --- a/trustchain_idhub/settings.py +++ b/trustchain_idhub/settings.py @@ -197,7 +197,7 @@ LOCALE_PATHS = [ ] # LANGUAGE_CODE="en" # LANGUAGE_CODE="es" -LANGUAGE_CODE="en" +LANGUAGE_CODE="ca" gettext = lambda s: s LANGUAGES = ( ('de', gettext('German')), From 7b2a2436047b95a21dc90add8efc2d3e3bf97559 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 19 Mar 2024 09:16:19 +0100 Subject: [PATCH 2/7] changes local lang to en --- trustchain_idhub/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trustchain_idhub/settings.py b/trustchain_idhub/settings.py index bdab762..8ff251b 100644 --- a/trustchain_idhub/settings.py +++ b/trustchain_idhub/settings.py @@ -195,9 +195,9 @@ MESSAGE_TAGS = { LOCALE_PATHS = [ os.path.join(BASE_DIR, 'locale'), ] -# LANGUAGE_CODE="en" +LANGUAGE_CODE="en" # LANGUAGE_CODE="es" -LANGUAGE_CODE="ca" +# LANGUAGE_CODE="ca" gettext = lambda s: s LANGUAGES = ( ('de', gettext('German')), From fe5b547a25a69afe5b6f06fa48065f6af10d012a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 19 Mar 2024 10:58:17 +0100 Subject: [PATCH 3/7] change languiage_code in settins --- trustchain_idhub/settings.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/trustchain_idhub/settings.py b/trustchain_idhub/settings.py index 8ff251b..5c42b66 100644 --- a/trustchain_idhub/settings.py +++ b/trustchain_idhub/settings.py @@ -195,14 +195,15 @@ MESSAGE_TAGS = { LOCALE_PATHS = [ os.path.join(BASE_DIR, 'locale'), ] -LANGUAGE_CODE="en" +# LANGUAGE_CODE="en" # LANGUAGE_CODE="es" -# LANGUAGE_CODE="ca" +LANGUAGE_CODE="ca" gettext = lambda s: s LANGUAGES = ( ('de', gettext('German')), ('en', gettext('English')), ('ca', gettext('Catalan')), + ('es', gettext('Spanish')), ) USE_I18N = True USE_L10N = True From 1c901d673c42ec94ed9cbd812d351ad847f242bc Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 19 Mar 2024 10:59:26 +0100 Subject: [PATCH 4/7] fix get_description in admin.view --- idhub/admin/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/idhub/admin/views.py b/idhub/admin/views.py index e8e4876..355d8ce 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -1021,7 +1021,10 @@ class SchemasImportAddView(SchemasMix): def get_description(self): for des in json.loads(self.get_template_description()).get('description', []): - if settings.LANGUAGE_CODE == des.get('lang'): + lang = settings.LANGUAGE_CODE + if lang == 'ca': + lang = 'ca_ES' + if lang == des.get('lang'): return des.get('value', '') return '' From ca64247f1b3670c876c4ef8cd7873e9351b10edd Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 19 Mar 2024 11:00:06 +0100 Subject: [PATCH 5/7] fix ca_ES for ca in models --- idhub/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/idhub/models.py b/idhub/models.py index 7843d4c..c5841da 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -537,7 +537,7 @@ class Schemas(models.Model): if request: language_code = request.LANGUAGE_CODE if self._is_catalan_code(language_code): - language_code = 'ca' + language_code = 'ca_ES' return language_code @@ -549,7 +549,7 @@ class Schemas(models.Model): return None def _is_catalan_code(self, language_code): - return language_code == 'ca_ES' + return language_code == 'ca' @name.setter def name(self, value): From 46cd29f931a4cac70dc29ebbdfb4b81d51e83fd5 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 19 Mar 2024 11:00:22 +0100 Subject: [PATCH 6/7] fix tests --- idhub/tests/test_credentials.py | 2 ++ idhub/tests/test_tables.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/idhub/tests/test_credentials.py b/idhub/tests/test_credentials.py index ac95977..e76a279 100644 --- a/idhub/tests/test_credentials.py +++ b/idhub/tests/test_credentials.py @@ -36,6 +36,7 @@ class KeyFirstTimeTest(TestCase): settings.DOMAIN = self.org.name settings.ENABLE_EMAIL = False + settings.LANGUAGE_CODE = 'en' def set_cache(self): cache.set("KEY_DIDS", '1234', None) @@ -94,6 +95,7 @@ class CredentialsViewTest(TestCase): settings.DOMAIN = self.org.name settings.ENABLE_EMAIL = False + settings.LANGUAGE_CODE = 'en' self.admin_login() self.create_schemas() diff --git a/idhub/tests/test_tables.py b/idhub/tests/test_tables.py index 3dfe181..5cf4f92 100644 --- a/idhub/tests/test_tables.py +++ b/idhub/tests/test_tables.py @@ -12,6 +12,7 @@ from django.core.exceptions import FieldError from idhub_auth.models import User from idhub.admin.tables import DashboardTable, UserTable, TemplateTable from idhub.models import Event, Membership, Rol, UserRol, Service, Schemas +from oidc4vp.models import Organization class AdminDashboardTableTest(TestCase): @@ -22,6 +23,10 @@ class AdminDashboardTableTest(TestCase): password='adminpass12') self.admin_user.accept_gdpr=True self.admin_user.save() + self.org = Organization.objects.create(name="testserver", main=True) + settings.LANGUAGE_CODE = 'en' + settings.DOMAIN = self.org.name + settings.ENABLE_EMAIL = False @classmethod def setUpTestData(cls): From 1cce4639d871450cc0f17491eb5253c1470e9e48 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 19 Mar 2024 11:04:39 +0100 Subject: [PATCH 7/7] add language_code as env var --- trustchain_idhub/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trustchain_idhub/settings.py b/trustchain_idhub/settings.py index 5c42b66..32a8ce7 100644 --- a/trustchain_idhub/settings.py +++ b/trustchain_idhub/settings.py @@ -197,7 +197,7 @@ LOCALE_PATHS = [ ] # LANGUAGE_CODE="en" # LANGUAGE_CODE="es" -LANGUAGE_CODE="ca" +LANGUAGE_CODE = config('LANGUAGE_CODE', "ca") gettext = lambda s: s LANGUAGES = ( ('de', gettext('German')),