Make translations with ease
- NodeJS 16+
- npm (if you want to install cli tool)
- Clone this repository
- Install using
npm
command:npm install -g ./translator/
If you are using Translator directly instead of installing it, you'll have to replace
translator
prefix withnode path/to/translator/dist/cli.js
# Build language file
translator myLang.lang
cat myLang.json
# Build from configuration
# Configuration allow you to build multiple language files at once
# {"include": ["myLang.lang"], "outputDirectory": "./compile"}
translator project.json
cat compile/myLang.json
// This is single-line comment.
/* This is comment block */
my.key "Translation for key 'my.key'";
my.emptykey; // Empty key
import "./path/to/file.lang";
import './path/to/file.lang'; // Single quote
namespace myglobal.namespace;
key "The key for this is myglobal.namespace.key";
// Note: You should only use this syntax once for each file.
// A check that prevents you from adding this multiple times will be implemented in a future.
namespace mynamespace {
key "The key is mynamespace.key";
namespace child {
key "The key is mynamespace.child.key";
}
}
Of course, you can mix those 2 into a single file:
namespace myglobal;
namespace coolnamespace {
key "myglobal.coolnamespace";
}
namespace anotherns {
key "myglobal.anotherns";
namespace child {
key "myglobal.anotherns.child.key";
}
}