npm.io
2.2.4 • Published 6 years ago

@tiny-i18n/fs

Licence
MIT
Version
2.2.4
Deps
2
Size
25 kB
Vulns
0
Weekly
0
Stars
8

@tiny-i18n/fs

NPM version NPM Downloads

The utilities about some actions dealing with i18n files.

API

new Fs(i18nRoot, options)

  • Example
const Fs = require('@tiny-i18n/fs')
new Fs(/* ... */)
Options
  • force boolean (default: true) Whether should insert an new record when the key is not found in dictionary.
  • quote enum('single', 'double') (default: 'single') The dictionary quote's rule.
Fs#getLanguages(): Promise<string[]>

Returns languages asynchronously.

In actual fact, The returned languages is readdir from i18nRoot.

  • Example
fs.getLanguages().then(console.log)
Fs::getWordSync(key: string, lang: string): any

Returns raw words in matched key and in exact environment.

Fs::getDictSync(lang: string): any

Returns dictionary in matched language.

Fs::update(key: string, value: string, lang: string, options: Options): boolean

Updates value of matched key.