# cloudux-l10n

Package to providing localization for the Avid® MediaCentral UX static
plugins.

## Getting the localization files
To be able to get the localization files you have to request them
through our API. Localization file will be fetched by using our internal
 mechanism that depends on the current runtime user locale.

**Example**
    
    import localizationData from 'path/to/your/folder/lang.l10n.json'

Here is the __lang.10n.json__ is the template file name, which will be replaced by the current language in the runtime. For instance, if current locale will be the 'de'
name of the required file will be __lang.de.json___


  To be able to use this API you have to provide the localization files at your
  project. This is name convention in the name of this files that resolves
  by API. To be able to obtain the file according to the current runtime
  localization you should require ```some-file-name.l10n.json``` file where
  In case if German is being active locale, file name request will be resolved
  to `some-string.de.json` at runtime level to the name of the current locale.
  Localization has names according to [ISO_639-1](https://en.wikipedia.org/wiki/ISO_639-1)
 
  #### Example of the file system structure
 ```
     static-plugin-folder/
     ├── src
     │   ├── index.js
     │   ├── l10n
     │   │   ├── lang.de.json
     │   │   ├── lang.fr.json
     │   │   └── lang.en.json
     │   └── views
     │       ├── settings-view
     │       │   ├── index.js
  ```
  
  #### Localization file structure
 
  Localization file has the flat json object structure. Nesting object is
  currently unsupported. Example of the ``lang.en.json``:
  ```
  {
   'hello-msg': 'Hello World'
  }
  ```
  the same file in different language will have the same key6 but localized
  value. For instance, in Deutch ``lang.de.json`` will be
  ```
  {
   'hello-msg': 'Hallo Welt'
  }
  ```

  #### Require the localization file
 
  In the above example we placed the three localization files in the folder
  named ```l10n```. This localization should be required as an external module.
  For instance, by using AMD module pattern
  Or, if you are using the webpack, you have to add the path to
  localization file as an external dependency. See example below.
 
 
``` 
  //@file "static-plugin-folder/src/views/settings-view/index.js";
  const l10nData = require('../../l10n/lang.l10n.json'); // path relative to this file
  // If current locale is === "de" will be required file named lang.de.json
  // l10nData = { 'submit': 'Einreichen' };
  const localize = l10n.getLocalization(l10nData);
 
```

#### Parametrized labels

  If you need parametrized labels, add parameters using `{}`:
  In your localization file:
  ```
  {
     "copy-folder-part-of-items-error-message": "{​​​​​​0}​​​​​​ of {​​​​​​1}​​​​​​ items cannot be copied to the destination folder."
  }
  ```
Usage:
```
localize('copy-folder-part-of-items-error-message', errorItemsCount, copyItemsCount)
```


**You can check it on our examples on [Avid-Technology Github](https://github.com/avid-technology)**

