Skip to content

Commit

Permalink
Switch id prefix from 0 to a
Browse files Browse the repository at this point in the history
  • Loading branch information
aomarks committed Dec 4, 2020
1 parent b67bd46 commit 9933ec6
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 41 deletions.
6 changes: 3 additions & 3 deletions packages/localize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Run `lit-localize` to extract all localizable templates and generate an XLIFF
file, a format which is supported by many localization tools and services:

```xml
<trans-unit id="0h3c44aff2d5f5ef6b">
<trans-unit id="ah3c44aff2d5f5ef6b">
<source>Hello <ph id="0">&lt;b></ph>World<ph id="1">&lt;/b></ph>!</source>
<!-- target tag added by your localization process -->
<target>Hola <ph id="0">&lt;b></ph>Mundo<ph id="1">&lt;/b></ph>!</target>
Expand Down Expand Up @@ -165,7 +165,7 @@ lit-localize supports two output modes: _transform_ and _runtime_.
into `<ph>` tags.
```xml
<trans-unit id="0h3c44aff2d5f5ef6b">
<trans-unit id="ah3c44aff2d5f5ef6b">
<source>Hello <ph id="0">&lt;b></ph>World<ph id="1">&lt;/b></ph>!</source>
</trans-unit>
```
Expand All @@ -175,7 +175,7 @@ lit-localize supports two output modes: _transform_ and _runtime_.
this tag by feeding it this XLIFF file.
```xml
<trans-unit id="0h3c44aff2d5f5ef6b">
<trans-unit id="ah3c44aff2d5f5ef6b">
<source>Hello <ph id="0">&lt;b></ph>World<ph id="1">&lt;/b></ph>!</source>
<target>Hola <ph id="0">&lt;b></ph>Mundo<ph id="1">&lt;/b></ph>!</target>
</trans-unit>
Expand Down
3 changes: 1 addition & 2 deletions packages/localize/examples/runtime/src/locales/es-419.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

export const templates = {
'0h3c44aff2d5f5ef6b': html`Hola <b>Mundo</b>!`,
'ah3c44aff2d5f5ef6b': html`Hola <b>Mundo</b>!`,
};

3 changes: 1 addition & 2 deletions packages/localize/examples/runtime/src/locales/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

export const templates = {
'0h3c44aff2d5f5ef6b': html`你好, <b>世界!</b>`,
'ah3c44aff2d5f5ef6b': html`你好, <b>世界!</b>`,
};

2 changes: 1 addition & 1 deletion packages/localize/examples/runtime/xliff/es-419.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<xliff version="1.2" xmlns="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd">
<file target-language="es-419" source-language="en" original="lit-localize-inputs" datatype="plaintext">
<body>
<trans-unit id="0h3c44aff2d5f5ef6b">
<trans-unit id="ah3c44aff2d5f5ef6b">
<source>Hello <ph id="0">&lt;b></ph>World<ph id="1">&lt;/b></ph>!</source>
<target>Hola <ph id="0">&lt;b></ph>Mundo<ph id="1">&lt;/b></ph>!</target>
</trans-unit>
Expand Down
2 changes: 1 addition & 1 deletion packages/localize/examples/runtime/xliff/zh_CN.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<xliff version="1.2" xmlns="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd">
<file target-language="zh_CN" source-language="en" original="lit-localize-inputs" datatype="plaintext">
<body>
<trans-unit id="0h3c44aff2d5f5ef6b">
<trans-unit id="ah3c44aff2d5f5ef6b">
<source>Hello <ph id="0">&lt;b></ph>World<ph id="1">&lt;/b></ph>!</source>
<target>你好, <ph id="0">&lt;b></ph>世界!<ph id="1">&lt;/b></ph></target>
</trans-unit>
Expand Down
2 changes: 1 addition & 1 deletion packages/localize/examples/transform/xliff/es-419.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<xliff version="1.2" xmlns="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd">
<file target-language="es-419" source-language="en" original="lit-localize-inputs" datatype="plaintext">
<body>
<trans-unit id="0h3c44aff2d5f5ef6b">
<trans-unit id="ah3c44aff2d5f5ef6b">
<source>Hello <ph id="0">&lt;b></ph>World<ph id="1">&lt;/b></ph>!</source>
<target>Hola <ph id="0">&lt;b></ph>Mundo<ph id="1">&lt;/b></ph>!</target>
</trans-unit>
Expand Down
2 changes: 1 addition & 1 deletion packages/localize/examples/transform/xliff/zh_CN.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<xliff version="1.2" xmlns="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd">
<file target-language="zh_CN" source-language="en" original="lit-localize-inputs" datatype="plaintext">
<body>
<trans-unit id="0h3c44aff2d5f5ef6b">
<trans-unit id="ah3c44aff2d5f5ef6b">
<source>Hello <ph id="0">&lt;b></ph>World<ph id="1">&lt;/b></ph>!</source>
<target>你好, <ph id="0">&lt;b></ph>世界!<ph id="1">&lt;/b></ph></target>
</trans-unit>
Expand Down
6 changes: 3 additions & 3 deletions packages/localize/src/tests/analysis.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ test('string message (auto ID)', (t) => {
`;
checkAnalysis(t, src, [
{
name: '0s3d58dee72d4e0c27',
name: 'as3d58dee72d4e0c27',
contents: ['Hello World'],
},
]);
Expand Down Expand Up @@ -123,7 +123,7 @@ test('HTML message (auto ID)', (t) => {
`;
checkAnalysis(t, src, [
{
name: '0hc468c061c2d171f4',
name: 'ahc468c061c2d171f4',
contents: [
{untranslatable: '<b>'},
'Hello World',
Expand Down Expand Up @@ -171,7 +171,7 @@ test('parameterized string message (auto ID)', (t) => {
`;
checkAnalysis(t, src, [
{
name: '0saed7d3734ce7f09d',
name: 'asaed7d3734ce7f09d',
contents: ['Hello ', {untranslatable: '${name}'}],
params: ['name'],
},
Expand Down
6 changes: 3 additions & 3 deletions packages/localize/src_client/id-generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const HASH_DELIMITER = String.fromCharCode(30);
* Id scheme version prefix to distinguish this implementation from potential
* changes in the future.
*/
const VERSION_PREFIX = '0';
const VERSION_PREFIX = 'a';

/**
* Id prefix on html-tagged templates to distinguish e.g. `<b>x</b>` from
Expand All @@ -43,11 +43,11 @@ const STRING_PREFIX = 's';
* Example:
* Template: html`Hello <b>${who}</b>!`
* Params: ["Hello <b>", "</b>!"], true
* Output: 0h82ccc38d4d46eaa9
* Output: ah82ccc38d4d46eaa9
*
* The ID is constructed as:
*
* [0] Version number indicating this ID generation scheme.
* [0] Version indicator for this ID generation scheme ("a").
* [1] Kind of template: [h]tml or [s]tring.
* [2,17] 64-bit FNV-1a hash hex digest of the template strings, where each
* string is UTF-8 encoded and delineated by an ASCII "record separator"
Expand Down
8 changes: 4 additions & 4 deletions packages/localize/src_client/tests/lit-localize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ suite('lit-localize', () => {
suite('auto ID', () => {
const autoSpanishModule = {
templates: {
'0s8c0ec8d1fb9e6e32': 'Hola Mundo!',
'0s00ad08ebae1e0f74': (name: string) => `Hola ${name}!`,
'0h3c44aff2d5f5ef6b': html`Hola <b>Mundo</b>!`,
'0h82ccc38d4d46eaa9': (name: string) => html`Hola <b>${name}</b>!`,
as8c0ec8d1fb9e6e32: 'Hola Mundo!',
as00ad08ebae1e0f74: (name: string) => `Hola ${name}!`,
ah3c44aff2d5f5ef6b: html`Hola <b>Mundo</b>!`,
ah82ccc38d4d46eaa9: (name: string) => html`Hola <b>${name}</b>!`,
},
};

Expand Down
8 changes: 4 additions & 4 deletions packages/localize/testdata/xliff/goldens/tsout/es-419.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {html} from 'lit-html';
/* eslint-disable @typescript-eslint/no-explicit-any */

export const templates = {
'0h3c44aff2d5f5ef6b': html`Hola <b>Mundo</b>!`,
'0h82ccc38d4d46eaa9': (name: any) => html`Hola <b>${name}</b>!`,
'0s00ad08ebae1e0f74': (name: any) => `Hola ${name}!`,
'0s8c0ec8d1fb9e6e32': `Hola Mundo!`,
ah3c44aff2d5f5ef6b: html`Hola <b>Mundo</b>!`,
ah82ccc38d4d46eaa9: (name: any) => html`Hola <b>${name}</b>!`,
as00ad08ebae1e0f74: (name: any) => `Hola ${name}!`,
as8c0ec8d1fb9e6e32: `Hola Mundo!`,
comment: html`Hola <b><!-- comment -->Mundo!</b>`,
lit: html`Hola <b><i>Galaxia!</i></b>`,
lit_variables_1: (url: any, name: any) =>
Expand Down
8 changes: 4 additions & 4 deletions packages/localize/testdata/xliff/goldens/tsout/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const templates = {
<i>y</i>
<b>${x}</b>`,
comment: html`Hello <b><!-- comment -->World!</b>`,
'0s8c0ec8d1fb9e6e32': `Hello World!`,
'0s00ad08ebae1e0f74': (name: any) => `Hello ${name}!`,
'0h3c44aff2d5f5ef6b': html`Hello <b>World</b>!`,
'0h82ccc38d4d46eaa9': (name: any) => html`Hello <b>${name}</b>!`,
as8c0ec8d1fb9e6e32: `Hello World!`,
as00ad08ebae1e0f74: (name: any) => `Hello ${name}!`,
ah3c44aff2d5f5ef6b: html`Hello <b>World</b>!`,
ah82ccc38d4d46eaa9: (name: any) => html`Hello <b>${name}</b>!`,
};
8 changes: 4 additions & 4 deletions packages/localize/testdata/xliff/goldens/xliff/es-419.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@
<source>Hello <ph id="0">&lt;b>&lt;!-- comment --></ph>World!<ph id="1">&lt;/b></ph></source>
<target>Hola <ph id="0">&lt;b>&lt;!-- comment --></ph>Mundo!<ph id="1">&lt;/b></ph></target>
</trans-unit>
<trans-unit id="0s8c0ec8d1fb9e6e32">
<trans-unit id="as8c0ec8d1fb9e6e32">
<source>Hello World!</source>
<target>Hola Mundo!</target>
</trans-unit>
<trans-unit id="0s00ad08ebae1e0f74">
<trans-unit id="as00ad08ebae1e0f74">
<source>Hello <ph id="0">${name}</ph>!</source>
<target>Hola <ph id="0">${name}</ph>!</target>
</trans-unit>
<trans-unit id="0h3c44aff2d5f5ef6b">
<trans-unit id="ah3c44aff2d5f5ef6b">
<source>Hello <ph id="0">&lt;b></ph>World<ph id="1">&lt;/b></ph>!</source>
<target>Hola <ph id="0">&lt;b></ph>Mundo<ph id="1">&lt;/b></ph>!</target>
</trans-unit>
<trans-unit id="0h82ccc38d4d46eaa9">
<trans-unit id="ah82ccc38d4d46eaa9">
<source>Hello <ph id="0">&lt;b>${name}&lt;/b></ph>!</source>
<target>Hola <ph id="0">&lt;b>${name}&lt;/b></ph>!</target>
</trans-unit>
Expand Down
8 changes: 4 additions & 4 deletions packages/localize/testdata/xliff/goldens/xliff/zh_CN.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
<trans-unit id="comment">
<source>Hello <ph id="0">&lt;b>&lt;!-- comment --></ph>World!<ph id="1">&lt;/b></ph></source>
</trans-unit>
<trans-unit id="0s8c0ec8d1fb9e6e32">
<trans-unit id="as8c0ec8d1fb9e6e32">
<source>Hello World!</source>
</trans-unit>
<trans-unit id="0s00ad08ebae1e0f74">
<trans-unit id="as00ad08ebae1e0f74">
<source>Hello <ph id="0">${name}</ph>!</source>
</trans-unit>
<trans-unit id="0h3c44aff2d5f5ef6b">
<trans-unit id="ah3c44aff2d5f5ef6b">
<source>Hello <ph id="0">&lt;b></ph>World<ph id="1">&lt;/b></ph>!</source>
</trans-unit>
<trans-unit id="0h82ccc38d4d46eaa9">
<trans-unit id="ah82ccc38d4d46eaa9">
<source>Hello <ph id="0">&lt;b>${name}&lt;/b></ph>!</source>
</trans-unit>
</body>
Expand Down
8 changes: 4 additions & 4 deletions packages/localize/testdata/xliff/input/xliff/es-419.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@
<source>Hello <ph id="0">&lt;b>&lt;!-- comment --></ph>World!<ph id="1">&lt;/b></ph></source>
<target>Hola <ph id="0">&lt;b>&lt;!-- comment --></ph>Mundo!<ph id="1">&lt;/b></ph></target>
</trans-unit>
<trans-unit id="0s8c0ec8d1fb9e6e32">
<trans-unit id="as8c0ec8d1fb9e6e32">
<source>Hello World!</source>
<target>Hola Mundo!</target>
</trans-unit>
<trans-unit id="0s00ad08ebae1e0f74">
<trans-unit id="as00ad08ebae1e0f74">
<source>Hello <ph id="0">${name}</ph>!</source>
<target>Hola <ph id="0">${name}</ph>!</target>
</trans-unit>
<trans-unit id="0h3c44aff2d5f5ef6b">
<trans-unit id="ah3c44aff2d5f5ef6b">
<source>Hello <ph id="0">&lt;b></ph>World<ph id="1">&lt;/b></ph>!</source>
<target>Hola <ph id="0">&lt;b></ph>Mundo<ph id="1">&lt;/b></ph>!</target>
</trans-unit>
<trans-unit id="0h82ccc38d4d46eaa9">
<trans-unit id="ah82ccc38d4d46eaa9">
<source>Hello <ph id="0">&lt;b>${name}&lt;/b></ph>!</source>
<target>Hola <ph id="0">&lt;b>${name}&lt;/b></ph>!</target>
</trans-unit>
Expand Down

0 comments on commit 9933ec6

Please sign in to comment.