From 999ebe604ccbf06b0ba174b310a805f986582aa3 Mon Sep 17 00:00:00 2001 From: "Amy J. Ko" Date: Sat, 11 Nov 2023 16:05:08 -0800 Subject: [PATCH] Explicit code localization switch. --- CHANGELOG.md | 3 + src/components/editor/Editor.svelte | 8 ++- src/components/editor/util/Commands.ts | 6 +- src/components/project/ProjectView.svelte | 20 +++++- src/components/project/RootView.svelte | 79 ++++++++++++----------- src/db/Database.ts | 1 + src/db/LocalizedSetting.ts | 9 +++ src/db/SettingsDatabase.ts | 14 ++++ src/locale/UITexts.ts | 2 + src/locale/en-US.json | 4 ++ static/locales/es-MX/es-MX.json | 4 ++ static/locales/example/example.json | 4 ++ static/locales/zh-CN/zh-CN.json | 4 ++ static/schemas/Locale.json | 7 +- 14 files changed, 122 insertions(+), 43 deletions(-) create mode 100644 src/db/LocalizedSetting.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cd5b83bb..22eeb2111 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Dates are in `YYYY-MM-DD` format and versions are in [semantic versioning](http: ## 0.9.1 +This version includes many other changes made prior to this log was created. + ## Added - New change password form on profile. @@ -13,6 +15,7 @@ Dates are in `YYYY-MM-DD` format and versions are in [semantic versioning](http: - Improved design of username and password login [#272](https://github.com/wordplaydev/wordplay/issues/272), [#273](https://github.com/wordplaydev/wordplay/issues/273) - Converted blocks toggle to a keyboard/mouse switch. +- Explicit switch control over localization of editor, instead of automatic. ## Fixed diff --git a/src/components/editor/Editor.svelte b/src/components/editor/Editor.svelte index ef4e8e214..2538f8f5f 100644 --- a/src/components/editor/Editor.svelte +++ b/src/components/editor/Editor.svelte @@ -86,6 +86,7 @@ import Adjust from './Adjust.svelte'; import EditorHelp from './EditorHelp.svelte'; import Emoji from '@components/app/Emoji.svelte'; + import { localized } from '../../db/Database'; const SHOW_OUTPUT_IN_PALETTE = false; @@ -1448,7 +1449,12 @@ on:focusout={() => (focused = false)} /> - + {#each outlines as outline} diff --git a/src/components/editor/util/Commands.ts b/src/components/editor/util/Commands.ts index e3224efdc..5163e7ccc 100644 --- a/src/components/editor/util/Commands.ts +++ b/src/components/editor/util/Commands.ts @@ -30,7 +30,7 @@ import type Evaluator from '@runtime/Evaluator'; import FunctionDefinition from '@nodes/FunctionDefinition'; import ExpressionPlaceholder from '@nodes/ExpressionPlaceholder'; import Names from '@nodes/Names'; -import type { Database } from '@db/Database'; +import { Settings, type Database } from '@db/Database'; import type Locale from '@locale/Locale'; import Sym from '../../../nodes/Sym'; import type Project from '../../../models/Project'; @@ -90,7 +90,7 @@ export type CommandContext = { database: Database; dragging: boolean; toggleMenu?: () => void; - toggleBlocks?: () => void; + toggleBlocks?: (on: boolean) => void; setFullscreen?: (on: boolean) => void; focusOrCycleTile?: (content?: TileKind) => void; resetInputs?: () => void; @@ -575,7 +575,7 @@ export const ToggleBlocks: Command = { key: 'Enter', execute: ({ toggleBlocks }) => { if (toggleBlocks) { - toggleBlocks(); + toggleBlocks(!Settings.getBlocks()); return true; } return false; diff --git a/src/components/project/ProjectView.svelte b/src/components/project/ProjectView.svelte index 232530107..cc4277cfe 100644 --- a/src/components/project/ProjectView.svelte +++ b/src/components/project/ProjectView.svelte @@ -83,6 +83,7 @@ Projects, writingLayout, blocks, + localized, Creators, } from '../../db/Database'; import Arrangement from '../../db/Arrangement'; @@ -781,8 +782,8 @@ }; }); - function toggleBlocks() { - Settings.setBlocks(!$blocks); + function toggleBlocks(on: boolean) { + Settings.setBlocks(on); } function getTileView(tileID: string) { @@ -1360,6 +1361,21 @@ toggle={toggleBlocks} on={$blocks} /> + + l.ui.source.toggle.localized.on + )} + offLabel={withVariationSelector('🌎')} + offTip={$locales.get( + (l) => + l.ui.source.toggle.localized.off + )} + toggle={(on) => + Settings.setLocalized(on)} + on={$localized} + /> {#each VisibleModifyCommands as command}