Translation async provider fallback
See original GitHub issueI’m using the module into a project, loading the JSON files asynchronously from an external web API.
It would be nice having a fallback when the API doesn’t respond for any reason. At this moment, the LocalizationService just prints an error to the console on the getTranslation() method, but the method itself returns void so there’s no way of telling whether the async load was successful or not.
Maybe returning an Observable<boolean> would allow to define a fallback static object on loading error?
What do you think? Would you find this useful? What would be your preferred way of implementing this? I can try to put together a PR if you want me to.
Thanks and regards.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Async Loading and fallback languages · Issue #245
After that, when angular-translate needs a fallback language, it starts to request the languages one by one by one. But as soon as...
Read more >Set a fallback language
Set a fallback language to be used when user interface text is not translated in the user's preferred language to accommodate the language...
Read more >javascript - Angular Translate async timing issue with $ ...
useStaticFilesLoader works asynchronous while I would really need it to be synchronous because by the time the plunker runs, the JSON files are ......
Read more >Configuration Options - i18next documentation
fallbackLng. 'dev'. language to use if translations in user language are not available. Setting it explicitly to false will not trigger to load...
Read more >Internationalization (i18n) - Spartacus Documentation - SAP
To provide better a better user experience if a translation is missing, you can specify a fallback language. Setting the fallbackLang option ensures...
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

I made a commit https://github.com/robisim74/angular-l10n/commit/823e0091de562a7e8d6c917f1a7a2b39d939f8e5 to add a
translationErrorevent and to add a newAddWebAPIProvidermethod to the configuration.I’m going to release a new version by Monday.
Greetings,
Roberto
@robisim74 Sounds good. Either way, the point is being able to notify subscribers of a possible HTTP error. I’ll fork and try to come up with something later today / tomorrow and will let you know.