Skip to content

Commit b4f5319

Browse files
authored
feat: add locale display names in selector (#6561)
1 parent 78a28d9 commit b4f5319

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

libs/common-const/src/locales.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ export const SUPPORTED_LOCALES = [
88
export type SupportedLocale = (typeof SUPPORTED_LOCALES)[number] | 'pseudo'
99

1010
export const DEFAULT_LOCALE: SupportedLocale = 'en-US'
11+
12+
// Override display names shown in language selectors to ensure consistent wording
13+
export const LOCALE_DISPLAY_NAMES: Partial<Record<SupportedLocale, string>> = {
14+
'en-US': 'English (US)',
15+
'es-ES': 'Español (España)',
16+
'ru-RU': 'Русский (Россия)',
17+
}

libs/ui/src/pure/MenuBar/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import IMG_ICON_MENU_DOTS from '@cowprotocol/assets/images/menu-grid-dots.svg'
1616
import IMG_ICON_MENU_HAMBURGER from '@cowprotocol/assets/images/menu-hamburger.svg'
1717
import IMG_ICON_SETTINGS_GLOBAL from '@cowprotocol/assets/images/settings-global.svg'
1818
import IMG_ICON_X from '@cowprotocol/assets/images/x.svg'
19+
import { LOCALE_DISPLAY_NAMES } from '@cowprotocol/common-const'
1920
import { useMediaQuery, useOnClickOutside } from '@cowprotocol/common-hooks'
2021
import { addBodyClass, removeBodyClass } from '@cowprotocol/common-utils'
2122

@@ -102,6 +103,11 @@ const DAO_NAV_ITEMS: MenuItem[] = [
102103
]
103104

104105
const getLanguageName = (locale: string): string => {
106+
const override = LOCALE_DISPLAY_NAMES[locale as keyof typeof LOCALE_DISPLAY_NAMES]
107+
if (override) {
108+
return override
109+
}
110+
105111
const display = new Intl.DisplayNames([locale], { type: 'language' })
106112
const languageName = display.of(locale)
107113

0 commit comments

Comments
 (0)