How to check if a translation mapping exists
See original GitHub issueHi there,
I couldn’t see if there was a way to see if a translation mapping exists?
What I mean is, I have an angular page where I am looking up translations dynamically in a loop. Mappings for some of them may not exist for whatever reason, and I’d like to make that check before attempting to render the translation and associated markup.
I mainly want to do these checks from a view, where I would be using the translate
filter or directive.
But I also couldn’t see a way to do this from a controller using the $translate
service either - although I’m sure it’s probably possible using the $translate service directly.
Any ideas?
Issue Analytics
- State:
- Created 10 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
ngx-translate - Checking if translate key exist with Angular
Since I found no way to safely check for the presence of a translation, the best thing I could do is to check...
Read more >Determining if a Translation Exists
Use the Lang::has() method. To check if a translation exists for the current locale pass a single argument to the method. The argument...
Read more >Determining translations (video) - Khan Academy
- [Voiceover] We're asked to use the translation tool to determine the translation that will map triangle WIN, so this right over here,...
Read more >How to identify there is no translation value in Value Mapping
Hi , I am using value mapping to translate one of the fields of data. Whenever the input has a translation value, the...
Read more >key bindings - How to debug a mapping?
You can see in the first column the mode of the mapping ( n for normal mode, v for visual mode, etc), the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For anyone else looking: http://angular-translate.github.io/docs/en/#/guide/16_error-handling
+1 Note: Both links are “Page not Found”
It would be really great to have a helper method to explicitly check in advance if a translation exists. Also, if I could define a fallback-key that is used for non existent mappings.