Put locale labels outside of translations

This commit is contained in:
Sebastien Castiel
2024-12-07 11:37:39 -05:00
parent 5374d9e9c7
commit 2c973f976f
14 changed files with 29 additions and 190 deletions

View File

@@ -294,20 +294,6 @@
"Settings": { "Settings": {
"title": "Einstellungen" "title": "Einstellungen"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文 (Traditional Chinese)",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "Teilen", "title": "Teilen",
"description": "Teile die URL, damit andere Mitglieder die Gruppe sehen und Ausgaben hinzufügen können.", "description": "Teile die URL, damit andere Mitglieder die Gruppe sehen und Ausgaben hinzufügen können.",

View File

@@ -294,20 +294,6 @@
"Settings": { "Settings": {
"title": "Settings" "title": "Settings"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文 (Traditional Chinese)",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "Share", "title": "Share",
"description": "For other participants to see the group and add expenses, share its URL with them.", "description": "For other participants to see the group and add expenses, share its URL with them.",

View File

@@ -294,20 +294,6 @@
"Settings": { "Settings": {
"title": "Ajustes" "title": "Ajustes"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文 (Traditional Chinese)",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "Compartir", "title": "Compartir",
"description": "Para que otros participantes puedan ver el grupo y añadir gastos, compárteles su URL.", "description": "Para que otros participantes puedan ver el grupo y añadir gastos, compárteles su URL.",

View File

@@ -294,20 +294,6 @@
"Settings": { "Settings": {
"title": "Asetukset" "title": "Asetukset"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文 (Traditional Chinese)",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "Jaa", "title": "Jaa",
"description": "Jaa ryhmän URL muille jäsenille, jotta he voivat nähdä sen ja lisätä kuluja.", "description": "Jaa ryhmän URL muille jäsenille, jotta he voivat nähdä sen ja lisätä kuluja.",

View File

@@ -294,20 +294,6 @@
"Settings": { "Settings": {
"title": "Paramètres" "title": "Paramètres"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文 (Traditional Chinese)",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "Partager", "title": "Partager",
"description": "Pour que d'autres participants puissent voir le groupe et ajouter des dépenses, partagez son URL avec eux.", "description": "Pour que d'autres participants puissent voir le groupe et ajouter des dépenses, partagez son URL avec eux.",

View File

@@ -294,20 +294,6 @@
"Settings": { "Settings": {
"title": "Impostazioni" "title": "Impostazioni"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文 (Traditional Chinese)",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "Condividi", "title": "Condividi",
"description": "Per consentire agli altri partecipanti di vedere il gruppo e aggiungere spese, condividi il suo URL con loro.", "description": "Per consentire agli altri partecipanti di vedere il gruppo e aggiungere spese, condividi il suo URL con loro.",

View File

@@ -293,20 +293,6 @@
"Settings": { "Settings": {
"title": "Ustawienia" "title": "Ustawienia"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文 (Traditional Chinese)",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "Udostępnij", "title": "Udostępnij",
"description": "Aby inni uczestnicy mogli zobaczyć grupę i dodać wydatki, udostępnij im jej adres URL.", "description": "Aby inni uczestnicy mogli zobaczyć grupę i dodać wydatki, udostępnij im jej adres URL.",

View File

@@ -294,20 +294,6 @@
"Settings": { "Settings": {
"title": "Setări" "title": "Setări"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文 (Traditional Chinese)",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "Distribuie", "title": "Distribuie",
"description": "Pentru ca ceilalți participanți să poată vedea grupul și cheltuielile adăugate, distribuie URL-ul acestuia cu ei.", "description": "Pentru ca ceilalți participanți să poată vedea grupul și cheltuielile adăugate, distribuie URL-ul acestuia cu ei.",

View File

@@ -294,20 +294,6 @@
"Settings": { "Settings": {
"title": "Настройки" "title": "Настройки"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文 (Traditional Chinese)",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "Поделиться", "title": "Поделиться",
"description": "Чтобы другие участники получили доступ к этой группе и смогли добавлять расходы, отправьте им этот URL.", "description": "Чтобы другие участники получили доступ к этой группе и смогли добавлять расходы, отправьте им этот URL.",

View File

@@ -294,20 +294,6 @@
"Settings": { "Settings": {
"title": "Налаштування" "title": "Налаштування"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文 (Traditional Chinese)",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "Поділитися", "title": "Поділитися",
"description": "Щоб інші учасники могли побачити групу і додати витрати, поділіться з ними її URL", "description": "Щоб інші учасники могли побачити групу і додати витрати, поділіться з ними її URL",

View File

@@ -294,20 +294,6 @@
"Settings": { "Settings": {
"title": "设定" "title": "设定"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "分享", "title": "分享",
"description": "请将此URL分享给其他群组成员以使其可以查看群组并添加消费。", "description": "请将此URL分享给其他群组成员以使其可以查看群组并添加消费。",

View File

@@ -294,20 +294,6 @@
"Settings": { "Settings": {
"title": "設定" "title": "設定"
}, },
"Locale": {
"en-US": "English",
"fi": "Suomi",
"fr-FR": "Français",
"es": "Español",
"de-DE": "Deutsch",
"zh-CN": "Chinese (Simplified)",
"zh-TW": "正體中文",
"pl-PL": "Polski",
"ru-RU": "Русский",
"it-IT": "Italiano",
"ua-UA": "Українська",
"ro": "Română"
},
"Share": { "Share": {
"title": "分享", "title": "分享",
"description": "將此網址分享給其他人以加入群組並查看及新增消費紀錄", "description": "將此網址分享給其他人以加入群組並查看及新增消費紀錄",

View File

@@ -7,24 +7,26 @@ import {
DropdownMenuItem, DropdownMenuItem,
DropdownMenuTrigger, DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu' } from '@/components/ui/dropdown-menu'
import { locales } from '@/i18n' import { Locale, localeLabels } from '@/i18n'
import { setUserLocale } from '@/lib/locale' import { setUserLocale } from '@/lib/locale'
import { useLocale, useTranslations } from 'next-intl' import { useLocale } from 'next-intl'
export function LocaleSwitcher() { export function LocaleSwitcher() {
const t = useTranslations('Locale') const locale = useLocale() as Locale
const locale = useLocale()
return ( return (
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger asChild> <DropdownMenuTrigger asChild>
<Button variant="ghost" size="sm" className="-my-3 text-primary"> <Button variant="ghost" size="sm" className="-my-3 text-primary">
<span>{t(locale)}</span> <span>{localeLabels[locale]}</span>
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent> <DropdownMenuContent>
{locales.map((locale) => ( {Object.entries(localeLabels).map(([locale, label]) => (
<DropdownMenuItem key={locale} onClick={() => setUserLocale(locale)}> <DropdownMenuItem
{t(locale)} key={locale}
onClick={() => setUserLocale(locale as Locale)}
>
{label}
</DropdownMenuItem> </DropdownMenuItem>
))} ))}
</DropdownMenuContent> </DropdownMenuContent>

View File

@@ -1,20 +1,25 @@
import { getRequestConfig } from 'next-intl/server' import { getRequestConfig } from 'next-intl/server'
import { getUserLocale } from './lib/locale' import { getUserLocale } from './lib/locale'
export const locales = [ export const localeLabels = {
'en-US', 'en-US': 'English',
'fi', fi: 'Suomi',
'fr-FR', 'fr-FR': 'Français',
'es', es: 'Español',
'de-DE', 'de-DE': 'Deutsch',
'zh-CN', 'zh-CN': '简体中文',
'zh-TW', 'zh-TW': '正體中文',
'ru-RU', 'pl-PL': 'Polski',
'it-IT', 'ru-RU': 'Русский',
'ua-UA', 'it-IT': 'Italiano',
'ro', 'ua-UA': 'Українська',
] as const ro: 'Română',
export type Locale = (typeof locales)[number] } as const
export const locales: (keyof typeof localeLabels)[] = Object.keys(
localeLabels,
) as any
export type Locale = keyof typeof localeLabels
export type Locales = ReadonlyArray<Locale> export type Locales = ReadonlyArray<Locale>
export const defaultLocale: Locale = 'en-US' export const defaultLocale: Locale = 'en-US'