Skip to content

Commit

Permalink
Merge pull request #1040 from opentripplanner/load-simplified-chinese
Browse files Browse the repository at this point in the history
fix(i18n): Correctly load OTP-UI's Chinese (simplified) files.
  • Loading branch information
binh-dam-ibigroup authored Oct 18, 2023
2 parents fc57cad + bae420f commit b2dedb4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/util/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ async function loadOtpUiLocaleData(matchedLocale) {
*/
export async function loadLocaleData(matchedLocale, customMessages) {
let messages
let otpUiLocale = matchedLocale
switch (matchedLocale) {
case 'es': // Spanish translation is not specific to a region
messages = await import('../../i18n/es.yml')
Expand All @@ -130,15 +131,18 @@ export async function loadLocaleData(matchedLocale, customMessages) {
case 'vi': // Vietnamese translation is not specific to a region
messages = await import('../../i18n/vi.yml')
break
case 'zh': // Chinese translation is not specific to a region
case 'zh': // Chinese (Simplified) translation is not specific to a region
messages = await import('../../i18n/zh.yml')
// The OTP-UI files for Chinese (Simplified) are (correctly) named `zh_Hans`.
// TODO: Rename this repo's zh files to zh_Hans
otpUiLocale = 'zh_Hans'
break
default:
messages = await import('../../i18n/en-US.yml')
break
}

const otpUiMessages = await loadOtpUiLocaleData(matchedLocale)
const otpUiMessages = await loadOtpUiLocaleData(otpUiLocale)

// Merge custom strings into the standard language strings.
const mergedMessages = {
Expand Down

0 comments on commit b2dedb4

Please sign in to comment.