open-index/open-npm huggingface dataset:
npm package: @secret-escapes/i18n
Description: i18n system used internally at Secret Escapes
Author: Sam Palmer
Latest version: 1.0.17

# Secret Escapes i18n Library

## Description

This library contains two parts.

- An i18n function which takes an object of key value pairs. They key is an identifier and the value is a translation. This has been tested on a Phraseapp output but this should work with most standard internationalisation library outputs

- A react component which takes parameters and calls the library to output the translated text

## Examples

Given the following json object:

```
const jsonObject =
{
   "a.key.with.no.arguments":"This is a translation with no arguments.",
   "a.key.with.one.choice":"{0} {0,choice,1#Child|1<Children}",
   "a.key.with.two.choices.and.one.argument":"{0} {0,choice,1#adult|1<adults} and {1} {1,choice,1#child|1<children} from {2}"
}
```

`i18n('a.key.with.no.arguments', [], jsonObject)`

> This is a translation with no arguments.

`i18n('a.key.with.one.choice', [1], jsonObject)`

> should return 1 Child

`i18n('a.key.with.one.choice', [2], jsonObject)`

> 2 Children

`i18n('a.key.with.two.choices.and.one.argument', [1, 5, 'London'], jsonObject)`

> 1 adult and 5 children from London

The react component calls the library in the same way except the arguments are optional if they would be empty

```
<Translation
        translationKey={'a.key.with.two.choices.and.one.argument'}
        translationArguments={[1, 5, 'London']}
        translationObject={jsonObject}
      />
```

> 1 adult and 5 children from London

```
<Translation
        translationKey={'a.key.with.no.arguments'}
        translationObject={jsonObject}
      />
```

> This is a translation with no arguments.