diff --git a/docs/client.md b/docs/client.md index d8d9805..9cd5b96 100644 --- a/docs/client.md +++ b/docs/client.md @@ -32,7 +32,7 @@ Setting the locales can be done with `i18nClient.setLocales([...])`. ### Other locales -The `I18nClient` also have 2 properties: +The `I18nClient` also has 2 properties: - `timeZone`: A timezone used when displaying dates (if none is specified) with [this format](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) - `currency`: A currency to use when displaying a number with `style: currency` (3-uppercase code: USD, EUR, ...) diff --git a/docs/interpolation.md b/docs/interpolation.md index ed7eb28..8b74e5c 100644 --- a/docs/interpolation.md +++ b/docs/interpolation.md @@ -78,11 +78,11 @@ Object.assign(processors, { Where `TContext` contains mostly the `client` (the object containing all the language specification) The arguments will mainly be strings or object when flat named lists are specified -The syntax to use them is `{processor | arg1 | arg2}`. +The syntax to use them is `{processor:: arg1 | arg2}`. -example: `{upper | $1}` will render the first argument in upper-case +example: `{upper :: $1}` will render the first argument in upper-case -> :information_source: `{$2[upper] | $1}` is also possible, in which case the second argument can both specify a text key, a processor or be defaulted to the `upper` processor. +> :information_source: `{$2[upper] :: $1}` is also possible, in which case the second argument can both specify a text key, a processor or be defaulted to the `upper` processor. #### Casing diff --git a/package.json b/package.json index 80927b0..d57d434 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "omni18n", - "version": "1.1.14", + "version": "1.1.15", "exports": { ".": { "browser": { diff --git a/src/client/interpolation.ts b/src/client/interpolation.ts index d52cbcf..b1559c7 100644 --- a/src/client/interpolation.ts +++ b/src/client/interpolation.ts @@ -30,6 +30,7 @@ export const formats: Record<'date' | 'number' | 'relative', Record string> = { + // TODO Interpolation should have access to localeFlagsEngine upper(str: string) { return str.toUpperCase() }, diff --git a/src/db/fileDb.ts b/src/db/fileDb.ts index bc587d4..8a1dad9 100644 --- a/src/db/fileDb.ts +++ b/src/db/fileDb.ts @@ -1,6 +1,6 @@ import { readFile, stat, writeFile } from 'node:fs/promises' import Defer from '../tools/defer' -import { WorkDictionary, type Locale, type TextKey, type Translation, type Zone } from '../types' +import type { WorkDictionary, Locale, TextKey, Translation, Zone } from '../types' import MemDB from './memDb' import serialization from './serialization' diff --git a/src/tools/cgpt-js.ts b/src/tools/cgpt-js.ts index 33f7416..30a94f4 100644 --- a/src/tools/cgpt-js.ts +++ b/src/tools/cgpt-js.ts @@ -244,7 +244,7 @@ export function parse(jsonString: string): JSONValue { return parseObject() } else if (jsonString[index] === '[') { return parseArray() - } else if (jsonString[index] === '"' || jsonString[index] === "'") { + } else if ('"\'`'.includes(jsonString[index])) { return parseString() } else { return parseLiteral() diff --git a/test/specifics.test.ts b/test/specifics.test.ts index 239b3f5..4fc17d7 100644 --- a/test/specifics.test.ts +++ b/test/specifics.test.ts @@ -119,9 +119,6 @@ describe('specifics', () => { '' ]) }) - test('errors', async () => { - // TODO test errors - }) test('fallbacks', async () => { misses.mockClear() const { Tp } = localStack({ @@ -260,7 +257,7 @@ line*/, isAdmin: true, hobbies: ["reading", "coding", "swimming"], address: {city: "New -York", country: "USA"/* -- */} +York", country: \`USA\`/* -- */} }` const expected = { name: 'John',