(key, ...args)
| 34955 | } |
| 34956 | |
| 34957 | lang(key, ...args) { |
| 34958 | const msg = (_index || _load_index())[this.language][key] || (_index || _load_index()).en[key]; |
| 34959 | if (!msg) { |
| 34960 | throw new ReferenceError(`No message defined for language key ${key}`); |
| 34961 | } |
| 34962 | |
| 34963 | // stringify args |
| 34964 | const stringifiedArgs = stringifyLangArgs(args); |
| 34965 | |
| 34966 | // replace $0 placeholders with args |
| 34967 | return msg.replace(/\$(\d+)/g, (str, i) => { |
| 34968 | return stringifiedArgs[i]; |
| 34969 | }); |
| 34970 | } |
| 34971 | |
| 34972 | /** |
| 34973 | * `stringifyLangArgs` run `JSON.stringify` on strings too causing |
no test coverage detected