Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法使用库 I18n-js 检查翻译是否存在?
你可以使用方法lookup()。
lookup()
它undefined在翻译不存在时返回,因此您可以将其放在条件中。
undefined
例如:
if(!I18n.lookup('translation_key')) { console.log('Translation does not exist'); } else { console.log('Translation does exist. Congrats.'); }