Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-35294: Add French and Spanish localization for login screen #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pkg/server/locales/locales.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ type Localization map[string]string

var supportedLocalizations = map[string]Localization{
language.English.String(): locale_en,
language.Spanish.String(): locale_es,
language.French.String(): locale_fr,
language.Chinese.String(): locale_zh,
language.Japanese.String(): locale_ja,
language.Korean.String(): locale_ko,
Expand Down Expand Up @@ -36,6 +38,8 @@ func getPreferredLang(acceptLangHeader string) string {

var supportedLangs = []language.Tag{
language.English, // en - first language is fallback
language.Spanish, // es
language.French, // fr
language.Chinese, // zh
language.Japanese, // ja
language.Korean, // ko
Expand All @@ -54,6 +58,32 @@ var locale_en = Localization{
"InvalidLoginOrPasswordPleaseTryAgain": "Invalid login or password. Please try again.",
}

var locale_es = Localization{
"LogInToYourAccount": "Connectez-vous à votre compte",
"Username": "Nom d'utilisateur",
"Password": "Mot de passe",
"LogIn": "Se connecter",
"WelcomeTo": "Bienvenue à",
"LogInWith": "Connectez-vous avec",
"Error": "Erreur",
"LoginIsRequiredPleaseTryAgain": "La connexion est requise. Veuillez réessayer.",
"CouldNotCheckCSRFTokenPleaseTryAgain": "Impossible de vérifier le jeton CSRF. Veuillez réessayer.",
"InvalidLoginOrPasswordPleaseTryAgain": "Identifiant ou mot de passe invalide. Veuillez réessayer.",
}

var locale_fr = Localization{
"LogInToYourAccount": "Inicia sesión en tu cuenta",
"Username": "Nombre de usuario",
"Password": "Contraseña",
"LogIn": "Iniciar sesión",
"WelcomeTo": "Bienvenido a",
"LogInWith": "Inicia sesión con",
"Error": "Error",
"LoginIsRequiredPleaseTryAgain": "Se requiere iniciar sesión. Por favor, inténtalo de nuevo.",
"CouldNotCheckCSRFTokenPleaseTryAgain": "No se pudo verificar el token CSRF. Por favor, inténtalo de nuevo.",
"InvalidLoginOrPasswordPleaseTryAgain": "Usuario o contraseña inválidos. Por favor, inténtalo de nuevo.",
}

var locale_zh = Localization{
"LogInToYourAccount": "登录到您的帐户",
"Username": "用户名",
Expand Down
14 changes: 12 additions & 2 deletions pkg/server/locales/locales_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@ func TestLocales(t *testing.T) {
},
{
name: "Test 'Accept-Language' request header which favours English language",
header: "fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5",
header: "en;q=0.8, de;q=0.7, *;q=0.5",
locale: locale_en,
},
{
name: "Test 'Accept-Language' request header which favours Spanish language",
header: "es;q=0.9, en;q=0.8",
locale: locale_es,
},
{
name: "Test 'Accept-Language' request header which favours French language",
header: "fr;q=0.9, en;q=0.8",
locale: locale_fr,
},
{
name: "Test 'Accept-Language' request header which favours Japan language",
header: "ja;q=0.8, en;q=0.7",
Expand All @@ -38,7 +48,7 @@ func TestLocales(t *testing.T) {
},
{
name: "Test empty 'Accept-Language' request header which doesn't match any supported languages, so defaults to English language",
header: "fr;q=0.5, de;q=0.8",
header: "cz;q=0.5, de;q=0.8",
locale: locale_en,
},
}
Expand Down