Added support for KO and VI

This commit is contained in:
Zhiyuan Zheng 2022-02-06 23:25:16 +01:00
parent e35d18c969
commit 7bf428f179
8 changed files with 51 additions and 20 deletions

View File

@ -3,3 +3,8 @@
[![GPL-3.0](https://img.shields.io/github/license/tooot-app/push)](LICENSE) ![GitHub issues](https://img.shields.io/github/issues/tooot-app/app) ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/tooot-app/app?include_prereleases) ![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/tooot-app/app) [![Crowdin](https://badges.crowdin.net/tooot/localized.svg)](https://crowdin.tooot.app/project/tooot)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/tooot-app/app/build) ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/tooot-app/app/build/candidate?label=build%20candidate) ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/tooot-app/app/build/release?label=build%20release)
## Special thanks
@hellojaccc for Korean translation
@duy@mas.to for Vietnamese translation

View File

@ -1,4 +1,4 @@
languages(['zh-Hans', 'en-US'])
languages(['zh-Hans', 'vi', 'ko', 'en-US'])
name({
'default' => "tooot"

View File

@ -2,6 +2,8 @@ import i18n from 'i18next'
import { initReactI18next } from 'react-i18next'
import en from '@root/i18n/en/_all'
import ko from '@root/i18n/ko/_all'
import vi from '@root/i18n/vi/_all'
import zh_Hans from '@root/i18n/zh-Hans/_all'
i18n.use(initReactI18next).init({
@ -11,7 +13,7 @@ i18n.use(initReactI18next).init({
ns: ['common'],
defaultNS: 'common',
resources: { 'zh-Hans': zh_Hans, en },
resources: { 'zh-Hans': zh_Hans, vi, ko, en },
saveMissing: true,
missingKeyHandler: (ns, key) => {

17
src/i18n/ko/_all.ts Normal file
View File

@ -0,0 +1,17 @@
export default {
common: require('./common'),
screens: require('./screens'),
screenActions: require('./screens/actions'),
screenAnnouncements: require('./screens/announcements'),
screenCompose: require('./screens/compose'),
screenImageViewer: require('./screens/imageViewer'),
screenTabs: require('./screens/tabs'),
componentInstance: require('./components/instance'),
componentMediaSelector: require('./components/mediaSelector'),
componentParse: require('./components/parse'),
componentRelationship: require('./components/relationship'),
componentRelativeTime: require('./components/relativeTime'),
componentTimeline: require('./components/timeline')
}

View File

@ -1,6 +1,8 @@
const LOCALES = {
en: 'English',
ko: '한국어',
vi: 'Tiếng Việt',
'zh-Hans': '简体中文'
} as {en: string}
}
export { LOCALES }

17
src/i18n/vi/_all.ts Normal file
View File

@ -0,0 +1,17 @@
export default {
common: require('./common'),
screens: require('./screens'),
screenActions: require('./screens/actions'),
screenAnnouncements: require('./screens/announcements'),
screenCompose: require('./screens/compose'),
screenImageViewer: require('./screens/imageViewer'),
screenTabs: require('./screens/tabs'),
componentInstance: require('./components/instance'),
componentMediaSelector: require('./components/mediaSelector'),
componentParse: require('./components/parse'),
componentRelationship: require('./components/relationship'),
componentRelativeTime: require('./components/relativeTime'),
componentTimeline: require('./components/timeline')
}

View File

@ -3,8 +3,6 @@ import { RootState } from '@root/store'
import * as Updates from 'expo-updates'
import * as StoreReview from 'expo-store-review'
export const supportedLngs = ['zh-Hans', 'en']
export type ContextsState = {
storeReview: {
context: Readonly<number>

View File

@ -1,14 +1,10 @@
import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit'
import { LOCALES } from '@root/i18n/locales'
import { RootState } from '@root/store'
import * as Analytics from 'expo-firebase-analytics'
import * as Localization from 'expo-localization'
import { pickBy } from 'lodash'
enum AvailableLanguages {
'zh-Hans',
'en'
}
export const changeAnalytics = createAsyncThunk(
'settings/changeAnalytics',
async (newValue: SettingsState['analytics']) => {
@ -31,12 +27,10 @@ export const settingsInitialState = {
enabled: false
},
language: Object.keys(
pickBy(AvailableLanguages, (_, key) => Localization.locale.includes(key))
pickBy(LOCALES, (_, key) => Localization.locale.startsWith(key))
)
? Object.keys(
pickBy(AvailableLanguages, (_, key) =>
Localization.locale.includes(key)
)
pickBy(LOCALES, (_, key) => Localization.locale.startsWith(key))
)[0]
: 'en',
theme: 'auto',
@ -88,10 +82,6 @@ export const getSettingsBrowser = (state: RootState) => state.settings.browser
export const getSettingsAnalytics = (state: RootState) =>
state.settings.analytics
export const {
changeFontsize,
changeLanguage,
changeTheme,
changeBrowser
} = settingsSlice.actions
export const { changeFontsize, changeLanguage, changeTheme, changeBrowser } =
settingsSlice.actions
export default settingsSlice.reducer