Transloco: Allow fallback language for missing values

Created on 19 Sep 2019  路  6Comments  路  Source: ngneat/transloco

Example: If I use Spanish, and one of the keys is missing, I want to display the English version of it.

PRs welcome enhancement

Most helpful comment

@NetanelBasal I would be happy to pick this.

All 6 comments

@NetanelBasal I would be happy to pick this.

Go ahead 馃榾

@NetanelBasal In your point of view is it better to add this behavior directly in the translate method or delegate this to the DefaultHandler ?

There are couple of issues with this approach:

  1. It will not work with the structural directive as we don't support it with the missing handler.
  2. When we have missing value, we need to load the fallback language, something that could lead to a bad UX such as jumpy content.

The solution for this is that if the consumer passes the fallbackLangValue option, we should load both the active language and the fallbackLangValue and merge them together. Then, we can clean some memory by removing the fallbackLangValue translation from the service's cache.

@Edouardbozon what's the status of the issue?

@NetanelBasal I have something working, I have to add tests now. I will push it soon to get feedback.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

flgraveline picture flgraveline  路  7Comments

frct1 picture frct1  路  3Comments

inorganik picture inorganik  路  8Comments

karmasakshi picture karmasakshi  路  6Comments

mailok picture mailok  路  5Comments