retro-langs v1.1.2
DofusRetro-Langs
Allows you to watch and download langs files for Dofus Retro.
Is available through a CLI and Class usable in your own code
(Thanks @drag0une for his work)
Table of contents
Installation
You can install the retro-langs package with npm
npm i --save retro-langs
If you want to use the cli everywhere you can add the -g option
CLI
You can follow the instruction of the help command of the cli
retro-langs --help
retro-langs [command] --help
Langs
Watch versions.txt file on DofusRetro CDN
Kind: global class Emits: update, downloaded, watching, error
new Langs(lang, saveFolder)
Creates an instance of Langs.
Param | Type | Default | Description |
---|---|---|---|
lang | string | Language to watch (if invalid 'fr' is used) | |
saveFolder | string | "langs" | Folder used to save versions.json and swf langs files |
build | string | "prod" | lang build type : prod (default), temporis or beta |
langs.watch(interval, downloadNewFiles)
Watch remote versions.txt file
Kind: instance method of Langs
Param | Type | Default | Description |
---|---|---|---|
interval | number | interval in seconds | |
downloadNewFiles | boolean | false | download new swf files on changes |
langs.unwatch()
Remove the watcher of the remote versions.txt file
Kind: instance method of Langs
"update"
Langs update event
Kind: event emitted by Langs Properties
Name | Type | Description |
---|---|---|
lang | string | Language |
files | Array.<string> | Array of new files names (without extension) |
build | string | lang build type |
"downloaded"
Lang downloaded event
Kind: event emitted by Langs Properties
Name | Type | Description |
---|---|---|
lang | string | Language |
file | string | File name (without extension) |
path | string | Full path of the downloaded file |
build | string | lang build type |
"watching"
Start watching langs event
Kind: event emitted by Langs Properties
Name | Type | Description |
---|---|---|
lang | string | Language |
interval | number | interval in seconds |
saveFolder | string | Full path of the downloading directory |
downloadNewFiles | boolean | download new swf files |
build | string | lang build type |
"error"
Error event
Kind: event emitted by Langs Properties
Name | Type | Description |
---|---|---|
error | error | Error message |
Exemple
const Langs = require('retro-langs');
/**
* Watched language is fr
* Working directory is ./output/dir/
* Lang build type is temporis (can also be 'beta' or 'prod' by default)
*/
const langWatcher = new Langs('fr', 'output/dir', 'temporis');
langWatcher.on('update', ({ lang, files, build }) => {
// an update of langs is available
});
langWatcher.on('downloaded', ({ lang, file, path, build }) => {
// a lang file has been downloaded
});
/**
* Watch every 60s
* Will be downloading every new files on changes
*/
langWatcher.watch(60, true);