From 0de7ab87a54211421cb9e4076111f19f68d85179 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 26 Mar 2021 19:26:35 +1000 Subject: [PATCH] drop legacy enum from ts/ --- ts/lib/genfluent.py | 13 ------------- ts/lib/i18n.ts | 12 +----------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/ts/lib/genfluent.py b/ts/lib/genfluent.py index d9a855719..e4b3c1dfb 100644 --- a/ts/lib/genfluent.py +++ b/ts/lib/genfluent.py @@ -17,18 +17,6 @@ class Variable(TypedDict): kind: Literal["Any", "Int", "String", "Float"] -def legacy_enum() -> str: - out = ["export enum LegacyEnum {"] - for module in modules: - for translation in module["translations"]: - key = stringcase.constcase(translation["key"]) - value = module["index"] * 1000 + translation["index"] - out.append(f" {key} = {value},") - - out.append("}") - return "\n".join(out) + "\n" - - def methods() -> str: out = [ "export class GeneratedTranslations {", @@ -93,7 +81,6 @@ def typescript_arg_name(arg: Variable) -> str: out = "" -out += legacy_enum() out += methods() diff --git a/ts/lib/i18n.ts b/ts/lib/i18n.ts index eea12ce81..f663030d5 100644 --- a/ts/lib/i18n.ts +++ b/ts/lib/i18n.ts @@ -3,7 +3,7 @@ import "intl-pluralrules"; import { FluentBundle, FluentResource, FluentNumber } from "@fluent/bundle/compat"; -import { LegacyEnum, GeneratedTranslations } from "anki/i18n_generated"; +import { GeneratedTranslations } from "anki/i18n_generated"; type RecordVal = number | string | FluentNumber; @@ -23,7 +23,6 @@ function formatNumbers(args?: Record): void { export class I18n extends GeneratedTranslations { bundles: FluentBundle[] = []; langs: string[] = []; - TR = LegacyEnum; translate(key: string, args: Record): string { formatNumbers(args); @@ -36,11 +35,6 @@ export class I18n extends GeneratedTranslations { return `missing key: ${key}`; } - tr(id: LegacyEnum, args?: Record): string { - const key = this.keyName(id); - return this.translate(key, args || {}); - } - supportsVerticalText(): boolean { const firstLang = this.bundles[0].locales[0]; return ( @@ -69,10 +63,6 @@ export class I18n extends GeneratedTranslations { weekday: "narrow", }); } - - private keyName(msg: LegacyEnum): string { - return this.TR[msg].toLowerCase().replace(/_/g, "-"); - } } export async function setupI18n(): Promise {