mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Simple localization support and currency selector.
Summary: - Grist document has a associated "locale" setting that affects how currency is formatted. - Currency selector for number format. Test Plan: not done Reviewers: dsagal Reviewed By: dsagal Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D2977
This commit is contained in:
@@ -788,3 +788,10 @@ def migration22(tdset):
|
||||
add_column('_grist_Tables_column', 'recalcWhen', 'Int'),
|
||||
add_column('_grist_Tables_column', 'recalcDeps', 'RefList:_grist_Tables_column'),
|
||||
])
|
||||
|
||||
@migration(schema_version=23)
|
||||
def migration23(tdset):
|
||||
return tdset.apply_doc_actions([
|
||||
add_column('_grist_DocInfo', 'documentSettings', 'Text'),
|
||||
actions.UpdateRecord('_grist_DocInfo', 1, {'documentSettings': '{"locale":"en-US"}'})
|
||||
])
|
||||
|
||||
@@ -15,7 +15,7 @@ import six
|
||||
|
||||
import actions
|
||||
|
||||
SCHEMA_VERSION = 22
|
||||
SCHEMA_VERSION = 23
|
||||
|
||||
def make_column(col_id, col_type, formula='', isFormula=False):
|
||||
return {
|
||||
@@ -40,6 +40,9 @@ def schema_create_actions():
|
||||
|
||||
# Document timezone.
|
||||
make_column("timezone", "Text"),
|
||||
|
||||
# Document settings (excluding timezone).
|
||||
make_column("documentSettings", "Text"), # JSON string describing document settings
|
||||
]),
|
||||
|
||||
# The names of the user tables. This does NOT include built-in tables.
|
||||
|
||||
@@ -193,13 +193,14 @@ class UserActions(object):
|
||||
#----------------------------------------
|
||||
|
||||
@useraction
|
||||
def InitNewDoc(self, timezone):
|
||||
def InitNewDoc(self, timezone, locale):
|
||||
creation_actions = schema.schema_create_actions()
|
||||
self._engine.out_actions.stored.extend(creation_actions)
|
||||
self._engine.out_actions.direct += [True] * len(creation_actions)
|
||||
self._do_doc_action(actions.AddRecord("_grist_DocInfo", 1,
|
||||
{'schemaVersion': schema.SCHEMA_VERSION,
|
||||
'timezone': timezone}))
|
||||
'timezone': timezone,
|
||||
'documentSettings': json.dumps({'locale': locale})}))
|
||||
|
||||
# Set up initial ACL data.
|
||||
# NOTE The special records below are not actually used. They were intended for obsolete ACL
|
||||
|
||||
Reference in New Issue
Block a user