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": {
"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": {
"title": "Teilen",
"description": "Teile die URL, damit andere Mitglieder die Gruppe sehen und Ausgaben hinzufügen können.",

View File

@@ -294,20 +294,6 @@
"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": {
"title": "Share",
"description": "For other participants to see the group and add expenses, share its URL with them.",

View File

@@ -294,20 +294,6 @@
"Settings": {
"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": {
"title": "Compartir",
"description": "Para que otros participantes puedan ver el grupo y añadir gastos, compárteles su URL.",

View File

@@ -294,20 +294,6 @@
"Settings": {
"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": {
"title": "Jaa",
"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": {
"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": {
"title": "Partager",
"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": {
"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": {
"title": "Condividi",
"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": {
"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": {
"title": "Udostępnij",
"description": "Aby inni uczestnicy mogli zobaczyć grupę i dodać wydatki, udostępnij im jej adres URL.",

View File

@@ -294,20 +294,6 @@
"Settings": {
"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": {
"title": "Distribuie",
"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": {
"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": {
"title": "Поделиться",
"description": "Чтобы другие участники получили доступ к этой группе и смогли добавлять расходы, отправьте им этот URL.",

View File

@@ -294,20 +294,6 @@
"Settings": {
"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": {
"title": "Поділитися",
"description": "Щоб інші учасники могли побачити групу і додати витрати, поділіться з ними її URL",

View File

@@ -294,20 +294,6 @@
"Settings": {
"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": {
"title": "分享",
"description": "请将此URL分享给其他群组成员以使其可以查看群组并添加消费。",

View File

@@ -294,20 +294,6 @@
"Settings": {
"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": {
"title": "分享",
"description": "將此網址分享給其他人以加入群組並查看及新增消費紀錄",

View File

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

View File

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