1
0
mirror of https://github.com/tooot-app/app synced 2024-12-27 01:42:32 +01:00

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) [![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) ![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({ name({
'default' => "tooot" 'default' => "tooot"

View File

@ -2,6 +2,8 @@ import i18n from 'i18next'
import { initReactI18next } from 'react-i18next' import { initReactI18next } from 'react-i18next'
import en from '@root/i18n/en/_all' 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' import zh_Hans from '@root/i18n/zh-Hans/_all'
i18n.use(initReactI18next).init({ i18n.use(initReactI18next).init({
@ -11,7 +13,7 @@ i18n.use(initReactI18next).init({
ns: ['common'], ns: ['common'],
defaultNS: 'common', defaultNS: 'common',
resources: { 'zh-Hans': zh_Hans, en }, resources: { 'zh-Hans': zh_Hans, vi, ko, en },
saveMissing: true, saveMissing: true,
missingKeyHandler: (ns, key) => { 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 = { const LOCALES = {
en: 'English', en: 'English',
ko: '한국어',
vi: 'Tiếng Việt',
'zh-Hans': '简体中文' 'zh-Hans': '简体中文'
} as {en: string} }
export { LOCALES } 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 Updates from 'expo-updates'
import * as StoreReview from 'expo-store-review' import * as StoreReview from 'expo-store-review'
export const supportedLngs = ['zh-Hans', 'en']
export type ContextsState = { export type ContextsState = {
storeReview: { storeReview: {
context: Readonly<number> context: Readonly<number>

View File

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