Language setting during initialization #29
Language setting during initialization #29
Conversation
Fix typo.
Add the "preferredLanguage" property in order to solve an initial language setting issue. At the configuration phase it's better to use this property instead of the "uses" method, because if "rememberLanguage" is set to true it may invoke a language file loading process twice (the language from the uses method and a stored language).
Change demo files in order to show a way of using the preferredLanguage property.
Add simple tests for basic behavior of the preferredLanguage property.
As for tests, I don't have testing experience at all. I tried to write some tests based on other tests. But it's only basics. |
Thanks @DWand ! Glad you made a PR, will look into this now! :) |
I really like that one :) @knalli What do you say? I think we can merge it in. |
Hey, a rival of my defaultKey. ;) Technically, I'm wonder if the PR is correct because commits are split (see by travis build) and the merge commits (will that merge correctly?) In general, I'm with it 👍 , but under which circumstances the language will be loaded twice? That case should be covered by a test. |
Let's say you already have a cookie stored with a What happens is, that in the time when This again, would auto-invokes a loader with the |
Got it. ;) |
Awesome. And yeah, probably it's nearly the same you did with Regarding Travis CI. If it's not merging without conflict, I'll resolve them :) |
Merged this in. Tests have to be fixed. |
Done. |
It's impossible to control the exact amount of language files, which will be loaded to the user's browser at the startup phase of the application, while we specify a preferred language (which we think a user prefer) by calling a "uses" method. For example, if rememberLanguage is true browser will load one or two language files depending on a stored language code. So, it this behavior is unpredictable sometimes.
What if we provide one more property specially for setting preferred language on app startup phase? This property only know which language we prefer, but not really set it up. In such way we can fully transfer a responsibility for an initial language setting to the "run" method. So, we will be able to control which language we have to set and how many files we have to load.