rbalet / ngx-translate-multi-http-loader

A loader for ngx-translate that loads translations with http calls
MIT License
77 stars 15 forks source link

Feature: optional resources #24

Closed AntoninoBonanno closed 1 year ago

AntoninoBonanno commented 1 year ago

Hi, at this moment if a file is not found a 404 error is triggered visible in the console.

Cattura

Would it be possible to add the optional attribute to the resources, in order to catch the 404 error and not propagate it? (so as not to be visible in the console - for me it's not an error as I know that in that folder there may be no files)

For example, it is useful when initially there are no files in a specific directory but they can be added later to overwrite or customize the labels loaded by default.

Example:

export function HttpLoaderFactory(_httpBackend: HttpBackend) {
    return new MultiTranslateHttpLoader(_httpBackend, [
        {prefix: './assets/i18n/core/'},
        {prefix: './assets/i18n/custom/', optional: true}, // catches the 404 error and doesn't propagate it
    ]);
}

Thank you

rbalet commented 1 year ago

@AntoninoBonanno There you are -> https://github.com/rbalet/ngx-translate-multi-http-loader/releases/tag/v9.3.0