localise-text
v0.0.2
Published
An easier way to localise your Node.JS programs for users.
Downloads
2
Maintainers
Readme
localise-text
Install
To install using NPM: npm i -S localise-text
How to use:
- Create a folder in the same directory as the file using the package.
- To initialise the
localise-text
package,
const Localiser = require('localise-text');
let l = new Localiser(<location of the languages folder>);
l.init({<Settings (See bottom of file)>});
- To get the text from the language ID,
l.translate("<lang_id>");
- To change the language id,
l.setNewLanguage("<new language id>");
Format of Language file
The format of the language file is simply just a JSON Object, and is probably the simplest thing you'll ever see.
To make a language file, first name it the locale alias, such as en_US
or nl
, and give it the .json
extension.
To assign text to values, do the following:
{
"localisation_id": "Text to display!",
"buttons.home_button": "Home",
"buttons.send_email": "Send Email!"
}
Settings
language
: The language IDleaveIDIfNotExist
: Whether or not to show the language ID if the matching text could not be found.
Dependencies
I would like to take this space to thank all of the dependencies that allowed this project to come to life- wait, oh yeah! I didn't include any, you're welcome for keeping your package-lock.json
clean 😉