<commit_before># translite
Small no-db translation library for js, supporting controlled contexts, versioning and plural forms.

## Features

Below we'll describe the features of this translation library. The example translations file at the bottom of this file helps to clarify how these features are used.
Note that the input to the translation function is a string that we call the "identifier".  The output is the translation of the identifier into the selected language. My personal preference is to create identifiers by concatenating the first words of the english translation, e.g.
"Welcome-to-this-webpage". Of course, you can also use regular english words and sentences as the identifier.


### No database: all translations are grouped in javascript dictionaries

The use of javascript files for storing the translations allows you to manage the translations and source code together in source control.
Declaring multiple translation dictionaries in these javascript files makes it possible to group related translations, and to translate the same string differently in each group. Moreover, the context that is provided by the group helps to clarify the intention behind each translated string. In the following example, the `form` and `welcome` groups are used:

    ```javascript
    import { pages } from 'translations'
    import { getTr } from 'translite'

    let {tr: tr, context: context} = getTr(groups['form']);
    console.log(tr('message'))

    let {tr: tr2, context: context2} = getTr(group['welcome']);
    console.log(tr2('Good-morning'))
    ```

### Identifiers and their translations have a version number

If the identifier and the translation are at the same version number, then the translation is up-to-date. Note that it's possible for none of the translations to be up-to-date.<commit_msg>Improve README<commit_after># translite
Small no-db translation library for js, supporting controlled contexts, versioning and plural forms.

## Features

Below we'll describe the features of this translation library. The example translations file at the bottom of this file helps to clarify how these features are used.
The input to the translation function is a string that we call the "identifier".  The output is the translation of the identifier into the selected language. Note that the identifier itself is never used as a translation (in other words: if you target English as one of the output languages, you will write an English translation for each identifier).
My personal preference is to create identifiers by concatenating the first words of the english translation, e.g.
"Welcome-to-this-webpage". Of course, you can also use regular english words and sentences as the identifier, but the use of hyphens or underscores makes it clear that it's only used as an *input*.


### No database: all translations are grouped in javascript dictionaries

The use of javascript files for storing the translations allows you to manage the translations and source code together in source control.
Declaring multiple translation dictionaries in these javascript files makes it possible to group related translations, and to translate the same string differently in each group. This has the advantage that the context (provided by the group) helps to clarify the intention behind each translated string. In the following example, the `form` and `welcome` groups are used:

    ```javascript
    import { pages } from 'translations'
    import { getTr } from 'translite'

    let {tr: tr, context: context} = getTr(groups['form']);
    console.log(tr('message'))

    let {tr: tr2, context: context2} = getTr(group['welcome']);
    console.log(tr2('Good-morning'))
    ```

### Translations are not split per language

Each group (mentioned above) contains the translation of the identifier into all the target languages. This helps to ensure that all the translations carry the same meaning. In addition, having all the translations together makes it easier to find translations that are no longer up-to-date.

### Identifiers and their translations have a version number

If the identifier and the translation are at the same version number, then the translation is up-to-date. Note that it's possible for none of the translations to be up-to-date.
{'fraction_non_alphanumeric': 0.055880289922843114, 'fraction_numerical': 0.0014028524666822538, 'mean_word_length': 4.6141732283464565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '844712', 'n_tokens_mistral': 1020, 'n_tokens_neox': 944, 'n_words': 597}