JavaScript

Last updated: October 04, 2024Author: Jakub Pomykała
javascript
File format value
javascript

JavaScript file format is a simple way to store translations in JavaScript or TypeScript format. This format is useful when you want to store translations in a single file and use it in your application.

File format example

export default {
  "HELLO_WORLD": "Hello world!",
  "TRANSLATION_KEY": "This is my translated text!"
}

Upload with CLI

simplelocalize upload --apiKey <PROJECT_KEY> \
  --uploadFormat javascript \
  --uploadPath ./messages_{lang}.js

Learn more about SimpleLocalize CLI and translations upload feature.

Download with CLI

simplelocalize download --apiKey <PROJECT_KEY> \
  --downloadFormat javascript \
  --downloadPath ./messages_{lang}.js

Learn more about SimpleLocalize CLI and translations download feature.

Import with API

curl
    --request POST \
    --url 'https://api.simplelocalize.io/api/v2/import?uploadFormat=javascript&languageKey=en' \
    --header 'x-simplelocalize-token: <API_KEY>' \
    --form file=@/path/to/your/file.js

Learn more about importing translations with API

Export with API

curl
    --request GET \
    --url https://api.simplelocalize.io/api/v3/export?downloadFormat=javascript \
    --header 'x-simplelocalize-token: <API_KEY>'

Learn more about exporting translations with API

Was this helpful?