-
-
Notifications
You must be signed in to change notification settings - Fork 578
Conversation
stanislas-m
commented
Nov 23, 2017
- Enable view suffixes support (+ fallback on non-suffixed version).
- Enable localized views support on i18n middleware, which uses view suffixes support. Opt-in option.
* When the default language is a higher preference user choice, use the non-suff ixed template version
So this looks a little too complicated, and requires a bit too much effort for end-users, it also changes some APIs, so I'm not sure this is the correct implementation. What I was thinking was something like this: If the i18n middleware is configured is a slice of accepted languages on the context. So, let's assume it has the following slice: In the action you have this: The templating system would look for files in this order:
If there are no This would mean that to get internationalized views you need to enable the middleware and name your files accordingly. With this approach we don't have to change any of the APIs, everyone's apps will continue to work as they do today. Those that want localized views get them easy, those that don't, don't have to do anything. Thoughts? |
I don't really understand why it requires too much effort for end-users: if they want to use this feature, they just have to set
So the changes you propose are the following, am I right?
|
@markbates Another thing, the .{lang}.html will conflict with the multiple template engine layers feature, don't you think? That's why I suggested _{lang}.html |
@stanislas-m I don't see why it should conflict, but I'm open to suggestions. perhaps |
@markbates That's because of |
@markbates Anything else? |
Love it! I just tried it on an existing app. Everything worked as expected. I then added some localized views, changed my accept header and it found them. Perfect! This is a great feature. Thanks! |