README
slang-js
The official JavaScript/Node client for Slang, a Kick-Ass translation and content management service.
Important Notes
SemVer
This project adheres to Semantic Versioning.
Please refer to the CHANGELOG when upgrading.
Installation
Node
npm install slang-js --save
Bower
bower install slang-js --save
Documentation
Public API
Slang's public API is documented below. While it is tempting to look into the Slang client's internals (and the curious should), do not depend on those implementation details in your code! They will most likely change as Slang evolves. If you stick to this public API, your code will not break, as this project adheres to [Semantic Versioning][semver-home].
Slang.ify(config={})
Initializes Slang with the given configuration hash. This must be called before any other methods, even if config
is empty.
Slang.t(key, variableMap={})
Fetch the translation for the given key name. The second parameter is an optional object mapping variable names to their values (for variable interpolation, pluralization rules, etc).
Slang.localeCode=
Sets the locale code (i.e. language).
Slang.localeCode
Returns the current locale code.
Slang.keys
Returns an array of keys available in the current snapshot.
Development
slang-js uses Babel's excellent transpiler. For distribution we are currently only offering the transpiled, ES5-compliant, code.
Install Dependencies
npm install
Building for Node
npm run build-npm
This will generate Node-appropriate code and output it to ./dist/npm/
. Essentially all this does is transpiles the ES6 files to ES5 and copies the files to ./dist/npm/
.
Building for browsers
npm run build-global
This will generate browser-appropriate code and output it to ./dist/global/
. This process will exclude node-specific code (from ./src/lib/node
) and concat everything into one file. It will additionally create another, minfied, version of the library.
To generate documentation:
./node_modules/.bin/yuidoc -o docs ./src
To run documentation server:
./node_modules/.bin/yuidoc --server 9090 ./src
Then visit http://localhost:9090/ to see doc site.