From 0cbd9080f12c326d2c2907db6c9c594f2e0a7f8f Mon Sep 17 00:00:00 2001 From: "Amy J. Ko" Date: Mon, 16 Oct 2023 18:47:49 -0700 Subject: [PATCH] Fixed #204, locale fallback for unfinished locales. --- src/basis/Basis.test.ts | 6 +- src/basis/Basis.ts | 14 +- src/basis/BoolBasis.ts | 3 +- src/basis/InternalExpression.ts | 13 +- src/basis/Iteration.ts | 21 ++- src/basis/ListBasis.ts | 4 +- src/basis/MapBasis.ts | 4 +- src/basis/NoneBasis.ts | 5 +- src/basis/NumberBasis.ts | 3 +- src/basis/SetBasis.ts | 4 +- src/basis/StructureBasis.ts | 4 +- src/basis/TableBasis.ts | 6 +- src/basis/TextBasis.ts | 3 +- src/components/annotations/Annotations.svelte | 50 +++--- src/components/app/CreatorView.svelte | 6 +- src/components/app/GalleryPreview.svelte | 15 +- src/components/app/Loading.svelte | 6 +- src/components/app/Page.svelte | 14 +- src/components/app/ProjectPreviewSet.svelte | 4 +- src/components/app/Spinning.svelte | 6 +- src/components/app/Status.svelte | 12 +- src/components/app/TutorialView.svelte | 27 ++- .../concepts/BindConceptView.svelte | 16 +- src/components/concepts/ConceptLinkUI.svelte | 18 +- src/components/concepts/ConceptView.svelte | 29 ++-- src/components/concepts/Documentation.svelte | 38 +++-- src/components/concepts/ExampleUI.svelte | 2 +- .../concepts/StructureConceptView.svelte | 12 +- src/components/editor/CaretView.svelte | 8 +- src/components/editor/Editor.svelte | 34 ++-- src/components/editor/EditorHelp.svelte | 9 +- .../editor/ExpressionPlaceholderView.svelte | 11 +- src/components/editor/GlyphChooser.svelte | 10 +- src/components/editor/Menu.svelte | 28 +-- src/components/editor/NodeSequenceView.svelte | 6 +- src/components/editor/NodeView.svelte | 8 +- .../editor/StructureTypeView.svelte | 4 +- src/components/editor/TokenView.svelte | 6 +- src/components/editor/TypeView.svelte | 4 +- src/components/editor/util/Menu.ts | 11 +- src/components/evaluator/Controls.svelte | 6 +- src/components/evaluator/Timeline.svelte | 8 +- src/components/lore/Speech.svelte | 4 +- src/components/output/GroupView.svelte | 6 +- src/components/output/OutputDescriptions.ts | 15 +- src/components/output/OutputView.svelte | 37 ++-- src/components/output/Painting.svelte | 6 +- src/components/output/PhraseView.svelte | 6 +- src/components/output/ShapeView.svelte | 6 +- src/components/output/StageView.svelte | 6 +- src/components/palette/BindText.svelte | 11 +- src/components/palette/ContentEditor.svelte | 18 +- src/components/palette/EditOffer.svelte | 7 +- src/components/palette/Palette.svelte | 38 +++-- src/components/palette/PaletteProperty.svelte | 34 ++-- src/components/palette/PlaceEditor.svelte | 12 +- src/components/palette/PoseEditor.svelte | 12 +- src/components/palette/SequenceEditor.svelte | 4 +- .../palette/SequencePosesEditor.svelte | 25 ++- src/components/palette/VelocityEditor.svelte | 8 +- src/components/palette/editOutput.ts | 27 +-- src/components/project/Collaborators.svelte | 24 ++- .../project/CommandDescription.svelte | 4 +- src/components/project/CreatorList.svelte | 22 ++- src/components/project/Help.svelte | 25 ++- src/components/project/Moderation.svelte | 14 +- .../project/NonSourceTileToggle.svelte | 4 +- src/components/project/ProjectView.svelte | 106 +++++++----- src/components/project/Public.svelte | 30 ++-- src/components/project/RootView.svelte | 16 +- .../project/SourceTileToggle.svelte | 7 +- src/components/project/TileView.svelte | 14 +- src/components/settings/LocaleChooser.svelte | 31 ++-- src/components/settings/Settings.svelte | 26 ++- src/components/values/ExceptionView.svelte | 4 +- src/components/values/FunctionView.svelte | 4 +- .../values/StreamDefinitionView.svelte | 2 +- .../values/StructureDefinitionView.svelte | 2 +- src/components/values/StructureView.svelte | 8 +- src/components/values/TableView.svelte | 6 +- src/components/widgets/ColorChooser.svelte | 12 +- src/components/widgets/CommandButton.svelte | 4 +- src/components/widgets/ConfirmButton.svelte | 4 +- src/components/widgets/Dialog.svelte | 4 +- src/components/widgets/Note.svelte | 5 +- src/concepts/BindConcept.ts | 20 +-- src/concepts/Concept.ts | 24 +-- src/concepts/ConceptIndex.ts | 63 ++++--- src/concepts/ConversionConcept.ts | 12 +- src/concepts/DefaultConcepts.ts | 8 +- src/concepts/FunctionConcept.ts | 18 +- src/concepts/NodeConcept.ts | 31 ++-- src/concepts/StreamConcept.ts | 48 +++--- src/concepts/StructureConcept.ts | 64 ++++--- src/conflicts/BorrowCycle.ts | 12 +- src/conflicts/Conflict.ts | 4 +- src/conflicts/DisallowedInputs.ts | 13 +- src/conflicts/DuplicateName.ts | 22 ++- src/conflicts/DuplicateShare.ts | 22 ++- src/conflicts/DuplicateTypeVariable.ts | 32 ++-- src/conflicts/ExpectedBooleanCondition.ts | 28 +-- src/conflicts/ExpectedColumnBind.ts | 12 +- src/conflicts/ExpectedColumnType.ts | 12 +- src/conflicts/ExpectedEndingExpression.ts | 11 +- src/conflicts/ExpectedSelectName.ts | 12 +- src/conflicts/ExpectedStream.ts | 12 +- src/conflicts/ExtraCell.ts | 20 ++- src/conflicts/IgnoredExpression.ts | 21 ++- src/conflicts/ImpossibleType.ts | 9 +- src/conflicts/IncompatibleCellType.ts | 28 +-- src/conflicts/IncompatibleInput.ts | 31 ++-- src/conflicts/IncompatibleKey.ts | 30 ++-- src/conflicts/IncompatibleType.ts | 27 +-- src/conflicts/IncompleteImplementation.ts | 13 +- src/conflicts/InputListMustBeLast.ts | 10 +- src/conflicts/InvalidRow.ts | 9 +- src/conflicts/MisplacedConversion.ts | 13 +- src/conflicts/MisplacedInput.ts | 10 +- src/conflicts/MisplacedShare.ts | 8 +- src/conflicts/MisplacedThis.ts | 9 +- src/conflicts/MissingCell.ts | 24 +-- src/conflicts/MissingInput.ts | 25 +-- src/conflicts/MissingLanguage.ts | 10 +- src/conflicts/MissingShareLanguages.ts | 10 +- src/conflicts/NoExpression.ts | 12 +- src/conflicts/NotAKeyValue.ts | 23 ++- src/conflicts/NotANumber.ts | 10 +- src/conflicts/NotAnInterface.ts | 12 +- src/conflicts/NotInstantiable.ts | 10 +- src/conflicts/OrderOfOperations.ts | 11 +- src/conflicts/Placeholder.ts | 13 +- src/conflicts/ReferenceCycle.ts | 12 +- src/conflicts/RequiredAfterOptional.ts | 10 +- src/conflicts/UnclosedDelimiter.ts | 17 +- src/conflicts/UnexpectedColumnBind.ts | 25 ++- src/conflicts/UnexpectedEtc.ts | 9 +- src/conflicts/UnexpectedInput.ts | 25 ++- src/conflicts/UnexpectedTypeInput.ts | 32 ++-- src/conflicts/UnexpectedTypeVariable.ts | 11 +- src/conflicts/UnimplementedInterface.ts | 23 +-- src/conflicts/UnknownBorrow.ts | 8 +- src/conflicts/UnknownColumn.ts | 9 +- src/conflicts/UnknownConversion.ts | 14 +- src/conflicts/UnknownInput.ts | 20 ++- src/conflicts/UnknownLanguage.ts | 10 +- src/conflicts/UnknownName.ts | 14 +- src/conflicts/UnknownTypeName.ts | 12 +- src/conflicts/UnparsableConflict.ts | 13 +- src/conflicts/UnusedBind.ts | 9 +- src/db/Database.ts | 3 - src/db/GalleryDatabase.ts | 10 +- src/db/LocalesDatabase.ts | 30 ++-- src/edit/Append.ts | 20 ++- src/edit/Assign.ts | 20 +-- src/edit/Autocomplete.test.ts | 10 +- src/edit/Autocomplete.ts | 18 +- src/edit/Caret.ts | 44 ++--- src/edit/GroupProperties.ts | 16 +- src/edit/OutputExpression.ts | 16 +- src/edit/OutputProperties.ts | 66 +++++--- src/edit/OutputProperty.ts | 6 +- src/edit/OutputPropertyValueSet.ts | 13 +- src/edit/PhraseProperties.ts | 14 +- src/edit/PoseProperties.ts | 24 ++- src/edit/Refer.ts | 6 +- src/edit/Remove.ts | 10 +- src/edit/Replace.ts | 26 +-- src/edit/Revision.ts | 12 +- src/edit/SequenceProperties.ts | 12 +- src/edit/ShapeProperties.ts | 8 +- src/edit/StageProperties.ts | 10 +- src/edit/getShapeProperties.ts | 8 +- src/examples/examples.test.ts | 4 +- src/input/Button.ts | 4 +- src/input/Camera.ts | 4 +- src/input/Chat.ts | 4 +- src/input/Choice.ts | 4 +- src/input/Collision.ts | 4 +- src/input/Key.ts | 4 +- src/input/Motion.ts | 4 +- src/input/Pitch.ts | 4 +- src/input/Placement.ts | 6 +- src/input/Pointer.ts | 4 +- src/input/Random.ts | 4 +- src/input/Time.ts | 4 +- src/input/Volume.ts | 4 +- src/input/Webpage.ts | 3 +- src/locale/DefaultLocale.ts | 3 + src/locale/Locale.ts | 7 +- src/locale/Locales.ts | 74 ++++++++ src/locale/NodeRef.ts | 6 +- src/locale/ValueRef.ts | 8 +- src/locale/concretize.test.ts | 4 +- src/locale/concretize.ts | 19 ++- src/locale/getBind.ts | 13 +- src/locale/getDocLocales.ts | 15 +- src/locale/getInputLocales.ts | 9 +- src/locale/getNameLocales.ts | 8 +- src/models/Moderation.ts | 5 +- src/models/Project.ts | 10 +- src/nodes/AnyType.ts | 6 +- src/nodes/BinaryEvaluate.ts | 37 ++-- src/nodes/Bind.ts | 42 ++--- src/nodes/Block.ts | 25 +-- src/nodes/BooleanLiteral.ts | 14 +- src/nodes/BooleanType.ts | 6 +- src/nodes/Borrow.ts | 25 +-- src/nodes/Branch.ts | 14 +- src/nodes/Changed.ts | 14 +- src/nodes/ConceptLink.ts | 5 +- src/nodes/Concretizer.ts | 4 +- src/nodes/Conditional.ts | 33 ++-- src/nodes/Content.ts | 4 +- src/nodes/ConversionDefinition.ts | 18 +- src/nodes/ConversionType.ts | 6 +- src/nodes/Convert.ts | 22 +-- src/nodes/CycleType.ts | 9 +- src/nodes/Delete.test.ts | 3 +- src/nodes/Delete.ts | 26 +-- src/nodes/Dimension.ts | 10 +- src/nodes/Doc.ts | 6 +- src/nodes/Docs.ts | 10 +- src/nodes/DocumentedExpression.ts | 13 +- src/nodes/Evaluate.ts | 39 +++-- src/nodes/Example.ts | 6 +- src/nodes/ExceptionType.ts | 6 +- src/nodes/Expression.ts | 10 +- src/nodes/ExpressionPlaceholder.ts | 26 +-- src/nodes/FormatedLiteral.test.ts | 3 +- src/nodes/FormattdLiteral.test.ts | 8 +- src/nodes/FormattedLiteral.ts | 16 +- src/nodes/FormattedTranslation.ts | 6 +- src/nodes/FormattedType.ts | 6 +- src/nodes/FunctionDefinition.ts | 20 ++- src/nodes/FunctionType.ts | 10 +- src/nodes/Initial.ts | 13 +- src/nodes/Insert.test.ts | 3 +- src/nodes/Insert.ts | 26 +-- src/nodes/Is.ts | 26 +-- src/nodes/IsLocale.ts | 12 +- src/nodes/KeyValue.ts | 10 +- src/nodes/Language.ts | 5 +- src/nodes/ListAccess.ts | 26 +-- src/nodes/ListLiteral.ts | 25 +-- src/nodes/ListType.ts | 10 +- src/nodes/Literal.ts | 6 +- src/nodes/MapLiteral.ts | 21 ++- src/nodes/MapType.ts | 12 +- src/nodes/Markup.ts | 14 +- src/nodes/Mention.ts | 10 +- src/nodes/Name.ts | 6 +- src/nodes/NameType.ts | 6 +- src/nodes/Names.ts | 5 +- src/nodes/NeverType.ts | 6 +- src/nodes/NoExpressionType.ts | 9 +- src/nodes/Node.ts | 27 +-- src/nodes/NonFunctionType.ts | 9 +- src/nodes/NoneLiteral.ts | 13 +- src/nodes/NoneType.ts | 6 +- src/nodes/NotAType.ts | 14 +- src/nodes/NumberLiteral.ts | 18 +- src/nodes/NumberType.ts | 10 +- src/nodes/Paragraph.ts | 10 +- src/nodes/Previous.ts | 26 +-- src/nodes/Program.test.ts | 9 +- src/nodes/Program.ts | 24 +-- src/nodes/PropertyBind.test.ts | 3 +- src/nodes/PropertyBind.ts | 27 +-- src/nodes/PropertyReference.ts | 31 ++-- src/nodes/Reaction.test.ts | 7 +- src/nodes/Reaction.ts | 32 ++-- src/nodes/Reference.ts | 17 +- src/nodes/Root.ts | 6 +- src/nodes/Row.ts | 6 +- src/nodes/Select.test.ts | 3 +- src/nodes/Select.ts | 28 +-- src/nodes/SetLiteral.ts | 21 ++- src/nodes/SetOrMapAccess.ts | 26 +-- src/nodes/SetType.ts | 10 +- src/nodes/SimpleExpression.ts | 6 +- src/nodes/Source.ts | 5 +- src/nodes/Spread.ts | 8 +- src/nodes/StreamDefinition.ts | 16 +- src/nodes/StreamDefinitionType.ts | 5 +- src/nodes/StreamType.ts | 6 +- src/nodes/StructureDefinition.ts | 27 +-- src/nodes/StructureType.ts | 9 +- src/nodes/TableLiteral.ts | 23 +-- src/nodes/TableType.ts | 6 +- src/nodes/TextLiteral.test.ts | 5 +- src/nodes/TextLiteral.ts | 16 +- src/nodes/TextType.ts | 6 +- src/nodes/This.ts | 14 +- src/nodes/Token.ts | 23 +-- src/nodes/Translation.ts | 6 +- src/nodes/TypeInputs.ts | 6 +- src/nodes/TypePlaceholder.ts | 8 +- src/nodes/TypeVariable.ts | 5 +- src/nodes/TypeVariables.ts | 6 +- src/nodes/UnaryEvaluate.ts | 22 +-- src/nodes/UnenclosedType.ts | 9 +- src/nodes/UnimplementedType.ts | 9 +- src/nodes/UnionType.ts | 12 +- src/nodes/Unit.ts | 10 +- src/nodes/UnknownNameType.ts | 8 +- src/nodes/UnknownType.ts | 19 ++- src/nodes/UnknownVariableType.ts | 9 +- src/nodes/UnparsableExpression.ts | 12 +- src/nodes/UnparsableType.ts | 6 +- src/nodes/Update.test.ts | 3 +- src/nodes/Update.ts | 28 +-- src/nodes/VariableType.ts | 6 +- src/nodes/WebLink.ts | 6 +- src/nodes/Words.ts | 10 +- src/output/Arrangement.ts | 6 +- src/output/Color.ts | 11 +- src/output/DefaultSequences.ts | 16 +- src/output/Direction.ts | 4 +- src/output/Form.ts | 10 +- src/output/Free.ts | 10 +- src/output/Grid.ts | 10 +- src/output/Group.ts | 17 +- src/output/Matter.ts | 4 +- src/output/Output.ts | 8 +- src/output/OutputAnimation.ts | 5 +- src/output/Phrase.ts | 16 +- src/output/Place.ts | 4 +- src/output/Pose.ts | 17 +- src/output/Rebound.ts | 4 +- src/output/RenderContext.ts | 6 +- src/output/Row.ts | 10 +- src/output/Sequence.ts | 9 +- src/output/Shape.ts | 11 +- src/output/Stack.ts | 10 +- src/output/Stage.ts | 19 ++- src/output/Velocity.ts | 4 +- src/output/getOrCreatePlace.ts | 6 +- src/routes/+error.svelte | 6 +- src/routes/+layout.svelte | 19 +-- src/routes/+page.svelte | 34 ++-- src/routes/about/+page.svelte | 6 +- src/routes/galleries/+page.svelte | 8 +- src/routes/gallery/[galleryid]/+page.svelte | 111 ++++++++---- src/routes/learn/+page.svelte | 13 +- src/routes/login/+page.svelte | 159 ++++++++++++------ src/routes/moderate/+page.svelte | 25 ++- src/routes/project/[projectid]/+page.svelte | 7 +- src/routes/projects/+page.svelte | 101 +++++++---- src/routes/rights/+page.svelte | 12 +- src/runtime/Check.ts | 9 +- src/runtime/Evaluator.test.ts | 8 +- src/runtime/Evaluator.ts | 14 +- src/runtime/Finish.ts | 6 +- src/runtime/Halt.ts | 9 +- src/runtime/Initialize.ts | 9 +- src/runtime/Jump.ts | 9 +- src/runtime/JumpIf.ts | 8 +- src/runtime/Next.ts | 9 +- src/runtime/Start.ts | 6 +- src/runtime/StartConversion.ts | 9 +- src/runtime/StartEvaluation.ts | 9 +- src/runtime/StartFinish.ts | 6 +- src/runtime/Step.ts | 4 +- src/runtime/createDefaultShares.ts | 6 +- src/runtime/evaluate.ts | 15 +- src/util/verify-locales.ts | 3 +- src/values/BlankException.ts | 10 +- src/values/BoolValue.ts | 9 +- src/values/ConversionDefinitionValue.ts | 9 +- src/values/ConversionException.ts | 16 +- src/values/CycleException.ts | 14 +- src/values/EvaluationLimitException.ts | 21 ++- src/values/ExceptionValue.ts | 10 +- src/values/FunctionException.ts | 16 +- src/values/FunctionValue.ts | 17 +- src/values/ListValue.ts | 11 +- src/values/MapValue.ts | 11 +- src/values/MarkupValue.ts | 9 +- src/values/MessageException.ts | 6 +- src/values/NameException.ts | 16 +- src/values/NoneValue.ts | 9 +- src/values/NumberValue.ts | 9 +- src/values/ReactionStream.ts | 24 ++- src/values/SetValue.ts | 11 +- src/values/StepLimitException.ts | 10 +- src/values/StreamDefinitionValue.ts | 17 +- src/values/StreamValue.ts | 16 +- src/values/StructureDefinitionValue.ts | 17 +- src/values/StructureValue.ts | 23 ++- src/values/TableValue.ts | 11 +- src/values/TextValue.ts | 9 +- src/values/TypeException.ts | 16 +- src/values/UnimplementedException.ts | 14 +- src/values/UnparsableException.ts | 16 +- src/values/Value.ts | 8 +- src/values/ValueException.ts | 10 +- 396 files changed, 3267 insertions(+), 2455 deletions(-) create mode 100644 src/locale/Locales.ts diff --git a/src/basis/Basis.test.ts b/src/basis/Basis.test.ts index 49e5e23a4..a77c59a30 100644 --- a/src/basis/Basis.test.ts +++ b/src/basis/Basis.test.ts @@ -8,9 +8,9 @@ import UnparsableExpression from '@nodes/UnparsableExpression'; import Project from '../models/Project'; import Example from '../nodes/Example'; import { Basis } from './Basis'; -import DefaultLocale from '../locale/DefaultLocale'; +import DefaultLocale, { DefaultLocales } from '../locale/DefaultLocale'; -const basis = Basis.getLocalizedBasis(DefaultLocale); +const basis = Basis.getLocalizedBasis(DefaultLocales); const source = new Source('basis', ''); const project = Project.make(null, 'test', source, [], DefaultLocale); @@ -66,7 +66,7 @@ function checkBasisNodes(nodes: Node[]) { )}\nPrimary node: ${conflictingNodes.primary.node.toWordplay()}\n\t${ conflict.constructor.name }\n${conflictingNodes.primary.explanation( - basis.locales[0], + basis.locales, context )}` ); diff --git a/src/basis/Basis.ts b/src/basis/Basis.ts index 8643023fd..b49712ee8 100644 --- a/src/basis/Basis.ts +++ b/src/basis/Basis.ts @@ -33,9 +33,10 @@ import { getNameLocales } from '../locale/getNameLocales'; import bootstrapStructure from './StructureBasis'; import { toTokens } from '../parser/toTokens'; import parseType from '../parser/paresType'; +import type Locales from '../locale/Locales'; export class Basis { - readonly locales: Locale[]; + readonly locales: Locales; readonly languages: LanguageCode[]; readonly shares: ReturnType; @@ -45,9 +46,9 @@ export class Basis { */ static readonly Bases: Map = new Map(); - constructor(locales: Locale[]) { + constructor(locales: Locales) { this.locales = locales; - this.languages = locales.map((locale) => locale.language); + this.languages = locales.getLanguages(); this.addStructure('none', bootstrapNone(locales)); this.addStructure('boolean', bootstrapBool(locales)); @@ -62,9 +63,8 @@ export class Basis { this.shares = createDefaultShares(locales); } - static getLocalizedBasis(locales: Locale | Locale[]) { - locales = Array.isArray(locales) ? locales : [locales]; - const languages = locales.map((locale) => locale.language); + static getLocalizedBasis(locales: Locales) { + const languages = locales.getLanguages(); const key = languages.join(','); const basis = Basis.Bases.get(key) ?? new Basis(locales); Basis.Bases.set(key, basis); @@ -160,7 +160,7 @@ export class Basis { } export function createBasisFunction( - locales: Locale[], + locales: Locales, text: (locale: Locale) => FunctionText, typeVars: TypeVariables | undefined, types: (Type | [Type, Expression])[], diff --git a/src/basis/BoolBasis.ts b/src/basis/BoolBasis.ts index 81d96baf7..b37f9caf6 100644 --- a/src/basis/BoolBasis.ts +++ b/src/basis/BoolBasis.ts @@ -13,8 +13,9 @@ import type Locale from '../locale/Locale'; import type { FunctionText, NameAndDoc } from '../locale/Locale'; import type Type from '../nodes/Type'; import AnyType from '../nodes/AnyType'; +import type Locales from '../locale/Locales'; -export default function bootstrapBool(locales: Locale[]) { +export default function bootstrapBool(locales: Locales) { function createBooleanFunction( text: (locale: Locale) => FunctionText, inputs: Type[], diff --git a/src/basis/InternalExpression.ts b/src/basis/InternalExpression.ts index 7388aeb89..4606a0d09 100644 --- a/src/basis/InternalExpression.ts +++ b/src/basis/InternalExpression.ts @@ -9,7 +9,6 @@ import type Context from '@nodes/Context'; import type TypeSet from '@nodes/TypeSet'; import StartFinish from '@runtime/StartFinish'; import SimpleExpression from '@nodes/SimpleExpression'; -import type Locale from '@locale/Locale'; import InternalException from '@values/InternalException'; import Glyphs from '../lore/Glyphs'; import concretize from '../locale/concretize'; @@ -18,6 +17,7 @@ import Start from '@runtime/Start'; import Finish from '@runtime/Finish'; import { toTokens } from '../parser/toTokens'; import parseType from '../parser/paresType'; +import type Locales from '../locale/Locales'; export default class InternalExpression extends SimpleExpression { readonly type: Type; @@ -106,12 +106,15 @@ export default class InternalExpression extends SimpleExpression { return this; } - getNodeLocale(translation: Locale) { - return translation.node.InternalExpression; + getNodeLocale(locales: Locales) { + return locales.get((l) => l.node.InternalExpression); } - getStartExplanations(locale: Locale) { - return concretize(locale, locale.node.InternalExpression.start); + getStartExplanations(locales: Locales) { + return concretize( + locales, + locales.get((l) => l.node.InternalExpression.start) + ); } getGlyphs() { diff --git a/src/basis/Iteration.ts b/src/basis/Iteration.ts index 26dd81a6c..27ede10cf 100644 --- a/src/basis/Iteration.ts +++ b/src/basis/Iteration.ts @@ -1,5 +1,4 @@ import Purpose from '../concepts/Purpose'; -import type Locale from '../locale/Locale'; import concretize from '../locale/concretize'; import Glyphs from '../lore/Glyphs'; import AnyType from '../nodes/AnyType'; @@ -23,6 +22,7 @@ import Next from '@runtime/Next'; import Start from '@runtime/Start'; import type Step from '@runtime/Step'; import Value from '../values/Value'; +import type Locales from '../locale/Locales'; const IterationState = 'state'; @@ -218,23 +218,26 @@ export class Iteration extends Expression { return this; } - getNodeLocale(translation: Locale) { - return translation.node.Iteration; + getNodeLocale(locales: Locales) { + return locales.get((l) => l.node.Iteration); } - getStartExplanations(locale: Locale) { - return concretize(locale, locale.node.Iteration.start); + getStartExplanations(locales: Locales) { + return concretize( + locales, + locales.get((l) => l.node.Iteration.start) + ); } getFinishExplanations( - locale: Locale, + locales: Locales, context: Context, evaluator: Evaluator ) { return concretize( - locale, - locale.node.Iteration.finish, - this.getValueIfDefined(locale, context, evaluator) + locales, + locales.get((l) => l.node.Iteration.finish), + this.getValueIfDefined(locales, context, evaluator) ); } diff --git a/src/basis/ListBasis.ts b/src/basis/ListBasis.ts index ff58954ed..cb7b01511 100644 --- a/src/basis/ListBasis.ts +++ b/src/basis/ListBasis.ts @@ -20,7 +20,6 @@ import { getDocLocales } from '@locale/getDocLocales'; import { getNameLocales } from '@locale/getNameLocales'; import TypeVariable from '@nodes/TypeVariable'; import type Expression from '../nodes/Expression'; -import type Locale from '../locale/Locale'; import NoneLiteral from '../nodes/NoneLiteral'; import NoneValue from '@values/NoneValue'; import { Iteration } from './Iteration'; @@ -34,8 +33,9 @@ import InternalExpression from './InternalExpression'; import ConversionException from '@values/ConversionException'; import ExceptionValue from '@values/ExceptionValue'; import SetType from '../nodes/SetType'; +import type Locales from '../locale/Locales'; -export default function bootstrapList(locales: Locale[]) { +export default function bootstrapList(locales: Locales) { const ListTypeVarNames = getNameLocales( locales, (locale) => locale.basis.List.kind diff --git a/src/basis/MapBasis.ts b/src/basis/MapBasis.ts index 3e252412c..7a346248f 100644 --- a/src/basis/MapBasis.ts +++ b/src/basis/MapBasis.ts @@ -16,7 +16,6 @@ import TypeVariable from '@nodes/TypeVariable'; import type Evaluation from '@runtime/Evaluation'; import type Value from '@values/Value'; import type Expression from '../nodes/Expression'; -import type Locale from '../locale/Locale'; import { createFunction, createInputs } from '../locale/Locale'; import { Iteration } from './Iteration'; import NumberType from '../nodes/NumberType'; @@ -25,8 +24,9 @@ import TextType from '../nodes/TextType'; import SetType from '../nodes/SetType'; import ListType from '../nodes/ListType'; import AnyType from '../nodes/AnyType'; +import type Locales from '../locale/Locales'; -export default function bootstrapMap(locales: Locale[]) { +export default function bootstrapMap(locales: Locales) { const KeyTypeVariableNames = getNameLocales( locales, (locale) => locale.basis.Map.key diff --git a/src/basis/NoneBasis.ts b/src/basis/NoneBasis.ts index 6e1cbebf1..fbc6890d6 100644 --- a/src/basis/NoneBasis.ts +++ b/src/basis/NoneBasis.ts @@ -13,10 +13,11 @@ import type Expression from '../nodes/Expression'; import type Locale from '../locale/Locale'; import type { FunctionText, NameAndDoc } from '../locale/Locale'; import TextType from '../nodes/TextType'; +import type Locales from '../locale/Locales'; -export default function bootstrapNone(locales: Locale[]) { +export default function bootstrapNone(locales: Locales) { function createNoneFunction( - locales: Locale[], + locales: Locales, text: (locale: Locale) => FunctionText, expression: ( requestor: Expression, diff --git a/src/basis/NumberBasis.ts b/src/basis/NumberBasis.ts index f4ac84250..0f76f932a 100644 --- a/src/basis/NumberBasis.ts +++ b/src/basis/NumberBasis.ts @@ -25,8 +25,9 @@ import type Locale from '../locale/Locale'; import type { FunctionText, NameAndDoc } from '../locale/Locale'; import ListType from '../nodes/ListType'; import AnyType from '../nodes/AnyType'; +import type Locales from '../locale/Locales'; -export default function bootstrapNumber(locales: Locale[]) { +export default function bootstrapNumber(locales: Locales) { const subtractNames = getNameLocales( locales, (locale) => locale.basis.Number.function.subtract.inputs[0].names diff --git a/src/basis/SetBasis.ts b/src/basis/SetBasis.ts index 785066ff7..fb22bb246 100644 --- a/src/basis/SetBasis.ts +++ b/src/basis/SetBasis.ts @@ -15,7 +15,6 @@ import { getDocLocales } from '@locale/getDocLocales'; import { getNameLocales } from '@locale/getNameLocales'; import TypeVariable from '@nodes/TypeVariable'; import type Expression from '../nodes/Expression'; -import type Locale from '../locale/Locale'; import { createBind, createFunction, createInputs } from '../locale/Locale'; import { Iteration } from './Iteration'; import NumberType from '../nodes/NumberType'; @@ -23,8 +22,9 @@ import NumberValue from '@values/NumberValue'; import ListType from '../nodes/ListType'; import TextType from '../nodes/TextType'; import AnyType from '../nodes/AnyType'; +import type Locales from '../locale/Locales'; -export default function bootstrapSet(locales: Locale[]) { +export default function bootstrapSet(locales: Locales) { const SetTypeVariableNames = getNameLocales( locales, (locale) => locale.basis.Set.kind diff --git a/src/basis/StructureBasis.ts b/src/basis/StructureBasis.ts index 72d9d9b65..b615b60bb 100644 --- a/src/basis/StructureBasis.ts +++ b/src/basis/StructureBasis.ts @@ -2,7 +2,6 @@ import StructureDefinition from '@nodes/StructureDefinition'; import Block, { BlockKind } from '@nodes/Block'; import { getDocLocales } from '@locale/getDocLocales'; import { getNameLocales } from '@locale/getNameLocales'; -import type Locale from '../locale/Locale'; import { createBasisConversion, createBasisFunction } from './Basis'; import BoolValue from '@values/BoolValue'; import BooleanType from '../nodes/BooleanType'; @@ -13,8 +12,9 @@ import Value from '../values/Value'; import type StructureValue from '../values/StructureValue'; import TextType from '../nodes/TextType'; import TextValue from '../values/TextValue'; +import type Locales from '../locale/Locales'; -export default function bootstrapStructure(locales: Locale[]) { +export default function bootstrapStructure(locales: Locales) { return StructureDefinition.make( getDocLocales(locales, (locale) => locale.basis.Structure.doc), getNameLocales(locales, (locale) => locale.basis.Structure.name), diff --git a/src/basis/TableBasis.ts b/src/basis/TableBasis.ts index 484ea5dce..406c00561 100644 --- a/src/basis/TableBasis.ts +++ b/src/basis/TableBasis.ts @@ -10,7 +10,6 @@ import type Names from '@nodes/Names'; import { getInputLocales as getInputLocales } from '@locale/getInputLocales'; import { getDocLocales } from '@locale/getDocLocales'; import { getNameLocales } from '@locale/getNameLocales'; -import type Locale from '../locale/Locale'; import type Type from '../nodes/Type'; import TableType from '../nodes/TableType'; import TableValue from '../values/TableValue'; @@ -25,8 +24,9 @@ import TextValue from '../values/TextValue'; import TypeVariables from '../nodes/TypeVariables'; import TypeVariable from '../nodes/TypeVariable'; import AnyType from '../nodes/AnyType'; +import type Locales from '../locale/Locales'; -export default function bootstrapTable(locales: Locale[]) { +export default function bootstrapTable(locales: Locales) { /** This type variable represents the StructureDefinition of a row. */ const RowTypeVariable = new TypeVariable( getNameLocales(locales, (locale) => locale.basis.Table.row) @@ -135,7 +135,7 @@ export default function bootstrapTable(locales: Locale[]) { TableType.make(), TextType.make(), (requestor: Expression, table: TableValue) => - new TextValue(requestor, table.toWordplay([])) + new TextValue(requestor, table.toWordplay(locales)) ), ], BlockKind.Structure diff --git a/src/basis/TextBasis.ts b/src/basis/TextBasis.ts index acbe2b425..0f6cc0bfa 100644 --- a/src/basis/TextBasis.ts +++ b/src/basis/TextBasis.ts @@ -17,8 +17,9 @@ import type Locale from '../locale/Locale'; import type { FunctionText, NameAndDoc } from '../locale/Locale'; import ListType from '../nodes/ListType'; import AnyType from '../nodes/AnyType'; +import type Locales from '../locale/Locales'; -export default function bootstrapText(locales: Locale[]) { +export default function bootstrapText(locales: Locales) { function createBinaryTextFunction( functionText: (locale: Locale) => FunctionText, fun: ( diff --git a/src/components/annotations/Annotations.svelte b/src/components/annotations/Annotations.svelte index de314b5e6..0f15bd36c 100644 --- a/src/components/annotations/Annotations.svelte +++ b/src/components/annotations/Annotations.svelte @@ -20,7 +20,7 @@ import type Markup from '../../nodes/Markup'; import concretize from '../../locale/concretize'; import type Source from '../../nodes/Source'; - import { locale, locales } from '../../db/Database'; + import { locales } from '../../db/Database'; export let project: Project; export let evaluator: Evaluator; @@ -55,23 +55,25 @@ { node: node, element: view, - messages: $evaluation?.step - ? $locales.map((locale) => - ($evaluation?.step as Step).getExplanations( - locale, + messages: [ + $evaluation?.step + ? ($evaluation?.step as Step).getExplanations( + $locales, evaluator ) - ) - : evaluator.steppedToNode() && evaluator.isDone() - ? $locales.map((locale) => - concretize( - locale, - locale.node.Program.unevaluated + : evaluator.steppedToNode() && + evaluator.isDone() + ? concretize( + $locales, + $locales.get( + (l) => l.node.Program.unevaluated + ) ) - ) - : $locales.map((locale) => - concretize(locale, locale.node.Program.done) - ), + : concretize( + $locales, + $locales.get((l) => l.node.Program.done) + ), + ], kind: 'step', }, ]; @@ -93,17 +95,17 @@ { node: primary.node, element: getNodeView(primary.node), - messages: $locales.map((locale) => + messages: [ primary.explanation( - locale, + $locales, project.getNodeContext( primary.node ) ?? project.getContext( project.getMain() ) - ) - ), + ), + ], kind: conflict.isMinor() ? ('minor' as const) : ('primary' as const), @@ -116,14 +118,14 @@ { node: secondary.node, element: getNodeView(secondary.node), - messages: $locales.map((locale) => + messages: [ secondary.explanation( - locale, + $locales, project.getNodeContext( secondary.node ) - ) - ), + ), + ], kind: 'secondary' as const, }, ] @@ -188,7 +190,7 @@ -
+
l.ui.conflicts.label)}> {#each Array.from(annotationsByNode.values()) as annotations, index} {/each} diff --git a/src/components/app/CreatorView.svelte b/src/components/app/CreatorView.svelte index c5a1a342c..63ad55bad 100644 --- a/src/components/app/CreatorView.svelte +++ b/src/components/app/CreatorView.svelte @@ -1,6 +1,6 @@
- -

{$locale.ui.widget.loading.message}

+ l.ui.widget.loading.message)} large /> +

{$locales.get((l) => l.ui.widget.loading.message)}