RequireJS

Learn how you can localize RequireJS files (.js) using Transifex.

Antonis Mylonas avatar
Written by Antonis Mylonas
Updated this week

File Extension(s)

.js

i18n type(s)

REQUIREJS

This format is used by projects using the RequireJS framework. It is a JavaScript file that contains a single function define, to which a (key, value) dictionary is passed.

Example:

define({
"JOIN": "Join",
"NEST": {
"SPLIT": "Split,
"INTERSECT": "Intersect"
},
"LIST": ["Element 1", "Element 2", "Element 3"]
});


File format

RequireJS supports two different types of i18n root definitions:

define({
"root": {
"cat": "cat",
"dog": "dog",
"mouse": "mouse"
}
});

define({
"cat": "cat",
"dog": "dog",
"mouse": "mouse"
});

📝Note: Transifex currently supports only the second format, i.e., root must be defined as a normal locale bundle (see the official documentation at the bottom of the page for further information).


Things to note

JavaScript allows keys within a dictionary to be defined without single/double quotes. When a RequireJS file is uploaded, Transifex will automatically add these quotes (the file is parsed similarly to JSON). This means that keys will be quoted when you download your source or translation files.

Example

Someone uploads a translation file, which looks like this:

define({
hello: "Hello"
});

Their strings are then translated into German. The translated file now looks like this:

define({
"hello": "Hallo"
});


Additional information


💡Tip

Looking for more help? Get support from our Transifex Community Forum!

Find answers or post to get help from Transifex Support and our Community.

Did this answer your question?