# Dead Simple Internationalization Library (DSI18n)
A dead simple library to handle translations with support for Node.JS, Electron and Browsers.
## Features
* Simple but modern API with Promises.
* Fully documented, including the internal works.
* Delayed evaluation for languag trees with missing languages.
* Support for base languages with multiple languages.
## Support the Project
DSI18n, like all my other projects, is funded through [Patreon](https://www.patreon.com/Xaymar), which is my secondary source of income. If my projects have helped you, consider becoming a Patron (recurring donation) or donating once [through PayPal](https://paypal.me/Xaymar).
## License
The project is licensed under X11:
Copyright (C) 2018-2019 Michael Fabian Dirks
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL MICHAEL FABIAN DIRKS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the copyright holder.
This is an addition to the documentation contained within `i18n.js`, which uses JSDoc. Any modern IDE should be capable of showing it, and even if it doesn't you should first look at the comments in `i18n.js` before looking at this file.
Creates a new I18n object when called with `new I18n('mylanguage')` and sets up internal structures for quick use later. Optionally can specify an override for the base language key, which is used to detect base languages from loaded language files. Can throw exceptions if an error occurs.
Load a language from a File, Blob, object or string as JSON data, and store it as the language. Returns a Promise, which will resolve once it is done loading and parsing and the result will contain the loaded language name. Throws exceptions.
Save a language to a string as JSON data. Returns a Promise which will resolve with the JSON data string once done. Modifying the language before the returned Promise is done can result in corrupt data. Throws exceptions.
Automatically translate all elements in the current DOM which have the attribute specified in `property`. Returns a Promise which resolves when the translation is complete. Throws exceptions.
### Listening to Events
#### object hook(string event, function callback)
Hook a specific event with your own callback. See further below for all events.
#### unhook(object hook_id)
Removes an existing hook. You must have the id of the hook you've created before, otherwise you will not be able to unhook.
### Events
#### missingLanguage(string language)
This event is called for all languages that are missing while evaluating the translation tree.