bsky-app/src/locale/i18n.ts

102 lines
3.3 KiB
TypeScript
Raw Normal View History

import {useEffect} from 'react'
import {i18n} from '@lingui/core'
2024-04-04 01:50:15 +02:00
import {sanitizeAppLanguageSetting} from '#/locale/helpers'
import {AppLanguage} from '#/locale/languages'
import {messages as messagesCa} from '#/locale/locales/ca/messages'
2024-01-24 05:39:35 +01:00
import {messages as messagesDe} from '#/locale/locales/de/messages'
2024-04-04 01:50:15 +02:00
import {messages as messagesEn} from '#/locale/locales/en/messages'
import {messages as messagesEs} from '#/locale/locales/es/messages'
2024-02-19 07:09:49 +01:00
import {messages as messagesFi} from '#/locale/locales/fi/messages'
import {messages as messagesFr} from '#/locale/locales/fr/messages'
import {messages as messagesHi} from '#/locale/locales/hi/messages'
2024-04-04 01:50:15 +02:00
import {messages as messagesId} from '#/locale/locales/id/messages'
import {messages as messagesIt} from '#/locale/locales/it/messages'
import {messages as messagesJa} from '#/locale/locales/ja/messages'
import {messages as messagesKo} from '#/locale/locales/ko/messages'
import {messages as messagesPt_BR} from '#/locale/locales/pt-BR/messages'
2024-04-04 01:50:15 +02:00
import {messages as messagesTr} from '#/locale/locales/tr/messages'
2024-01-03 21:22:55 +01:00
import {messages as messagesUk} from '#/locale/locales/uk/messages'
import {messages as messagesZh_CN} from '#/locale/locales/zh-CN/messages'
Add zh-TW localization (#2781) * add zh-TW localization * fix typo * fix languages.ts * improve translation * improve translation * 部分翻譯修正 - 使用全形標點符號 - 將部分簡體字修正為正體字 - 更改部分用語 * fix incorrectly commented strings * small fix and suggestion * update translation team * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * modify the translation based on the review suggestions * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: noeFly <jeffyang0123@gmail.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: noeFly <jeffyang0123@gmail.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: noeFly <jeffyang0123@gmail.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * modify translation by review * modify translation by review * modify translation by review * modify translation by review * modify translation by review * modify translation by review * minor fixes * minor fixes * Update messages.po * translate new strings * fix typo * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update messages.po * Update messages.po * Update messages.po * Update messages.po * fixed typo * Update messages.po * correct translation * Update messages.po * modify translation by review * Update messages.po * Update messages.po --------- Co-authored-by: noeFly <jeffyang0123@gmail.com> Co-authored-by: Kuwa Lee <kuwalee1069@gmail.com> Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com>
2024-04-03 23:30:04 +02:00
import {messages as messagesZh_TW} from '#/locale/locales/zh-TW/messages'
2024-04-04 01:50:15 +02:00
import {useLanguagePrefs} from '#/state/preferences'
/**
* We do a dynamic import of just the catalog that we need
*/
export async function dynamicActivate(locale: AppLanguage) {
switch (locale) {
2024-01-24 05:39:35 +01:00
case AppLanguage.de: {
i18n.loadAndActivate({locale, messages: messagesDe})
break
}
case AppLanguage.es: {
i18n.loadAndActivate({locale, messages: messagesEs})
break
}
2024-03-19 21:04:45 +01:00
case AppLanguage.fi: {
2024-02-19 06:42:07 +01:00
i18n.loadAndActivate({locale, messages: messagesFi})
break
2024-03-19 21:04:45 +01:00
}
case AppLanguage.fr: {
i18n.loadAndActivate({locale, messages: messagesFr})
break
}
case AppLanguage.hi: {
i18n.loadAndActivate({locale, messages: messagesHi})
break
}
case AppLanguage.id: {
i18n.loadAndActivate({locale, messages: messagesId})
break
}
case AppLanguage.ja: {
i18n.loadAndActivate({locale, messages: messagesJa})
break
}
case AppLanguage.ko: {
i18n.loadAndActivate({locale, messages: messagesKo})
break
}
case AppLanguage.pt_BR: {
i18n.loadAndActivate({locale, messages: messagesPt_BR})
break
}
2024-01-03 21:22:55 +01:00
case AppLanguage.uk: {
i18n.loadAndActivate({locale, messages: messagesUk})
break
}
2024-01-19 06:54:00 +01:00
case AppLanguage.ca: {
i18n.loadAndActivate({locale, messages: messagesCa})
break
}
case AppLanguage.zh_CN: {
i18n.loadAndActivate({locale, messages: messagesZh_CN})
2024-02-13 19:01:59 +01:00
break
}
case AppLanguage.it: {
i18n.loadAndActivate({locale, messages: messagesIt})
break
}
Add zh-TW localization (#2781) * add zh-TW localization * fix typo * fix languages.ts * improve translation * improve translation * 部分翻譯修正 - 使用全形標點符號 - 將部分簡體字修正為正體字 - 更改部分用語 * fix incorrectly commented strings * small fix and suggestion * update translation team * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * modify the translation based on the review suggestions * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: noeFly <jeffyang0123@gmail.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: noeFly <jeffyang0123@gmail.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: noeFly <jeffyang0123@gmail.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * modify translation by review * modify translation by review * modify translation by review * modify translation by review * modify translation by review * modify translation by review * minor fixes * minor fixes * Update messages.po * translate new strings * fix typo * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update messages.po * Update messages.po * Update messages.po * Update messages.po * fixed typo * Update messages.po * correct translation * Update messages.po * modify translation by review * Update messages.po * Update messages.po --------- Co-authored-by: noeFly <jeffyang0123@gmail.com> Co-authored-by: Kuwa Lee <kuwalee1069@gmail.com> Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com>
2024-04-03 23:30:04 +02:00
case AppLanguage.zh_TW: {
i18n.loadAndActivate({locale, messages: messagesZh_TW})
2024-04-04 01:50:15 +02:00
break
}
case AppLanguage.tr: {
i18n.loadAndActivate({locale, messages: messagesTr})
break
Add zh-TW localization (#2781) * add zh-TW localization * fix typo * fix languages.ts * improve translation * improve translation * 部分翻譯修正 - 使用全形標點符號 - 將部分簡體字修正為正體字 - 更改部分用語 * fix incorrectly commented strings * small fix and suggestion * update translation team * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * modify the translation based on the review suggestions * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: noeFly <jeffyang0123@gmail.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: noeFly <jeffyang0123@gmail.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: noeFly <jeffyang0123@gmail.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> * modify translation by review * modify translation by review * modify translation by review * modify translation by review * modify translation by review * modify translation by review * minor fixes * minor fixes * Update messages.po * translate new strings * fix typo * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update src/locale/locales/zh-TW/messages.po Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com> * Update messages.po * Update messages.po * Update messages.po * Update messages.po * fixed typo * Update messages.po * correct translation * Update messages.po * modify translation by review * Update messages.po * Update messages.po --------- Co-authored-by: noeFly <jeffyang0123@gmail.com> Co-authored-by: Kuwa Lee <kuwalee1069@gmail.com> Co-authored-by: Yuki Cheung <13027432+snowleo208@users.noreply.github.com> Co-authored-by: Howard Guo <50100922+toto6038@users.noreply.github.com>
2024-04-03 23:30:04 +02:00
}
default: {
i18n.loadAndActivate({locale, messages: messagesEn})
break
}
}
}
export async function useLocaleLanguage() {
const {appLanguage} = useLanguagePrefs()
useEffect(() => {
dynamicActivate(sanitizeAppLanguageSetting(appLanguage))
}, [appLanguage])
}