# Translations in CloudCode

The same translation files used in the application can be used in CloudCode, although the translation function itself is not provided currently.

### Step 1: Add the js-yaml library

Use the instructions in [CloudCode Dependencies](https://docs.journeyapps.com/reference/cloudcode/advanced-cloudcode-topics/cloudcode-dependencies) to add the js-yaml library to the task:

```shell
yarn add js-yaml
```

### Step 2: Read the file

```javascript
const fs = require('fs');
const yaml = require('js-yaml');

export async function run() {
    const language = 'en_US';
    const doc = yaml.safeLoad(fs.readFileSync(`app/translations/${language}.yml`, 'utf8'));
    console.log(doc);
}
```

The translation document can now be used inside the task.

### Further reading:

For more information on how translations work for an app, please read the following documentation:

{% content-ref url="../../app-features/translations" %}
[translations](https://docs.journeyapps.com/reference/app-features/translations)
{% endcontent-ref %}
