Extracting default locale to a global constant

This commit is contained in:
Jarosław Sadziński 2022-11-09 12:14:31 +01:00
parent e09f71e481
commit b72e668705
3 changed files with 4 additions and 3 deletions

View File

@ -16,7 +16,7 @@ import usertypes
import relabeling import relabeling
import table import table
import moment import moment
from schema import RecalcWhen from schema import RecalcWhen, DEFAULT_LOCALE
# pylint:disable=redefined-outer-name # pylint:disable=redefined-outer-name
@ -66,7 +66,7 @@ class MetaTableExtras(object):
return {} return {}
def locale(rec, table): 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): def friendly_traceback_set_lang(rec, table):
try: try:

View File

@ -802,7 +802,7 @@ def migration22(tdset):
def migration23(tdset): def migration23(tdset):
return tdset.apply_doc_actions([ return tdset.apply_doc_actions([
add_column('_grist_DocInfo', 'documentSettings', 'Text'), 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 + '"}'})
]) ])

View File

@ -16,6 +16,7 @@ import six
import actions import actions
SCHEMA_VERSION = 33 SCHEMA_VERSION = 33
DEFAULT_LOCALE = "en-US"
def make_column(col_id, col_type, formula='', isFormula=False): def make_column(col_id, col_type, formula='', isFormula=False):
return { return {