有没有办法用 I18n-js 库检查翻译是否存在?
最佳答案
您可以使用方法lookup()
。
当翻译不存在时返回undefined
,所以你可以把它放在你的条件中。
例如:
if(!I18n.lookup('translation_key')) {
console.log('Translation does not exist');
}
else {
console.log('Translation does exist. Congrats.');
}
关于javascript - I18n-js - 有没有办法检查翻译是否存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65665076/