Prefix replacement of the old application-nested module path in go.mod and every import. No identifier, string, table, migration ID, config key or comment changes.
29 lines
722 B
Go
29 lines
722 B
Go
package classes
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.golem15.com/golem15/sm-user-plugin/models"
|
|
"git.golem15.com/golem15/summercms/modules/towel"
|
|
)
|
|
|
|
// MailTemplate appends -en for English and leaves every other locale,
|
|
// including empty and pl, on the unsuffixed Polish template name.
|
|
func MailTemplate(base, locale string) string {
|
|
if locale == "en" {
|
|
return base + "-en"
|
|
}
|
|
return base
|
|
}
|
|
|
|
// ResolveMailLocale prefers the user's saved locale, then the request locale.
|
|
func ResolveMailLocale(ctx context.Context, user *models.User) string {
|
|
if user != nil && user.PreferredLocale != nil && *user.PreferredLocale != "" {
|
|
return *user.PreferredLocale
|
|
}
|
|
if loc, ok := towel.Locale(ctx); ok {
|
|
return loc
|
|
}
|
|
return ""
|
|
}
|