npm.io
0.0.2 • Published 7 years ago

localise-text

Licence
ISC
Version
0.0.2
Deps
0
Size
4 kB
Vulns
0
Weekly
0

localise-text


Install

To install using NPM: npm i -S localise-text

How to use:

  1. Create a folder in the same directory as the file using the package.
  2. 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)>});
  1. To get the text from the language ID,
l.translate("<lang_id>");
  1. 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 ID
  • leaveIDIfNotExist : 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

Keywords