lib/l10n/index.js
/**
 * Translate a string into the global target language
 *
 * This function can be used as template string tranformer (l10n`...`). If so,
 * the target string to translate is rebuild automatically frome the string
 * fragments.
 *
 * @param {array|string} key The string to translate
 * @param {...string} params The params to inject within the tranlated string
 * @returns {string}
 */
Translate a string into the global target language
This function can be used as template string tranformer (l10n`...`). If so,
the target string to translate is rebuild automatically frome the string
fragments.

@param {array|string} key The string to translate
@param {...string} params The params to inject within the tranlated string
@returns {string}
Translate a string into the global target language This function can be used as template string tranformer ( l10n ` ... ` ) . If so the target string to translate is rebuild automatically frome the string fragments . @param { array|string } key The string to translate @param { ... string } params The params to inject within the tranlated string @returns { string }
function l10n (key, ...params) {
  if (Array.isArray(key)) {
    key = key.reduce((str, sub, index) => `${str}%${index}${sub}`)
  }
  let str = l10n.data[key] || key
  params.forEach((s, i) => {
    str = str.replace(`%${i + 1}`, s)
  })
  return str
}
function l10n ( key , ... params ) { if ( Array . isArray ( key ) ) { key = key . reduce ( ( str , sub , index ) => ` ${ str } ${ index } ${ sub } ` ) } let str = l10n . data [ key ] || key params . forEach ( ( s , i ) => { str = str . replace ( ` ${ i + 1 } ` , s ) } ) return str }
Translate a string into the global target language
 This function can be used as template string tranformer (l10n`...`).
Translate a string into the global target language This function can be used as template string tranformer ( l10n ` ... ` ) .