mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 03:07:31 +00:00
fix(login): avoid disallowed languages with custom texts (#9094)
# Which Problems Are Solved
If a browsers default language is not allowed by instance restrictions,
the login still renders it if it finds any custom texts for this
language. In that case, the login tries to render all texts on all
screens in this language using custom texts, even for texts that are not
customized.



# How the Problems Are Solved
If a custom messages language is not allowed, it is not added to the
i18n library's translations bundle. The library correctly falls back to
the instances default language.

This library method only receives messages for allowed languages

# Additional Context
Reported via support request
(cherry picked from commit ab6c4331df
)
This commit is contained in:

committed by
Livio Spring

parent
47268c738a
commit
74479bd085
@@ -64,10 +64,22 @@ func (t *Translator) SupportedLanguages() []language.Tag {
|
||||
return t.allowedLanguages
|
||||
}
|
||||
|
||||
// AddMessages adds messages to the translator for the given language tag.
|
||||
// If the tag is not in the allowed languages, the messages are not added.
|
||||
func (t *Translator) AddMessages(tag language.Tag, messages ...Message) error {
|
||||
if len(messages) == 0 {
|
||||
return nil
|
||||
}
|
||||
var isAllowed bool
|
||||
for _, allowed := range t.allowedLanguages {
|
||||
if allowed == tag {
|
||||
isAllowed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !isAllowed {
|
||||
return nil
|
||||
}
|
||||
i18nMessages := make([]*i18n.Message, len(messages))
|
||||
for i, message := range messages {
|
||||
i18nMessages[i] = &i18n.Message{
|
||||
|
Reference in New Issue
Block a user