angular-translate doesn't take into account fallback language when using static files

StackOverflow https://stackoverflow.com/questions/23138649

  •  05-07-2023
  •  | 
  •  

Pregunta

I'm trying to use angular-translate with angular-translate-loader-static-files.

When I do this:

$translateProvider.useStaticFilesLoader({
                prefix: 'strings',
                suffix: '.json'
            }).preferredLanguage('en_GB')
                .fallbackLanguage('de_DE');

I'd expect the fallback to use 'strings-de_DE.json' if 'strings-en_GB.json' is not present. Except it isn't.

If I declare the translations in the file, like this:

$translateProvider.translations('en_GB', {
                "recipients": {
                    "email-label": "Enter an email address",
                    "input-placeholder": "Insert one address and press enter",
                    "action-title": "Your selected criteria:"
                }
           }).translations('de_DE', {
                "recipients": {
                    "email-label": "Geben Sie eine E-Mail-Adresse",
                    "input-placeholder": "Legen Sie eine Adresse eingeben, und drücken Sie",
                    "action-title": "Ihre ausgewählten Kriterien:"
                },
           })
           .preferredLanguage('en_FR')
           .fallbackLanguage('de_DE');

it works. I've seen a few examples online, but none of them gives me a clear idea of what I need to do in order to make this work.

Am I missing something? Any additional step I need to do when using static files? Or fallback is simply not supported for static files at the moment?

Thanks

¿Fue útil?

Solución

Why don't you report the issue here: https://github.com/angular-translate/angular-translate/issues

When a library does not work, there's probably a bug in it. Reporting the issue in their bug tracker is the best way to get the issue fixed not only for you but for everybody else.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top