From 7cce01d64075cb8026c89342e589c3db38b421de Mon Sep 17 00:00:00 2001 From: Jon Imperiosi Date: Thu, 14 Nov 2024 18:15:56 -0800 Subject: [PATCH] Project import generated by Copybara PiperOrigin-RevId: 696715651 --- data/localization/test.xlb | 25 ++++++++++++++++++++ lit-localize.json | 3 ++- package.json | 3 ++- scripts/gen-test-locale.ts | 44 +++++++++++++++++++++++++++++++++++ src/generated/locale-codes.ts | 2 ++ src/generated/locales/test.ts | 44 +++++++++++++++++++++++++++++++++++ 6 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 data/localization/test.xlb create mode 100644 scripts/gen-test-locale.ts create mode 100644 src/generated/locales/test.ts diff --git a/data/localization/test.xlb b/data/localization/test.xlb new file mode 100644 index 0000000..d327b29 --- /dev/null +++ b/data/localization/test.xlb @@ -0,0 +1,25 @@ + + + + P̂́âĝ́ê ŝ́êt̂́t̂î́n̂ĝ́ŝ + Ŝ́l̂ốt̂ ŝ́êt̂́t̂î́n̂ĝ́ŝ + Ốût̂́p̂û́t̂ ŝ́êt̂́t̂î́n̂ĝ́ŝ + P̂́r̂î́v̂ấĉŷ́ + Ŝ́în̂́ĝl̂́ê R̂́êq̂́ûếŝt̂́ Ấr̂ĉ́ĥî́t̂ếĉt̂́ûr̂́ê (Ŝ́R̂Ấ) + P̂́âĝ́ê-l̂́êv̂́êl̂́ t̂́âr̂́ĝết̂î́n̂ĝ́ + L̂́îm̂́ît̂́êd̂́ ấd̂ŝ́ + N̂́ôn̂́-p̂́êr̂́ŝốn̂ấl̂î́ẑếd̂ ấd̂ŝ́ + R̂́êŝ́t̂r̂́îĉ́t̂ d̂́ât̂́â p̂́r̂ốĉếŝŝ́în̂́ĝ + Ĉ́ĥî́l̂d̂́-d̂́îr̂́êĉ́t̂ếd̂ t̂́r̂ếât̂́m̂ến̂t̂́ + Û́n̂d̂́êr̂́ t̂́ĥế ấĝế ốf̂ ĉ́ôn̂́ŝến̂t̂́ + Ŝ́âm̂́p̂l̂́ê t̂́êm̂́p̂l̂́ât̂́ê + Ốût̂́p̂û́t̂ f̂́ôr̂́m̂ất̂ + Ấn̂ĉ́ĥốr̂ ấd̂ (b̂́ôt̂́t̂ốm̂) + Ấn̂ĉ́ĥốr̂ ấd̂ (t̂́ôp̂́) + Ĝ́âm̂́în̂́ĝ î́n̂t̂́êr̂́ŝt̂́ît̂́îấl̂ ấd̂ + R̂́êŵ́âr̂́d̂ếd̂ ấd̂ + Ŝ́îd̂́ê r̂́âî́l̂ ấd̂ (l̂́êf̂́t̂) + Ŝ́îd̂́ê r̂́âî́l̂ ấd̂ (r̂́îĝ́ĥt̂́) + Ŵ́êb̂́ î́n̂t̂́êr̂́ŝt̂́ît̂́îấl̂ ấd̂ + + diff --git a/lit-localize.json b/lit-localize.json index 7c2890e..8c8b49a 100644 --- a/lit-localize.json +++ b/lit-localize.json @@ -21,7 +21,8 @@ "tr", "vi", "zh-cn", - "zh-tw" + "zh-tw", + "test" ], "tsConfig": "./tsconfig.json", "output": { diff --git a/package.json b/package.json index 1b41a84..d05c3c9 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ }, "scripts": { "build": "npm run build:l10n && npm run fix && npm run build:ts && npm run build:rollup", - "build:l10n": "lit-localize extract && lit-localize build", + "build:l10n": "lit-localize extract && npm run build:l10n-test && lit-localize build", + "build:l10n-test": "npx -y tsx@latest scripts/gen-test-locale.ts", "build:ts": "tsc", "build:rollup": "rollup -c", "fix": "gts fix", diff --git a/scripts/gen-test-locale.ts b/scripts/gen-test-locale.ts new file mode 100644 index 0000000..a23d80b --- /dev/null +++ b/scripts/gen-test-locale.ts @@ -0,0 +1,44 @@ +/** + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as fs from 'fs'; +import * as path from 'path'; +import {fileURLToPath} from 'url'; + +const INPUT_LOCALE = 'en'; +const OUTPUT_LOCALE = 'test'; + +const CURRENT_DIR = path.dirname(fileURLToPath(import.meta.url)); +const XLB_DIR = path.resolve(CURRENT_DIR, '../data/localization'); +const INPUT_XLB = path.join(XLB_DIR, `${INPUT_LOCALE}.xlb`); +const OUTPUT_XLB = path.join(XLB_DIR, `${OUTPUT_LOCALE}.xlb`); + +(() => { + const inputContent = fs.readFileSync(INPUT_XLB).toString(); + + const outputContent = inputContent + .replace(/()(.+)(<\/msg>)/gim, (match, p1, p2, p3) => { + // Add alternating diacritical marks to each character. + // First regex replaces odd characters, second replaces even. + let accentedStr = p2.replace(/([a-z])([a-z])?/gim, '$1\u0301$2'); + accentedStr = accentedStr.replace(/([a-z])/gim, '$1\u0302'); + return `${p1}${accentedStr}${p3}`; + }) + .replace(`locale="${INPUT_LOCALE}"`, `locale="${OUTPUT_LOCALE}"`); + + const output = fs.createWriteStream(OUTPUT_XLB); + output.write(outputContent); +})(); diff --git a/src/generated/locale-codes.ts b/src/generated/locale-codes.ts index 4f1fb63..aff3a0d 100644 --- a/src/generated/locale-codes.ts +++ b/src/generated/locale-codes.ts @@ -42,6 +42,7 @@ export const targetLocales = [ 'pl', 'pt-br', 'ru', + 'test', 'th', 'tr', 'vi', @@ -69,6 +70,7 @@ export const allLocales = [ 'pl', 'pt-br', 'ru', + 'test', 'th', 'tr', 'vi', diff --git a/src/generated/locales/test.ts b/src/generated/locales/test.ts new file mode 100644 index 0000000..55aa432 --- /dev/null +++ b/src/generated/locales/test.ts @@ -0,0 +1,44 @@ +/** + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Do not modify this file by hand! +// Re-generate this file by running lit-localize + +/* eslint-disable no-irregular-whitespace */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export const templates = { + s09c694b6602d365d: 'Ŝ́îd̂́ê r̂́âî́l̂ ấd̂ (l̂́êf̂́t̂)', + s0eb106f4b9813ad3: 'N̂́ôn̂́-p̂́êr̂́ŝốn̂ấl̂î́ẑếd̂ ấd̂ŝ́', + s1163c710c6c9bccf: 'Ĝ́âm̂́în̂́ĝ î́n̂t̂́êr̂́ŝt̂́ît̂́îấl̂ ấd̂', + s267a52c34c200ef0: 'Ŝ́în̂́ĝl̂́ê R̂́êq̂́ûếŝt̂́ Ấr̂ĉ́ĥî́t̂ếĉt̂́ûr̂́ê (Ŝ́R̂Ấ)', + s3132d1a0580760bc: 'Ĉ́ĥî́l̂d̂́-d̂́îr̂́êĉ́t̂ếd̂ t̂́r̂ếât̂́m̂ến̂t̂́', + s4535f519744108bf: 'Ốût̂́p̂û́t̂ f̂́ôr̂́m̂ất̂', + s5bf3f3d517569ebd: 'Ấn̂ĉ́ĥốr̂ ấd̂ (b̂́ôt̂́t̂ốm̂)', + s710f900ef624e363: 'Ấn̂ĉ́ĥốr̂ ấd̂ (t̂́ôp̂́)', + s758d8c59379ea482: 'P̂́âĝ́ê-l̂́êv̂́êl̂́ t̂́âr̂́ĝết̂î́n̂ĝ́', + s77b0113eae08368b: 'Ŝ́âm̂́p̂l̂́ê t̂́êm̂́p̂l̂́ât̂́ê', + s7b5fa742d13b462e: 'Ŝ́l̂ốt̂ ŝ́êt̂́t̂î́n̂ĝ́ŝ', + sb457d189f407a5a6: 'R̂́êŝ́t̂r̂́îĉ́t̂ d̂́ât̂́â p̂́r̂ốĉếŝŝ́în̂́ĝ', + sc907ffeeafb021d1: 'Ốût̂́p̂û́t̂ ŝ́êt̂́t̂î́n̂ĝ́ŝ', + sccb7f7246c10ecb6: 'Ŝ́îd̂́ê r̂́âî́l̂ ấd̂ (r̂́îĝ́ĥt̂́)', + sd5ac53cfd233dbcb: 'L̂́îm̂́ît̂́êd̂́ ấd̂ŝ́', + se78c02e9a98a0f47: 'P̂́r̂î́v̂ấĉŷ́', + secff207571282402: 'Ŵ́êb̂́ î́n̂t̂́êr̂́ŝt̂́ît̂́îấl̂ ấd̂', + sefe480470a2c783c: 'R̂́êŵ́âr̂́d̂ếd̂ ấd̂', + sf915707accde585c: 'Û́n̂d̂́êr̂́ t̂́ĥế ấĝế ốf̂ ĉ́ôn̂́ŝến̂t̂́', + sf93d227444bc5687: 'P̂́âĝ́ê ŝ́êt̂́t̂î́n̂ĝ́ŝ', +};