-
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.
- Loading branch information
Showing
14 changed files
with
228 additions
and
30 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
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,12 +1,12 @@ | ||
# OmnI18n | ||
|
||
[Overview](https://github.com/emedware/omni18n/blob/main/README.md) | ||
The first document presents an [overview](../README.md), here is a more detailed description | ||
|
||
> :warning: **Work in progress!** | ||
> :warning: **Work in progress!**. Remaining: server, DB, interpolation | ||
Projects using OmnI18n use it in 4 layers | ||
|
||
1. [The `client`](./client.md): The client manages the cache and download along with providing [`Translator`s](./translator.md) | ||
1. [The `client`](./client.md): The client manages the cache and download along with providing [`Translator`s](./translator.md) that will [interpolate](./interpolation.md) | ||
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 | ||
3. [The `server`](./server.md): The server exposes functions to interact with the languages | ||
4. [The `database`](./db.md): A class implementing some interface that interacts directly with a database |
This file was deleted.
Oops, something went wrong.
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,71 @@ | ||
# Database interface | ||
|
||
## Structure | ||
|
||
The main structure is `key -> translations`. In SQL, it would be translated as 2 tables: | ||
|
||
- One for the key, the text-key - like "msg.greet" - being the primary key | ||
- One for the translations, where the primary key is the couple (text-key, locale) | ||
|
||
In mongo or json-oriented DB, a key object could directly give a list of translations `locale -> text` | ||
|
||
The database interface is the one provided to the server. The first one is fairly simple: | ||
|
||
```ts | ||
type RawDictionary = Record<string, [Locale, string]> | ||
|
||
interface DB { | ||
list(locales: Locale[], zone: Zone): Promise<RawDictionary> | ||
} | ||
``` | ||
|
||
That `list` function is a glorified `SELECT` who gives all keys given in a zone and, for them, the [_first locale from the given list_](./client.md#locales) that has a translation - and the translation of course | ||
|
||
### Role in OmnI18n ecosystem | ||
|
||
The DB role is purely to deal with a database. The [`server`](./server.md) will often mimic functions and their signature (`modify`, `reKey`, ...) and while the `server` role is to propagate information to both the client and the DB, a DB's role is purely the one of an adapter toward a database. | ||
|
||
## InteractiveDB | ||
|
||
A kind of API has been designed for the server to be able to _modify_ the content of the DB : `InteractiveDB`. | ||
|
||
### Infos | ||
|
||
Here, we get already in the realm where we can specify `KeyInfos` and `TextInfos`. The former is given by developers, in english or some common language if text is needed - and appear in the `keys` database - and the `TextInfo`, more often used/edited by the translators and appearing in the `translations` database. | ||
|
||
These are generic arguments - It means, if one implements a DB adapter, care should be taken to store/retrieve them - even if we don't know what structure they have. They all : | ||
|
||
```ts | ||
...Infos extends {} = {} | ||
``` | ||
|
||
### Specific getters | ||
|
||
#### Work list | ||
|
||
```ts | ||
type WorkDictionaryText<TextInfos> = { | ||
text: string | ||
infos: TextInfos | ||
} | ||
type WorkDictionaryEntry<KeyInfos, TextInfos> = { | ||
locales: { [locale: Locale]: WorkDictionaryText<TextInfos> } | ||
zone: Zone | ||
infos: KeyInfos | ||
} | ||
type WorkDictionary = Record<string, WorkDictionaryEntry> | ||
workList(locales: Locale[]): Promise<WorkDictionary> | ||
``` | ||
Given a list of locales, find all their translations | ||
> No `zone` fuss, and it's not "the first translation", it's all of them. | ||
This function is indeed used to populate translator's list for working on it ... working list. | ||
#### Get a single key, check whether it is specified | ||
```ts | ||
get(key: string): Promise<Record<Locale, string>> | ||
isSpecified(key: string, locales: Locale[]): Promise<undefined | {} | TextInfos> | ||
``` |
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 @@ | ||
# TODO |
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 @@ | ||
# TODO |
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.