-
-
Notifications
You must be signed in to change notification settings - Fork 577
Refactor i18n middleware language finders #957
Conversation
@stanislas-m this appears to be a breaking change, how do you propose handling that? via |
@markbates |
The bare minimum we add to |
T.CookieName = "language" // Becomes T.LanguageFinderOptions["CookieName"] = "language"
T.SessionName = "language" // Becomes T.LanguageFinderOptions["SessionName"] = "language"
// This one needs refactor:
T.LanguageFinder = func(t *i18n.Translator, c buffalo.Context) []string {
langs := make([]string, 0)
if cookie, err := c.Request().Cookie(t.CookieName); err == nil {
if cookie.Value != "" {
langs = append(langs, cookie.Value)
}
}
langs = append(langs, t.DefaultLanguage)
return langs
} |
ef75e1d
to
3750d95
Compare
@stanislas-m can you make the changes needed to |
@markbates Sure, it's on my todo list. :) |
* Split language finders into separate functions * Refactor LanguageFinder type * Generalize Language finders options * Add a new path prefix language finding strategy * Ensure setups with default config won't break
eabbbdb
to
3b4246b
Compare
@markbates The update works on my side, but a specific case like the following will break (since I've removed the T.LanguageFinder = func(t *i18n.Translator, c buffalo.Context) []string {
langs := make([]string, 0)
if cookie, err := c.Request().Cookie(t.CookieName); err == nil {
if cookie.Value != "" {
langs = append(langs, cookie.Value)
}
}
langs = append(langs, t.DefaultLanguage)
return langs
} I issue a warning for this one with the update command, is it enough? |
middleware/i18n/i18n.go
Outdated
@@ -14,27 +14,32 @@ import ( | |||
"github.com/pkg/errors" | |||
) | |||
|
|||
// LanguageFinder can be implemented for custom finding of search | |||
// LanguageFinder - deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what should they use instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added more infos in the last commit, thanks!
* Refactor i18n middleware language finders * Split language finders into separate functions * Refactor LanguageFinder type * Generalize Language finders options * Add a new path prefix language finding strategy * Ensure setups with default config won't break * Handle deprecations * Fix deprecations replacement * Add more infos about i18n deprecations
Related to: gobuffalo/docs#133