From b72e6687053ad0306cbc1873a82b7f69c977ffbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Wed, 9 Nov 2022 12:14:31 +0100 Subject: [PATCH] Extracting default locale to a global constant --- sandbox/grist/docmodel.py | 4 ++-- sandbox/grist/migrations.py | 2 +- sandbox/grist/schema.py | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sandbox/grist/docmodel.py b/sandbox/grist/docmodel.py index e7b378b6..3955816e 100644 --- a/sandbox/grist/docmodel.py +++ b/sandbox/grist/docmodel.py @@ -16,7 +16,7 @@ import usertypes import relabeling import table import moment -from schema import RecalcWhen +from schema import RecalcWhen, DEFAULT_LOCALE # pylint:disable=redefined-outer-name @@ -66,7 +66,7 @@ class MetaTableExtras(object): return {} def locale(rec, table): - return rec.parsed_settings.get("locale", "en-US") + return rec.parsed_settings.get("locale", DEFAULT_LOCALE) def friendly_traceback_set_lang(rec, table): try: diff --git a/sandbox/grist/migrations.py b/sandbox/grist/migrations.py index 99842769..e78ab56e 100644 --- a/sandbox/grist/migrations.py +++ b/sandbox/grist/migrations.py @@ -802,7 +802,7 @@ def migration22(tdset): def migration23(tdset): return tdset.apply_doc_actions([ add_column('_grist_DocInfo', 'documentSettings', 'Text'), - actions.UpdateRecord('_grist_DocInfo', 1, {'documentSettings': '{"locale":"en-US"}'}) + actions.UpdateRecord('_grist_DocInfo', 1, {'documentSettings': '{"locale":"' + schema.DEFAULT_LOCALE + '"}'}) ]) diff --git a/sandbox/grist/schema.py b/sandbox/grist/schema.py index 682f561d..46c19fe5 100644 --- a/sandbox/grist/schema.py +++ b/sandbox/grist/schema.py @@ -16,6 +16,7 @@ import six import actions SCHEMA_VERSION = 33 +DEFAULT_LOCALE = "en-US" def make_column(col_id, col_type, formula='', isFormula=False): return {