Skip to main content
JavaScript Object (.js)
Ilya Krukowski avatar
Written by Ilya Krukowski
Updated this week

JavaScript Object files (.js) are used to manage translations in JavaScript applications. These files store localization data as objects within JavaScript variables, making it easy to access and use translations within your code. Lokalise supports .js files, allowing for efficient translation management directly within your projects.

Technical information

Overview

Format name:
JavaScript Object

File extensions:
.js

Common use cases:
Managing and organizing localization strings in JavaScript applications.

Technical details:

  • Structure: JavaScript Object files consist of a variable that holds an object representing your translations. Each key in the object corresponds to a specific translation string, which can include simple key-value pairs or nested objects for more complex translations like plurals.

  • Encoding: UTF-8

Example:
Here's an example of a typical JavaScript Object file used for localization:

var translations = {
"plural_key": {
"one": "One user online.",
"other": "%i users online."
},
"simple_key": "Hi, I am a key!"
};

In this example, the translations object contains two keys: plural_key and simple_key. The plural_key includes nested keys for handling plural forms, while simple_key is a simple key-value pair.

Using with Lokalise

Lokalise supports JavaScript Object files, allowing you to manage and translate your localization strings efficiently.

Supported project types

Please note that JS files can be uploaded only to Web and mobile projects.

Did this answer your question?