-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add auto fallback feature #35
Conversation
Add auto fallback feature (use first available locale as fallback locale), can be activated by setting fallback_locale to null.
Avoid too many return statements within this method - return null removed, makes no difference.
C'mon man..
I gave up regarding cognitive complexity. Please take a look. Note that originally this was a 6 line commit... |
Hey, After this I will take a look in depth. In general I'm not against this - but I have some things to keep in mind:
Some also changed the logic to respect a So just to warn you: it could be that I reject this particular PR in favor of a whole rework (respecting your changes and author) or simply merge it without an immediate release but reworking the fallback logic. I really appreciate your work and input but have to check it in a quiet minute. |
Hi, For example I'm making a restaurant system, let's say we have english, german, italian languages. For sure, if I haven't got the german and italian translation yet for some meals, I still want to show them. What if I set german as fallback and the user switches to italian language - meals only available in english won't show up. I think the whole thing could be simplified by only making one fallback config var and removing the rest. This would also enable more specific configuration to country based fallback. However, merging my commit would be the best for keeping compatibility.
This seems much cleaner for me, currently for configuring country based locale I would have to adjust 4 parameters. |
Hey @netdown , Thanks for your work! Because at all I'm not fine with the current super complex condition-loop style I think about something like a dedicated class to get the fallback locale |
Good idea to give full control to the users. Maybe the best would be if there was a default strategy with the idea (or simplified, like without point 3) I have written above, and if somebody wants it different, he can overwrite/inject his own strategy. |
Currently, only one fallback locale can be used and it has to be predetermined in config. Auto fallback means looping through available locales (in configuration order) and using the first available translation. I believe this is much more realistic than using a specified fallback locale.
This commit generates no conflicts or unwanted operation, as this feature only operates if fallback_locale in configuration is set to null (null value is not used for anything currently). Way of loading translations neither affected.