Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/eddow/omni18n
Browse files Browse the repository at this point in the history
  • Loading branch information
eddow committed Jun 18, 2024
2 parents 91d7b6c + c321e91 commit d6acdbc
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
Expand Down
6 changes: 3 additions & 3 deletions docs/interpolation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omni18n",
"version": "1.1.14",
"version": "1.1.15",
"exports": {
".": {
"browser": {
Expand Down
1 change: 1 addition & 0 deletions src/client/interpolation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const formats: Record<'date' | 'number' | 'relative', Record<string, obje
}

export const processors: Record<string, (...args: any[]) => string> = {
// TODO Interpolation should have access to localeFlagsEngine
upper(str: string) {
return str.toUpperCase()
},
Expand Down
2 changes: 1 addition & 1 deletion src/db/fileDb.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion src/tools/cgpt-js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions test/specifics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ describe('specifics', () => {
'<span class="fi fi-be"></span>'
])
})
test('errors', async () => {
// TODO test errors
})
test('fallbacks', async () => {
misses.mockClear()
const { Tp } = localStack({
Expand Down Expand Up @@ -260,7 +257,7 @@ line*/,
isAdmin: true,
hobbies: ["reading", "coding", "swimming"],
address: {city: "New
York", country: "USA"/* -- */}
York", country: \`USA\`/* -- */}
}`
const expected = {
name: 'John',
Expand Down

0 comments on commit d6acdbc

Please sign in to comment.