Romanchuk/angular-i18next

Backend missing files prevents angular app from starting, when fallback should be applied

Merwer opened this issue · 5 comments

As per the issue listed at i18next/i18next-xhr-backend#261, if a file is missing, the i18next-xhr-backend issues an error message to the callback indicating the missing files.

The system would normally continue with a graceful fallback, but due to the handling by I18NextService in init the app initialization is rejected.

(err: any) => {
if (err) {
console.error(err);
reject(err);
} else {

When using this project in the app initialization as defined in the cookbook section of the README (https://github.com/Romanchuk/angular-i18next#initialize-i18next-before-angular-application), the reject prevents the angular app from initializing, and only a blank screen is presented.

Thank you for info.
The issue is about fallback to generic culture (en) if there is no specific culture translation file loaded (en-US). Fix me if i am missunerstood you.
I'm going to dive into problem in a next week.

Temporary fix for this case is to wrap init promise in a new promise and resolve both positive and negative results.

@Merwer i've reproduced an issue. Library should behave as i18next framework.
In the upcomming version (3.0) i'm going to change this behavior to be the same as native and set it by default.
Current strict error handling would be also available to be set with a parameter.

@Romanchuk Thanks for the quick response. I'm glad you were able to reproduce the issue, and I think your proposed solution would work out perfectly.

@Merwer
version 3.0.0-alpha.2 with a new feature ErrorHandlingStrategy now available.
https://github.com/Romanchuk/angular-i18next#other-breaking-changes
npm install angular-i18next@3.0.0-alpha.2

Demo app repository updated to use latest angular-i18next version

angular-i18next v3.0.0 released