-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* +pages * autotest+emedware * integrations * auto * test timezone * v4 * doc-ing * prettier
- Loading branch information
Showing
26 changed files
with
1,247 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18, 20, 21] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm install | ||
- run: npm run build | ||
- run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
node_modules | ||
test | ||
/node_modules | ||
/test | ||
/coverage | ||
/docs | ||
.* | ||
*.config.js | ||
*.config.json | ||
*.config.json | ||
.gitignore | ||
/.svelte-kit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# OmnI18n | ||
|
||
[Overview](../README.md) | ||
|
||
> :warning: **Work in progress!** | ||
Projects using OmnI18n use it in 4 layers | ||
|
||
1. [The `client`](./client.md): The client manages the cache and download along with text retrieval and interpolation | ||
2. (optional) The HTTP or any other layer. This part is implemented by the user | ||
3. The `server`: The server exposes functions to interact with the languages | ||
4. The `database`: A class implementing some interface that interacts directly with a database |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
theme: jekyll-theme-leap-day |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Client part | ||
|
||
The client part `I18nClient` is usually instantiated once per client. | ||
|
||
For instance, in the browser for an SPA is is instantiated once for the whole web-application lifetime, while on the server-side for SSR, it might be instantiated once per request or per session. | ||
|
||
## Interactions and configurations | ||
|
||
### With the server | ||
|
||
```ts | ||
I18nClient(locales: OmnI18n.Locale[], condense: OmnI18n.Condense, onModification?: OmnI18n.OnModification) | ||
``` | ||
|
||
- `locales`: A list of locales: from preferred to fallback | ||
- `condense`: A function that will query the server for the condensed dictionary | ||
- `onModification`: A function that will be called when the dictionary is modified | ||
|
||
```ts | ||
const client = new I18nClient(['fr', 'en'], server.condense, frontend.refreshTexts) | ||
``` | ||
|
||
### Global settings | ||
|
||
These are variables you can import and modify: | ||
|
||
```ts | ||
import { reports, formats, processors } from 'omni18n' | ||
``` | ||
|
||
#### `reports` | ||
|
||
Reporting mechanism in case of problem. They both take an argument of type `TContext` describing mainly the client and the key where the problem occurred | ||
|
||
```ts | ||
export interface TContext { | ||
key: string | ||
zones: string[] | ||
client: I18nClient | ||
} | ||
``` | ||
|
||
> If texts might be displayed before loading is complete, make sure `onModification` has been specified as it will be called when the translations will be provided | ||
These reports will: | ||
|
||
- have any side effect, like logging or making a request that will log | ||
- return a string that will be used instead of the expected translation | ||
|
||
`reports` contain: | ||
|
||
- A missing key report | ||
|
||
```ts | ||
reports.missing = ({ key, client }: TContext, fallback?: string) => { | ||
// report | ||
return fallback ?? `[${key}]` | ||
} | ||
``` | ||
|
||
- A "missing key while loading" report | ||
This one is called only when the client is in a loading state. If `onModification` was specified, it will be called once loaded. If not, the client will automatically check all the keys that went through this error to check them again. | ||
|
||
```ts | ||
reports.loading = ({ client }: TContext) => '...' | ||
``` | ||
|
||
- An interpolation error | ||
When interpolating, an error calls this report with a textual description and some specifications depending on the error. | ||
|
||
> The specification is json-able _except_ in the case of `error: "Error in processor"`, in which case `spec.error` is whatever had been thrown and might be an `Error` or `Exception` | ||
```ts | ||
reports.error = ({ key, client }: TContext, error: string, spec: object) => { | ||
// report | ||
return '[!error!]' | ||
} | ||
``` | ||
|
||
#### `formats` | ||
|
||
#### `processors` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Part 2 | ||
|
||
[root](/) | ||
|
||
[local root](./) | ||
|
||
[index](README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.