Reputation: 1925
I am having a span tag like below.
<span translate="footer.copyright">Copyright</span>
In my Json file I have data like below,
"footer": {
"copyright": "Copyright ©"
},
Its working fine too. But if the json file is not having the data, I want translate to show whatever content is available in between the span tag, in this case Copyright. But its not taking the content instead its showing empty tag. Please help me with this.
Upvotes: 1
Views: 305
Reputation: 1440
Just simply add translate-default
to your tag:
<span translate="footer.copyright" translate-default="Copyright">Copyright</span>
You can read more here.
Upvotes: 1
Reputation: 21681
Use translate-default
instead translate
.
So your HTML look like
<span translate-default="footer.copyright">Copyright</span>
This would kind of sidestep the issue here, but then you'd end up with tags that look like
<ANY translate="missing.id" translate-default="This is some text"></ANY>
Where writing
<ANY translate="missing.id">This is some text</ANY>
Looks cleaner & simpler and would actually show the placeholder text in case of a JS error that prevents Angular/Angular-Translate from working, or when you open your view templates directly.
NOTE:
Keep in mind that the original situation where this problem occurred was, when the translation file was not loaded yet, for example due to slow internet connection. So at that point, Angular Translate would probably not know, yet, that it has to use the translate-default attribute for the content. Just try a custom $missingTranslationHandlerFactory
.
Upvotes: 0