Skip to content

Commit

Permalink
ref svelte4
Browse files Browse the repository at this point in the history
  • Loading branch information
eddow committed May 16, 2024
1 parent c4a3ef7 commit d845993
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ Or the [object-oriented way](./docs/client.md#oo-reporting) by overriding these
missing(key: string, fallback: Translation | undefined, zones: Zone[]): string
error(key: string, error: string, spec: object, zones: Zone[]): string
```
## Integrations

- [Svelte4](https://github.com/eddow/omni18n-svelte4)

## TODO

Expand Down
13 changes: 12 additions & 1 deletion docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ For instance, in the browser for an SPA is is instantiated once for the whole we

In order to acquire translations, the client just has to `enter` a zone to retrieve a [Translator](./translator.md)

## With the server
## Construction

```ts
I18nClient(locales: Locale[], condense: Condense, onModification?: OnModification)
Expand All @@ -26,6 +26,13 @@ Locales default to the more generic ones. Here, we can give several for fall-bac

If the locales `['fr-CA', 'en-UK', 'de-DE']` are given, the actual list of locales that will be used is `['fr-CA', 'fr', '', 'en-UK', 'en', 'de-DE', 'de']`. The `missing` report will be called when the used locale is english or german.

### Other locales

The `I18nClient` also have 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, ...)

## Reports

There are two ways to manage reports. There are also two report types : missing and error. The first one is for when a key is missing, the second one only happens when interpolating.
Expand Down Expand Up @@ -93,3 +100,7 @@ When the application knows well it enters several zones while doing an action (l
For this, **after** SSR-rendering, `payload = SSC.getPartialLoad(excludedZones: Zone[] = [])` can be called with the list of zones the CSC **already** possess. It will return a completely json-able in a compact format of the loaded dictionary

This partial answer can be conveyed in the answer with the action' results (especially useful in a page load action) and given to the CSC with `CSC.usePartial(payload)`

## Overriding `interpolate`

`I18nClient.interpolate` is called on _each_ translation, and can be used to add a transformation or have a list of "last 20 translations" in the translator's UI
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.5",
"version": "1.1.6",
"exports": {
"./client": {
"import": "./lib/esm/client.js",
Expand Down

0 comments on commit d845993

Please sign in to comment.