From c85395f21d7e27ba16f4b9005e7f2f2452cdd7f8 Mon Sep 17 00:00:00 2001 From: Dixsie Wolmers Date: Wed, 26 Feb 2020 13:22:12 -0600 Subject: Persist language settings using local storage When user logs in, language setting will be stored in local storage. Once stored, user does not have to re-select preferred language, but can still update language settings on the login page. Before a language is saved to local storage the locale = null Renamed 'en.json' to 'en-US' because the vue i18n plugin defaults to 'en-US' when a language is not selected or null. https://github.com/kazupon/vue-i18n/blob/v8.x/src/index.js#L67 Signed-off-by: Dixsie Wolmers Change-Id: I577db3c4578eab30fbfae997dad0ece456fdf231 --- src/i18n.js | 11 ++- src/locales/en-US.json | 209 ++++++++++++++++++++++++++++++++++++++++++++++ src/locales/en.json | 209 ---------------------------------------------- src/views/Login/Login.vue | 5 +- 4 files changed, 219 insertions(+), 215 deletions(-) create mode 100644 src/locales/en-US.json delete mode 100644 src/locales/en.json diff --git a/src/i18n.js b/src/i18n.js index 09b3f4ca..745d0504 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -21,9 +21,12 @@ function loadLocaleMessages() { } export default new VueI18n({ - // default language is English - locale: 'en', - // locale messages with a message key that doesn't exist will fallback to English - fallbackLocale: 'en', + // Get default locale from local storage + locale: localStorage.getItem('storedLanguage'), + // Locales that don't exist will fallback to English + fallbackLocale: 'en-US', + // Falling back to fallbackLocale generates two console warnings + // Silent fallback suppresses console warnings when using fallback + silentFallbackWarn: true, messages: loadLocaleMessages() }); diff --git a/src/locales/en-US.json b/src/locales/en-US.json new file mode 100644 index 00000000..0de52987 --- /dev/null +++ b/src/locales/en-US.json @@ -0,0 +1,209 @@ +{ + "global": { + "action": { + "confirm": "Confirm", + "cancel": "Cancel", + "delete": "Delete", + "disable": "Disable", + "enable": "Enable", + "save": "Save", + "selected": "Selected" + }, + "ariaLabel": { + "showPassword": "Show password as plain text. Note: this will visually expose your password on the screen." + }, + "form": { + "fieldRequired": "Field required", + "invalidFormat": "Invalid format", + "lengthMustBeBetween": "Length must be between %{min} – %{max} characters", + "mustBeAtLeast": "Must be at least %{value}", + "selectAnOption": "Select an option", + "valueMustBeBetween": "Value must be between %{min} – %{max}" + }, + "status": { + "disabled": "Disabled", + "enabled": "Enabled", + "error": "Error", + "notAvailable": "Not available", + "off": "Off", + "on": "On", + "success": "Success", + "warning": "Warning" + } + }, + "appHeader": { + "bmcSystemManagement": "BMC System Management", + "health": "Health", + "logOut": "Log out", + "power": "Power", + "refresh": "Refresh", + "skipToContent": "Skip to content" + }, + "appNavigation": { + "accessControl": "Access Control", + "configuration": "Configuration", + "control": "Control", + "eventLog": "@:appPageTitle.eventLog", + "firmware": "@:appPageTitle.firmware", + "hardwareStatus": "@:appPageTitle.hardwareStatus", + "health": "Health", + "ldap": "@:appPageTitle.ldap", + "localUserManagement": "@:appPageTitle.localUserManagement", + "managePowerUsage": "@:appPageTitle.managePowerUsage", + "networkSettings": "@:appPageTitle.networkSettings", + "overview": "@:appPageTitle.overview", + "rebootBmc": "@:appPageTitle.rebootBmc", + "sensors": "@:appPageTitle.sensors", + "serverLed": "@:appPageTitle.serverLed", + "serverPowerOperations": "@:appPageTitle.serverPowerOperations", + "snmpSettings": "@:appPageTitle.snmpSettings", + "sslCertificates": "@:appPageTitle.sslCertificates" + }, + "appPageTitle": { + "eventLog": "Event log", + "firmware": "Firmware", + "hardwareStatus": "Hardware status", + "ldap": "LDAP", + "localUserManagement": "Local user management", + "login": "Login", + "managePowerUsage": "Manage power usage", + "networkSettings": "Network settings", + "overview": "Overview", + "rebootBmc": "Reboot BMC", + "sensors": "Sensors", + "serverLed": "Server LED", + "serverPowerOperations": "Server power operations", + "snmpSettings": "SNMP settings", + "sslCertificates": "SSL Certificates", + "unauthorized": "Unauthorized" + }, + "pageLocalUserManagement": { + "accountPolicySettings": "Account policy settings", + "addUser": "Add user", + "deleteUser": "Delete user", + "editUser": "Edit user", + "viewPrivilegeRoleDescriptions": "View privilege role descriptions", + "modal": { + "accountStatus": "Account status", + "automaticAfterTimeout": "Automatic after timeout", + "cannotStartWithANumber": "Cannot start with a number", + "confirmUserPassword": "Confirm user password", + "deleteConfirmMessage": "Are you sure you want to delete user '%{user}'? This action cannot be undone.", + "manual": "Manual", + "maxFailedLoginAttempts": "Max failed login attempts", + "noSpecialCharactersExceptUnderscore": "No special characters except underscore", + "passwordMustBeBetween": "Password must be between %{min} – %{max} characters", + "passwordsDoNotMatch": "Passwords do not match", + "privilege": "Privilege", + "timeoutDurationSeconds": "Timeout duration (seconds)", + "username": "Username", + "userPassword": "User password", + "userUnlockMethod": "User unlock method" + }, + "table": { + "privilege": "Privilege", + "status": "Status", + "username": "Username" + }, + "tableRoles": { + "configureComponentsManagedByThisService": "Configure components managed by this service", + "configureManagerResources": "Configure manager resources", + "configureUsersAndTheirAccounts": "Configure users and their accounts", + "ipmiAccessPoint": "IPMI access point", + "logInToTheServiceAndReadResources": "Log in to the service and read resources", + "redfishAccessPoint": "Redfish access point", + "sshAccessPoint": "SSH access point", + "updatePasswordForCurrentUserAccount": "Update password for current user account", + "webUiAccessPoint": "WebUI access point" + }, + "toast": { + "errorDeleteUsers": "Error deleting %{count} user. | Error deleting %{count} users.", + "errorDisableUsers": "Error disabling %{count} user. | Error disabling %{count} users.", + "errorEnableUsers": "Error enabling %{count} user. | Error enabling %{count} users.", + "errorSaveSettings": "Error saving account settings.", + "successDeleteUsers": "Successfully deleted %{count} user. | Successfully deleted %{count} users.", + "successDisableUsers": "Successfully disabled %{count} user. | Successfully disabled %{count} users.", + "successEnableUsers": "Successfully enabled %{count} user. | Successfully enabled %{count} users.", + "successSaveSettings": "Successfully saved account settings." + } + }, + "pageLogin": { + "language": "Language", + "logIn": "Log in", + "password": "Password", + "username": "Username", + "alert": { + "title": "Invalid username or password", + "action": "Try again after verifying your username and password are correct." + }, + "form": { + "english": "English", + "spanish": "Spanish" + } + }, + "pageOverview": { + "bmcInformation": "BMC information", + "firmwareVersion": "Firmware version", + "highPriorityEvents": "High priority events", + "manufacturer": "Manufacturer", + "model": "Model", + "networkInformation": "Network information", + "powerCap": "Power cap", + "powerConsumption": "Power consumption", + "serialNumber": "Serial number", + "serverInformation": "Server information", + "events": { + "date": "Date", + "description": "Description", + "id": "ID", + "noHighEventsMsg": "There are no high priority events to display at this time.", + "refCode": "Reference code", + "viewAllButton": "View all event logs" + }, + "network": { + "hostname": "Hostname", + "ipAddress": "IP address", + "macAddress": "MAC address" + }, + "quicklinks": { + "bmcTime": "BMC time", + "editNetworkSettings": "Edit network settings", + "serverLed": "Server LED", + "solConsole": "Serial over LAN console" + } + }, + "pageRebootBmc": { + "rebootBmc": "Reboot BMC", + "rebootInformation": "When you reboot the BMC, your web browser loses contact with the BMC for several minutes. When the BMC is back online, you may need to log in again.", + "modal": { + "confirmMessage": "Are you sure you want to reboot the BMC?", + "confirmTitle": "Confirm BMC reboot" + }, + "toast": { + "errorRebootStart": "Error rebooting BMC.", + "successRebootStart": "Rebooting BMC." + } + }, + "pageServerPowerOperations": { + "currentStatus": "Current status", + "hostname": "Hostname", + "hostStatus": "Host status", + "immediateReboot": "Immediate – Server reboots without OS shutting down; may cause data corruption", + "immediateShutdown": "Immediate - Server shuts down without OS shutting down; may cause data corruption", + "operationInProgress": "There are no options to display while a power operation is in progress. When complete, power operations will be displayed here.", + "operations": "Operations", + "orderlyReboot": "Orderly – OS shuts down, then server reboots", + "orderlyShutdown": "Orderly - OS shuts down, then server shuts down", + "powerOn": "Power on", + "reboot": "Reboot", + "rebootServer": "Reboot server", + "shutDown": "Shut down", + "shutdownServer": "Shutdown server", + "modal": { + "confirmRebootMessage": "Are you sure you want to reboot?", + "confirmRebootTitle": "Server reboot will cause outage", + "confirmShutdownMessage": "Are you sure you want to shut down?", + "confirmShutdownTitle": "Server shutdown will cause outage" + } + } +} \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json deleted file mode 100644 index 0de52987..00000000 --- a/src/locales/en.json +++ /dev/null @@ -1,209 +0,0 @@ -{ - "global": { - "action": { - "confirm": "Confirm", - "cancel": "Cancel", - "delete": "Delete", - "disable": "Disable", - "enable": "Enable", - "save": "Save", - "selected": "Selected" - }, - "ariaLabel": { - "showPassword": "Show password as plain text. Note: this will visually expose your password on the screen." - }, - "form": { - "fieldRequired": "Field required", - "invalidFormat": "Invalid format", - "lengthMustBeBetween": "Length must be between %{min} – %{max} characters", - "mustBeAtLeast": "Must be at least %{value}", - "selectAnOption": "Select an option", - "valueMustBeBetween": "Value must be between %{min} – %{max}" - }, - "status": { - "disabled": "Disabled", - "enabled": "Enabled", - "error": "Error", - "notAvailable": "Not available", - "off": "Off", - "on": "On", - "success": "Success", - "warning": "Warning" - } - }, - "appHeader": { - "bmcSystemManagement": "BMC System Management", - "health": "Health", - "logOut": "Log out", - "power": "Power", - "refresh": "Refresh", - "skipToContent": "Skip to content" - }, - "appNavigation": { - "accessControl": "Access Control", - "configuration": "Configuration", - "control": "Control", - "eventLog": "@:appPageTitle.eventLog", - "firmware": "@:appPageTitle.firmware", - "hardwareStatus": "@:appPageTitle.hardwareStatus", - "health": "Health", - "ldap": "@:appPageTitle.ldap", - "localUserManagement": "@:appPageTitle.localUserManagement", - "managePowerUsage": "@:appPageTitle.managePowerUsage", - "networkSettings": "@:appPageTitle.networkSettings", - "overview": "@:appPageTitle.overview", - "rebootBmc": "@:appPageTitle.rebootBmc", - "sensors": "@:appPageTitle.sensors", - "serverLed": "@:appPageTitle.serverLed", - "serverPowerOperations": "@:appPageTitle.serverPowerOperations", - "snmpSettings": "@:appPageTitle.snmpSettings", - "sslCertificates": "@:appPageTitle.sslCertificates" - }, - "appPageTitle": { - "eventLog": "Event log", - "firmware": "Firmware", - "hardwareStatus": "Hardware status", - "ldap": "LDAP", - "localUserManagement": "Local user management", - "login": "Login", - "managePowerUsage": "Manage power usage", - "networkSettings": "Network settings", - "overview": "Overview", - "rebootBmc": "Reboot BMC", - "sensors": "Sensors", - "serverLed": "Server LED", - "serverPowerOperations": "Server power operations", - "snmpSettings": "SNMP settings", - "sslCertificates": "SSL Certificates", - "unauthorized": "Unauthorized" - }, - "pageLocalUserManagement": { - "accountPolicySettings": "Account policy settings", - "addUser": "Add user", - "deleteUser": "Delete user", - "editUser": "Edit user", - "viewPrivilegeRoleDescriptions": "View privilege role descriptions", - "modal": { - "accountStatus": "Account status", - "automaticAfterTimeout": "Automatic after timeout", - "cannotStartWithANumber": "Cannot start with a number", - "confirmUserPassword": "Confirm user password", - "deleteConfirmMessage": "Are you sure you want to delete user '%{user}'? This action cannot be undone.", - "manual": "Manual", - "maxFailedLoginAttempts": "Max failed login attempts", - "noSpecialCharactersExceptUnderscore": "No special characters except underscore", - "passwordMustBeBetween": "Password must be between %{min} – %{max} characters", - "passwordsDoNotMatch": "Passwords do not match", - "privilege": "Privilege", - "timeoutDurationSeconds": "Timeout duration (seconds)", - "username": "Username", - "userPassword": "User password", - "userUnlockMethod": "User unlock method" - }, - "table": { - "privilege": "Privilege", - "status": "Status", - "username": "Username" - }, - "tableRoles": { - "configureComponentsManagedByThisService": "Configure components managed by this service", - "configureManagerResources": "Configure manager resources", - "configureUsersAndTheirAccounts": "Configure users and their accounts", - "ipmiAccessPoint": "IPMI access point", - "logInToTheServiceAndReadResources": "Log in to the service and read resources", - "redfishAccessPoint": "Redfish access point", - "sshAccessPoint": "SSH access point", - "updatePasswordForCurrentUserAccount": "Update password for current user account", - "webUiAccessPoint": "WebUI access point" - }, - "toast": { - "errorDeleteUsers": "Error deleting %{count} user. | Error deleting %{count} users.", - "errorDisableUsers": "Error disabling %{count} user. | Error disabling %{count} users.", - "errorEnableUsers": "Error enabling %{count} user. | Error enabling %{count} users.", - "errorSaveSettings": "Error saving account settings.", - "successDeleteUsers": "Successfully deleted %{count} user. | Successfully deleted %{count} users.", - "successDisableUsers": "Successfully disabled %{count} user. | Successfully disabled %{count} users.", - "successEnableUsers": "Successfully enabled %{count} user. | Successfully enabled %{count} users.", - "successSaveSettings": "Successfully saved account settings." - } - }, - "pageLogin": { - "language": "Language", - "logIn": "Log in", - "password": "Password", - "username": "Username", - "alert": { - "title": "Invalid username or password", - "action": "Try again after verifying your username and password are correct." - }, - "form": { - "english": "English", - "spanish": "Spanish" - } - }, - "pageOverview": { - "bmcInformation": "BMC information", - "firmwareVersion": "Firmware version", - "highPriorityEvents": "High priority events", - "manufacturer": "Manufacturer", - "model": "Model", - "networkInformation": "Network information", - "powerCap": "Power cap", - "powerConsumption": "Power consumption", - "serialNumber": "Serial number", - "serverInformation": "Server information", - "events": { - "date": "Date", - "description": "Description", - "id": "ID", - "noHighEventsMsg": "There are no high priority events to display at this time.", - "refCode": "Reference code", - "viewAllButton": "View all event logs" - }, - "network": { - "hostname": "Hostname", - "ipAddress": "IP address", - "macAddress": "MAC address" - }, - "quicklinks": { - "bmcTime": "BMC time", - "editNetworkSettings": "Edit network settings", - "serverLed": "Server LED", - "solConsole": "Serial over LAN console" - } - }, - "pageRebootBmc": { - "rebootBmc": "Reboot BMC", - "rebootInformation": "When you reboot the BMC, your web browser loses contact with the BMC for several minutes. When the BMC is back online, you may need to log in again.", - "modal": { - "confirmMessage": "Are you sure you want to reboot the BMC?", - "confirmTitle": "Confirm BMC reboot" - }, - "toast": { - "errorRebootStart": "Error rebooting BMC.", - "successRebootStart": "Rebooting BMC." - } - }, - "pageServerPowerOperations": { - "currentStatus": "Current status", - "hostname": "Hostname", - "hostStatus": "Host status", - "immediateReboot": "Immediate – Server reboots without OS shutting down; may cause data corruption", - "immediateShutdown": "Immediate - Server shuts down without OS shutting down; may cause data corruption", - "operationInProgress": "There are no options to display while a power operation is in progress. When complete, power operations will be displayed here.", - "operations": "Operations", - "orderlyReboot": "Orderly – OS shuts down, then server reboots", - "orderlyShutdown": "Orderly - OS shuts down, then server shuts down", - "powerOn": "Power on", - "reboot": "Reboot", - "rebootServer": "Reboot server", - "shutDown": "Shut down", - "shutdownServer": "Shutdown server", - "modal": { - "confirmRebootMessage": "Are you sure you want to reboot?", - "confirmRebootTitle": "Server reboot will cause outage", - "confirmShutdownMessage": "Are you sure you want to shut down?", - "confirmShutdownTitle": "Server shutdown will cause outage" - } - } -} \ No newline at end of file diff --git a/src/views/Login/Login.vue b/src/views/Login/Login.vue index 10ebb930..fd6e711c 100644 --- a/src/views/Login/Login.vue +++ b/src/views/Login/Login.vue @@ -82,6 +82,7 @@