From fb2b03f00f494b043ad69a5d838981fb7d5d45ac Mon Sep 17 00:00:00 2001 From: Gucheng Wang Date: Fri, 6 Jan 2023 19:26:00 +0800 Subject: [PATCH] Add category to applyToOtherLanguage() --- i18n/generate_test.go | 52 ++++++-------- i18n/util.go | 14 ++-- web/src/locales/es/data.json | 136 +++++++++++++++++++++++++++++------ 3 files changed, 145 insertions(+), 57 deletions(-) diff --git a/i18n/generate_test.go b/i18n/generate_test.go index e130a0e7..9a15f68a 100644 --- a/i18n/generate_test.go +++ b/i18n/generate_test.go @@ -15,28 +15,28 @@ package i18n import ( - "fmt" "testing" ) -func applyToOtherLanguage(dataEn *I18nData, lang string) { - dataOther := readI18nFile(lang) - println(dataOther) +func applyToOtherLanguage(category string, language string, i18nData *I18nData) { + newData := readI18nFile(category, language) + println(newData) - applyData(dataEn, dataOther) - writeI18nFile(lang, dataEn) + applyData(i18nData, newData) + writeI18nFile(category, language, i18nData) } func TestGenerateI18nStringsForFrontend(t *testing.T) { - dataEn := parseToData() - writeI18nFile("en", dataEn) + enData := parseToData() + writeI18nFile("frontend", "en", enData) - applyToOtherLanguage(dataEn, "de") - applyToOtherLanguage(dataEn, "fr") - applyToOtherLanguage(dataEn, "ja") - applyToOtherLanguage(dataEn, "ko") - applyToOtherLanguage(dataEn, "ru") - applyToOtherLanguage(dataEn, "zh") + applyToOtherLanguage("frontend", "de", enData) + applyToOtherLanguage("frontend", "es", enData) + applyToOtherLanguage("frontend", "fr", enData) + applyToOtherLanguage("frontend", "ja", enData) + applyToOtherLanguage("frontend", "ko", enData) + applyToOtherLanguage("frontend", "ru", enData) + applyToOtherLanguage("frontend", "zh", enData) } func TestGenerateI18nStringsForBackend(t *testing.T) { @@ -44,21 +44,15 @@ func TestGenerateI18nStringsForBackend(t *testing.T) { errName := getErrName(paths) - dataEn := getI18nJSONData(errName) + enData := getI18nJSONData(errName) - writeI18nFile("backend_en", dataEn) + writeI18nFile("backend", "en", enData) - applyToOtherLanguage(dataEn, "backend_de") - applyToOtherLanguage(dataEn, "backend_es") - applyToOtherLanguage(dataEn, "backend_fr") - applyToOtherLanguage(dataEn, "backend_ja") - applyToOtherLanguage(dataEn, "backend_ko") - applyToOtherLanguage(dataEn, "backend_ru") - applyToOtherLanguage(dataEn, "backend_zh") - - fmt.Println("Total Err Words:", len(errName)) - - for i := range errName { - fmt.Println(i) - } + applyToOtherLanguage("backend", "de", enData) + applyToOtherLanguage("backend", "es", enData) + applyToOtherLanguage("backend", "fr", enData) + applyToOtherLanguage("backend", "ja", enData) + applyToOtherLanguage("backend", "ko", enData) + applyToOtherLanguage("backend", "ru", enData) + applyToOtherLanguage("backend", "zh", enData) } diff --git a/i18n/util.go b/i18n/util.go index c1b789af..4e738232 100644 --- a/i18n/util.go +++ b/i18n/util.go @@ -27,18 +27,16 @@ var f embed.FS var langMap = make(map[string]map[string]map[string]string) // for example : langMap[en][account][Invalid information] = Invalid information -func getI18nFilePath(language string) string { - if strings.Contains(language, "backend") { - // change language from 'backend_en' to 'en' - language = language[8:] +func getI18nFilePath(category string, language string) string { + if category == "backend" { return fmt.Sprintf("../i18n/locales/%s/data.json", language) } else { return fmt.Sprintf("../web/src/locales/%s/data.json", language) } } -func readI18nFile(language string) *I18nData { - s := util.ReadStringFromPath(getI18nFilePath(language)) +func readI18nFile(category string, language string) *I18nData { + s := util.ReadStringFromPath(getI18nFilePath(category, language)) data := &I18nData{} err := util.JsonToStruct(s, data) @@ -48,13 +46,13 @@ func readI18nFile(language string) *I18nData { return data } -func writeI18nFile(language string, data *I18nData) { +func writeI18nFile(category string, language string, data *I18nData) { s := util.StructToJsonFormatted(data) s = strings.ReplaceAll(s, "\\u0026", "&") s += "\n" println(s) - util.WriteStringToPath(s, getI18nFilePath(language)) + util.WriteStringToPath(s, getI18nFilePath(category, language)) } func applyData(data1 *I18nData, data2 *I18nData) { diff --git a/web/src/locales/es/data.json b/web/src/locales/es/data.json index 5e91c51e..f4866598 100644 --- a/web/src/locales/es/data.json +++ b/web/src/locales/es/data.json @@ -5,7 +5,23 @@ "My Account": "Mi cuenta", "Sign Up": "Registrarme" }, + "adapter": { + "Edit Adapter": "Edit Adapter", + "Failed to sync policies": "Failed to sync policies", + "New Adapter": "New Adapter", + "Policies": "Policies", + "Policies - Tooltip": "Policies - Tooltip", + "Repeated policy rules": "Repeated policy rules", + "Sync": "Sync", + "Sync policies successfully": "Sync policies successfully" + }, "application": { + "Always": "Always", + "Auto signin": "Auto signin", + "Auto signin - Tooltip": "Auto signin - Tooltip", + "Background URL": "Background URL", + "Background URL - Tooltip": "Background URL - Tooltip", + "Center": "Center", "Copy SAML metadata URL": "Copiar SAML metadata URL", "Copy prompt page URL": "Copy prompt page URL", "Copy signin page URL": "Copiar URL de inicio de sesión", @@ -17,39 +33,57 @@ "Enable WebAuthn signin - Tooltip": "Habilitar inicio de sesión de WebAuthn - Tooltip", "Enable code signin": "Habilitar inicio de sesión por código", "Enable code signin - Tooltip": "Habilitar inicio de sesión por código - Tooltip", + "Enable side panel": "Enable side panel", "Enable signin session - Tooltip": "Enable signin session - Tooltip", "Enable signup": "Habilitar nuevos registros", "Enable signup - Tooltip": "Habilitar nuevos registros - Tooltip", + "Failed to sign in": "Failed to sign in", "File uploaded successfully": "El archivo ha sido subido con éxito", + "Form CSS": "Form CSS", + "Form CSS - Edit": "Form CSS - Edit", + "Form CSS - Tooltip": "Form CSS - Tooltip", + "Form position": "Form position", + "Form position - Tooltip": "Form position - Tooltip", "Grant types": "Grant types", "Grant types - Tooltip": "Grant types - Tooltip", + "Left": "Left", + "Logged in successfully": "Logged in successfully", + "Logged out successfully": "Logged out successfully", "New Application": "Nueva Aplicación", + "None": "None", "Password ON": "Constraseña ON", "Password ON - Tooltip": "Constraseña ON - Tooltip", + "Please input your application!": "Please input your application!", + "Please input your organization!": "Please input your organization!", "Please select a HTML file": "Seleccione un archivo HTML", "Prompt page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "Prompt page URL copied to clipboard successfully, please paste it into the incognito window or another browser", "Redirect URL": "URL de redirección", + "Redirect URL (Assertion Consumer Service POST Binding URL) - Tooltip": "Redirect URL (Assertion Consumer Service POST Binding URL) - Tooltip", "Redirect URLs": "URLs de redirección", "Redirect URLs - Tooltip": "URL de redirección - Tooltip", "Refresh token expire": "Expiración del Refresh Token", "Refresh token expire - Tooltip": "Expiración del Refresh Token - Tooltip", + "Right": "Right", + "Rule": "Rule", + "SAML Reply URL": "SAML Reply URL", "SAML metadata": "SAML metadata", "SAML metadata - Tooltip": "SAML metadata - Tooltip", "SAML metadata URL copied to clipboard successfully": "SAML metadata URL copiado al portapapeles con éxito", + "Side panel HTML": "Side panel HTML", + "Side panel HTML - Edit": "Side panel HTML - Edit", + "Side panel HTML - Tooltip": "Side panel HTML - Tooltip", + "Sign Up Error": "Sign Up Error", "Signin page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "Signin page URL copied to clipboard successfully, please paste it into the incognito window or another browser", "Signin session": "Signin session", - "Sign Up Error": "Sign Up Error", "Signup items": "Signup items", "Signup items - Tooltip": "Signup items - Tooltip", "Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser", + "The application does not allow to sign up new account": "The application does not allow to sign up new account", "Token expire": "Expiración del Token", "Token expire - Tooltip": "Expiración del Token - Tooltip", "Token format": "Formato del Token", "Token format - Tooltip": "Formato del Token - Tooltip", - "You are unexpected to see this prompt page": "You are unexpected to see this prompt page", - "Rule": "Rule", - "None": "None", - "Always": "Always" + "You are unexpected to see this prompt page": "You are unexpected to see this prompt page" }, "cert": { "Bit size": "Tamaño del Bit", @@ -97,13 +131,14 @@ "Please input your username!": "Por favor ingrese su nombre de usuario!", "Reset": "Reiniciar", "Retrieve password": "Recuperar Contraseña", - "Unknown forget type": "Tipo de olvido desconocido", + "Unknown forget type: ": "Unknown forget type: ", "Verify": "Verificar" }, "general": { "Action": "Acción", "Adapter": "Adaptador", "Adapter - Tooltip": "Adaptador - Tooltip", + "Adapters": "Adapters", "Add": "Agregar", "Affiliation URL": "URL de Afiliación", "Affiliation URL - Tooltip": "URL de Afiliación - Tooltip", @@ -120,7 +155,13 @@ "Certs": "Certificados", "Click to Upload": "Click para subir archivo", "Client IP": "IP del Cliente", + "Close": "Close", + "Compact": "Compact", "Created time": "Fecha de creación", + "Dark": "Dark", + "Default": "Default", + "Default application": "Default application", + "Default application - Tooltip": "Default application - Tooltip", "Default avatar": "Avatar por defecto", "Default avatar - Tooltip": "Avatar por defecto - Tooltip", "Delete": "Eliminar", @@ -132,6 +173,10 @@ "Edit": "Editar", "Email": "Email", "Email - Tooltip": "Email - Tooltip", + "Failed to add": "Failed to add", + "Failed to connect to server": "Failed to connect to server", + "Failed to delete": "Failed to delete", + "Failed to save": "Failed to save", "Favicon": "Favicon", "Favicon - Tooltip": "Favicon - Tooltip", "First name": "Nombre", @@ -145,11 +190,14 @@ "Is enabled - Tooltip": "Está habilitado - Tooltip", "LDAPs": "LDAPs", "LDAPs - Tooltip": "LDAPs - Tooltip", + "Languages": "Languages", + "Languages - Tooltip": "Languages - Tooltip", "Last name": "Apellido", "Logo": "Logo", "Logo - Tooltip": "Logo - Tooltip", "Master password": "Contraseña maestra", "Master password - Tooltip": "Contraseña maestra - Tooltip", + "Menu": "Menu", "Method": "Metodo", "Model": "Modelo", "Model - Tooltip": "Modelo - Tooltip", @@ -188,6 +236,8 @@ "Roles - Tooltip": "Roles - Tooltip", "Save": "Guardar", "Save & Exit": "Guardar & Volver", + "Session ID": "Session ID", + "Sessions": "Sessions", "Signin URL": "URL de inicio de sesión", "Signin URL - Tooltip": "URL de inicio de sesión - Tooltip", "Signup URL": "URL de registro", @@ -196,12 +246,16 @@ "Signup application - Tooltip": "Aplicación de inicio de sesión - Tooltip", "Sorry, the page you visited does not exist.": "Lo sentimos, la página que visitaste no existe.", "Sorry, the user you visited does not exist or you are not authorized to access this user.": "Lo sentimos, el usuario que visitaste no existe o no estás autorizado para acceder.", - "Sorry, you do not have permission to access this page.": "Lo sentimos, no tienes permiso para acceder a esta página.", + "Sorry, you do not have permission to access this page or logged in status invalid.": "Sorry, you do not have permission to access this page or logged in status invalid.", "State": "Estado", "State - Tooltip": "Estado - Tooltip", + "Successfully added": "Successfully added", + "Successfully deleted": "Successfully deleted", + "Successfully saved": "Successfully saved", "Swagger": "Swagger", "Sync": "Sincronizador", "Syncers": "Sincronizadores", + "SysInfo": "SysInfo", "Timestamp": "Timestamp", "Tokens": "Tokens", "URL": "URL", @@ -250,6 +304,7 @@ "Continue with": "Continuar con", "Email or phone": "Email o teléfono", "Forgot password?": "¿Olvidó su contraseña?", + "Loading": "Loading", "Logging out...": "Cerrando su sesión...", "No account?": "¿No estás registrado?", "Or sign in with another account": "O inicia sesión con otra cuenta", @@ -259,14 +314,16 @@ "Please input your password!": "¡Por favor ingrese su contraseña!", "Please input your password, at least 6 characters!": "Su contraseña debe contener al menos 6 caracteres.", "Please input your username, Email or phone!": "¡Ingrese su nombre de usuario, correo electrónico o teléfono!", + "Redirecting, please wait.": "Redirecting, please wait.", "Sign In": "Iniciar de sesión", "Sign in with WebAuthn": "Iniciar de sesión con WebAuthn", - "Sign in with code": "Iniciar de sesión con código", - "Sign in with password": "Iniciar de sesión con contraseña", "Sign in with {type}": "Iniciar de sesión con {type}", "Signing in...": "Iniciando de sesión...", + "Successfully logged in with webauthn credentials": "Successfully logged in with webauthn credentials", "The input is not valid Email or Phone!": "El valor ingresado no es un Email o Teléfono válido!", "To access": "Para ingresar", + "Verification Code": "Verification Code", + "WebAuthn": "WebAuthn", "sign up now": "Regístrate ahora", "username, Email or phone": "nombre de usuario, correo electrónico o teléfono" }, @@ -282,17 +339,20 @@ "Default avatar": "Avatar por defecto", "Edit Organization": "Editar Organización", "Favicon": "Favicon", + "InitScore": "InitScore", "Is profile public": "Es el perfil publico", "Is profile public - Tooltip": "Es el perfil publico - Tooltip", + "Modify rule": "Modify rule", "New Organization": "Nueva Organización", "Soft deletion": "Eliminación Soft", "Soft deletion - Tooltip": "Eliminación Soft - Tooltip", "Tags": "Etiquetas", "Tags - Tooltip": "Etiquetas - Tooltip", + "The user's initScore - Tooltip": "The user's initScore - Tooltip", + "View rule": "View rule", + "Visible": "Visible", "Website URL": "URL del sitio web", - "Website URL - Tooltip": "URL del sitio web - Tooltip", - "modifyRule": "modifyRule", - "viewRule": "viewRule" + "Website URL - Tooltip": "URL del sitio web - Tooltip" }, "payment": { "Confirm your invoice information": "Confirma la información de tu factura", @@ -349,14 +409,20 @@ "permission": { "Actions": "Acciones", "Actions - Tooltip": "Acciones - Tooltip", + "Admin": "Admin", + "Allow": "Allow", "Approve time": "Fecha de aprobación", "Approve time - Tooltip": "Fecha de aprobación - Tooltip", + "Approved": "Approved", "Approver": "Aprobador", "Approver - Tooltip": "Aprobador - Tooltip", + "Deny": "Deny", "Edit Permission": "Editar Permiso", "Effect": "Effect", "Effect - Tooltip": "Effect - Tooltip", "New Permission": "Nuevo Permiso", + "Pending": "Pending", + "Read": "Read", "Resource type": "Tipo de recurso", "Resource type - Tooltip": "Tipo de recurso - Tooltip", "Resources": "Recursos", @@ -364,7 +430,9 @@ "State": "Estado", "State - Tooltip": "Estado - Tooltip", "Submitter": "Submitter", - "Submitter - Tooltip": "Submitter - Tooltip" + "Submitter - Tooltip": "Submitter - Tooltip", + "TreeNode": "TreeNode", + "Write": "Write" }, "product": { "Alipay": "Alipay", @@ -373,9 +441,12 @@ "CNY": "CNY", "Currency": "Moneda", "Currency - Tooltip": "Moneda - Tooltip", + "Description": "Description", + "Description - Tooltip": "Description - Tooltip", "Detail": "Detalle", "Detail - Tooltip": "Detalle - Tooltip", "Edit Product": "Editar Producto", + "I have completed the payment": "I have completed the payment", "Image": "Imagen", "Image - Tooltip": "Imagen - Tooltip", "New Product": "Nuevo producto", @@ -384,6 +455,8 @@ "Payment providers - Tooltip": "Pasarelas de pago - Tooltip", "Paypal": "Paypal", "Placing order...": "Creando su pedido...", + "Please provide your username in the remark": "Please provide your username in the remark", + "Please scan the QR code to pay": "Please scan the QR code to pay", "Price": "Precio", "Price - Tooltip": "Precio - Tooltip", "Quantity": "Cantidad", @@ -417,6 +490,9 @@ "Bucket": "Bucket", "Bucket - Tooltip": "Bucket - Tooltip", "Can not parse Metadata": "Can not parse Metadata", + "Can signin": "Can signin", + "Can signup": "Can signup", + "Can unlink": "Can unlink", "Category": "Categoria", "Category - Tooltip": "Categoria - Tooltip", "Channel No.": "Channel No.", @@ -439,6 +515,8 @@ "Email Content - Tooltip": "Contenido del Email - Tooltip", "Email Title": "Titulo del Email", "Email Title - Tooltip": "Titulo del Email - Tooltip", + "Enable QR code": "Enable QR code", + "Enable QR code - Tooltip": "Enable QR code - Tooltip", "Endpoint": "Endpoint", "Endpoint (Intranet)": "Endpoint (Intranet)", "Host": "Host", @@ -456,14 +534,18 @@ "New Provider": "Nuevo Proveedor", "Parse": "Parsear", "Parse Metadata successfully": "Metadata parseada con éxito", + "Path prefix": "Path prefix", + "Please use WeChat and scan the QR code to sign in": "Please use WeChat and scan the QR code to sign in", "Port": "Puerto", "Port - Tooltip": "Puerto - Tooltip", + "Prompted": "Prompted", "Provider URL": "URL del Proveedor", "Provider URL - Tooltip": "URL del Proveedor - Tooltip", "Region ID": "Region ID", "Region ID - Tooltip": "Region ID - Tooltip", "Region endpoint for Internet": "Region endpoint for Internet", "Region endpoint for Intranet": "Region endpoint for Intranet", + "Required": "Required", "SAML 2.0 Endpoint (HTTP)": "SAML 2.0 Endpoint (HTTP)", "SMS account": "SMS account", "SMS account - Tooltip": "SMS account - Tooltip", @@ -500,19 +582,16 @@ "Test Connection": "Probar Conexión", "Test Email": "Probar Email", "Test Email - Tooltip": "Probar Email - Tooltip", + "The prefix path of the file - Tooltip": "The prefix path of the file - Tooltip", "Token URL": "Token URL", "Token URL - Tooltip": "Token URL - Tooltip", "Type": "Tipo", "Type - Tooltip": "Tipo - Tooltip", "UserInfo URL": "UserInfo URL", "UserInfo URL - Tooltip": "UserInfo URL - Tooltip", - "alertType": "alertType", - "canSignIn": "canSignIn", - "canSignUp": "canSignUp", - "canUnlink": "canUnlink", - "prompted": "prompted", - "required": "required", - "visible": "visible" + "Visible": "Visible", + "admin (share)": "admin (share)", + "alertType": "alertType" }, "record": { "Is Triggered": "Esta activado" @@ -597,6 +676,18 @@ "Table primary key": "Clave primaria de la tabla", "Table primary key - Tooltip": "Clave primaria de la tabla - Tooltip" }, + "system": { + "About Casdoor": "About Casdoor", + "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS", + "CPU Usage": "CPU Usage", + "Community": "Community", + "Get CPU Usage Failed": "Get CPU Usage Failed", + "Get Memory Usage Failed": "Get Memory Usage Failed", + "Memory Usage": "Memory Usage", + "Official Website": "Official Website", + "Unknown Version": "Unknown Version", + "Version": "Version" + }, "token": { "Access token": "Token de acceso", "Authorization code": "Código de autorización", @@ -637,9 +728,11 @@ "Is forbidden - Tooltip": "Está prohibido - Tooltip", "Is global admin": "Es admin global", "Is global admin - Tooltip": "Es admin global - Tooltip", + "Keys": "Keys", "Link": "Enlace", "Location": "Ubicación", "Location - Tooltip": "Ubicación - Tooltip", + "Managed accounts": "Managed accounts", "Modify password...": "Cambiar contraseña...", "New Email": "Nuevo Email", "New Password": "Nueva Contraseña", @@ -649,7 +742,9 @@ "Old Password": "Contraseña anterior", "Password": "Contraseña", "Password Set": "Password Set", + "Please select avatar from resources": "Please select avatar from resources", "Properties": "Propiedades", + "Properties - Tooltip": "Properties - Tooltip", "Re-enter New": "Reingrese de nuevo", "Reset Email...": "Cambiar Email...", "Reset Phone...": "Cambiar Phone...", @@ -665,6 +760,7 @@ "Unlink": "Desvincular", "Upload (.xlsx)": "Subir archivo (.xlsx)", "Upload a photo": "Subir foto", + "Values": "Values", "WebAuthn credentials": "WebAuthn credentials", "input password": "input password" },