英文:
How to translate conditional string interpolation using NGX-translate
问题
{{ toggleRedirect ? 'Disabled' : 'Enabled' }}
英文:
I have a toggle button on my application that changes the label accordingly to its value, it will either display 'Enabled' or 'Disabled'.
I'm using ngx-translate to handle translation on my application but I can't get this to work. How can I set the translation in this scenario?
The words "disabled" and "enabled" should be translated.
{{ toggleRedirect ? 'Disabled' : 'Enabled' }}
Thanks
答案1
得分: 0
你可以使用 translate pipe:{{ toggleRedirect ? '已禁用' : '已启用' | translate }}...但你应该检查 '已禁用' 和 '已启用' 是否在翻译文件(例如 en.json)中,并且你的 ngx-translate 配置是否正确。
英文:
You can use translate pipe : {{ toggleRedirect ? 'Disabled' : 'Enabled' | translate }} ...but you should check if the 'Disabled' & 'Enabled' are on the translation file (ie en.json) and your config for ngx-translate is correct
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论