(key, ...args)
| 35389 | } |
| 35390 | |
| 35391 | lang(key, ...args) { |
| 35392 | const msg = (_index || _load_index())[this.language][key] || (_index || _load_index()).en[key]; |
| 35393 | if (!msg) { |
| 35394 | throw new ReferenceError(`No message defined for language key ${key}`); |
| 35395 | } |
| 35396 | |
| 35397 | // stringify args |
| 35398 | const stringifiedArgs = stringifyLangArgs(args); |
| 35399 | |
| 35400 | // replace $0 placeholders with args |
| 35401 | return msg.replace(/\$(\d+)/g, (str, i) => { |
| 35402 | return stringifiedArgs[i]; |
| 35403 | }); |
| 35404 | } |
| 35405 | |
| 35406 | /** |
| 35407 | * `stringifyLangArgs` run `JSON.stringify` on strings too causing |
no test coverage detected