mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-11 10:06:13 +01:00
Put locale labels outside of translations
This commit is contained in:
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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分享给其他群组成员,以使其可以查看群组并添加消费。",
|
||||
|
||||
@@ -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": "將此網址分享給其他人以加入群組並查看及新增消費紀錄",
|
||||
|
||||
@@ -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>
|
||||
|
||||
33
src/i18n.ts
33
src/i18n.ts
@@ -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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user