Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable languages #1079

Merged
merged 5 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/famous-crews-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alephium/explorer": patch
---

Enable Portuguese translations
5 changes: 5 additions & 0 deletions .changeset/gold-rabbits-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alephium/mobile-wallet": patch
---

Enable German translations
5 changes: 5 additions & 0 deletions .changeset/purple-wasps-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alephium/explorer': patch
---

Enable Thai translations in explorer
5 changes: 5 additions & 0 deletions .changeset/strange-candles-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"alephium-desktop-wallet": patch
---

Enable Thai translations in desktop wallet
16 changes: 0 additions & 16 deletions apps/desktop-wallet/.afterAllArtifactBuild.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
// Copyright 2018 - 2024 The Alephium Authors
// This file is part of the alephium project.
//
// The library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the library. If not, see <http://www.gnu.org/licenses/>.

const crypto = require('crypto')
const fs = require('fs')
const path = require('path')
Expand Down
16 changes: 0 additions & 16 deletions apps/desktop-wallet/.afterPack.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
// Copyright 2018 - 2024 The Alephium Authors
// This file is part of the alephium project.
//
// The library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the library. If not, see <http://www.gnu.org/licenses/>.

// The hook is a temporary fix to set the right icon size for the deb archive.
// The hook only applies to the `deb` target.
// The hook will set the icon size to 512 for all icons with a size of 0.
Expand Down
5 changes: 2 additions & 3 deletions apps/desktop-wallet/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ import SplashScreen from '@/components/SplashScreen'
import useAnalytics from '@/features/analytics/useAnalytics'
import useTrackUserSettings from '@/features/analytics/useTrackUserSettings'
import AutoUpdateSnackbar from '@/features/autoUpdate/AutoUpdateSnackbar'
import { languageOptions } from '@/features/localization/languages'
import { systemLanguageMatchFailed, systemLanguageMatchSucceeded } from '@/features/localization/localizationActions'
import {
localStorageGeneralSettingsMigrated,
systemLanguageMatchFailed,
systemLanguageMatchSucceeded,
systemRegionMatchFailed,
systemRegionMatchSucceeded
} from '@/features/settings/settingsActions'
import { languageOptions } from '@/features/settings/settingsConstants'
import useRegionOptions from '@/features/settings/useRegionOptions'
import { darkTheme, lightTheme } from '@/features/theme/themes'
import { WalletConnectContextProvider } from '@/features/walletConnect/walletConnectContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
/*
Copyright 2018 - 2024 The Alephium Authors
This file is part of the alephium project.

The library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with the library. If not, see <http://www.gnu.org/licenses/>.
*/
import { UseQueryResult } from '@tanstack/react-query'

import { combineError, combineIsFetching, combineIsLoading } from '@/api/apiDataHooks/apiDataHooksUtils'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
/*
Copyright 2018 - 2024 The Alephium Authors
This file is part of the alephium project.

The library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with the library. If not, see <http://www.gnu.org/licenses/>.
*/

import { X } from 'lucide-react'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'
Expand Down
18 changes: 0 additions & 18 deletions apps/desktop-wallet/src/features/ledger/ledgerActions.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
/*
Copyright 2018 - 2024 The Alephium Authors
This file is part of the alephium project.

The library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with the library. If not, see <http://www.gnu.org/licenses/>.
*/

import { createAction } from '@reduxjs/toolkit'

export const newLedgerDeviceConnected = createAction('ledger/newLedgerDeviceConnected')
Expand Down
18 changes: 0 additions & 18 deletions apps/desktop-wallet/src/features/ledger/ledgerSlice.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
/*
Copyright 2018 - 2024 The Alephium Authors
This file is part of the alephium project.

The library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with the library. If not, see <http://www.gnu.org/licenses/>.
*/

import { createSlice } from '@reduxjs/toolkit'

import { newLedgerDeviceConnected, userWasAskedToDiscoverAddresses } from './ledgerActions'
Expand Down
41 changes: 41 additions & 0 deletions apps/desktop-wallet/src/features/localization/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import i18next from 'i18next'
import { initReactI18next } from 'react-i18next'

import bg from '../../../locales/bg-BG/translation.json'
import de from '../../../locales/de-DE/translation.json'
import el from '../../../locales/el-GR/translation.json'
import en from '../../../locales/en-US/translation.json'
import es from '../../../locales/es-ES/translation.json'
import fr from '../../../locales/fr-FR/translation.json'
import id from '../../../locales/id-ID/translation.json'
import it from '../../../locales/it-IT/translation.json'
import pt from '../../../locales/pt-PT/translation.json'
import ru from '../../../locales/ru-RU/translation.json'
import tr from '../../../locales/tr-TR/translation.json'
import vi from '../../../locales/vi-VN/translation.json'
import zh from '../../../locales/zh-CN/translation.json'

i18next.use(initReactI18next).init({
resources: {
'en-US': { translation: en },
'bg-BG': { translation: bg },
'es-ES': { translation: es },
'de-DE': { translation: de },
'id-ID': { translation: id },
'it-IT': { translation: it },
'fr-FR': { translation: fr },
'pt-PT': { translation: pt },
'ru-RU': { translation: ru },
'tr-TR': { translation: tr },
'vi-VN': { translation: vi },
'el-GR': { translation: el },
'zh-CN': { translation: zh }
},
lng: 'en-US',
fallbackLng: 'en-US',
interpolation: {
escapeValue: false
}
})

export default i18next
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'i18next'

import en from '../../locales/en-US/translation.json'
import en from '../../../locales/en-US/translation.json'

type EnglishTranslationKeys = typeof en

Expand Down
34 changes: 34 additions & 0 deletions apps/desktop-wallet/src/features/localization/languages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { SelectOption } from '@/components/Inputs/Select'

export type Language =
| 'en-US'
| 'fr-FR'
| 'de-DE'
| 'vi-VN'
| 'pt-PT'
| 'ru-RU'
| 'bg-BG'
| 'es-ES'
| 'id-ID'
| 'tr-TR'
| 'it-IT'
| 'el-GR'
| 'zh-CN'
| 'th-TH'

export const languageOptions: SelectOption<Language>[] = [
{ label: 'English', value: 'en-US' },
{ label: 'Bahasa Indonesia', value: 'id-ID' },
{ label: 'Български', value: 'bg-BG' },
{ label: 'Deutsch', value: 'de-DE' },
{ label: 'Español', value: 'es-ES' },
{ label: 'Français', value: 'fr-FR' },
{ label: 'Italiano', value: 'it-IT' },
{ label: 'Português', value: 'pt-PT' },
{ label: 'Русский', value: 'ru-RU' },
{ label: 'Türkçe', value: 'tr-TR' },
{ label: 'Tiếng Việt', value: 'vi-VN' },
{ label: 'Ελληνικά', value: 'el-GR' },
{ label: 'ไทย', value: 'th-TH' },
{ label: '简体中文', value: 'zh-CN' }
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createAction } from '@reduxjs/toolkit'

import { Language } from '@/features/localization/languages'

export const languageChangeStarted = createAction('localization/languageChangeStarted')

export const languageChangeFinished = createAction('localization/languageChangeFinished')

export const systemLanguageMatchSucceeded = createAction<Language>('localization/systemLanguageMatchSucceeded')

export const systemLanguageMatchFailed = createAction('localization/systemLanguageMatchFailed')

export const languageChanged = createAction<Language>('localization/languageChanged')
2 changes: 1 addition & 1 deletion apps/desktop-wallet/src/features/send/StepsProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { useTranslation } from 'react-i18next'
import styled, { useTheme } from 'styled-components'

import DotIcon from '@/components/DotIcon'
import { TranslationKey } from '@/features/localization/i18next'
import { useAppSelector } from '@/hooks/redux'
import { TranslationKey } from '@/types/i18next'

interface StepsProgressProps {
currentStep: Step
Expand Down
12 changes: 1 addition & 11 deletions apps/desktop-wallet/src/features/settings/settingsActions.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import { createAction } from '@reduxjs/toolkit'

import { Language, Settings } from '@/features/settings/settingsTypes'
import { Settings } from '@/features/settings/settingsTypes'
import { ThemeType } from '@/features/theme/themeTypes'

export const languageChangeStarted = createAction('settings/languageChangeStarted')

export const languageChangeFinished = createAction('settings/languageChangeFinished')

export const systemLanguageMatchSucceeded = createAction<Language>('settings/systemLanguageMatchSucceeded')

export const systemLanguageMatchFailed = createAction('settings/systemLanguageMatchFailed')

export const systemRegionMatchSucceeded = createAction<string>('settings/systemRegionMatchSucceeded')

export const systemRegionMatchFailed = createAction('settings/systemRegionMatchFailed')
Expand All @@ -25,8 +17,6 @@ export const passwordRequirementToggled = createAction('settings/passwordRequire

export const devToolsToggled = createAction('settings/devToolsToggled')

export const languageChanged = createAction<Settings['general']['language']>('settings/languageChanged')

export const numberFormatRegionChanged = createAction<Settings['general']['region']>(
'settings/numberFormatRegionChanged'
)
Expand Down
18 changes: 1 addition & 17 deletions apps/desktop-wallet/src/features/settings/settingsConstants.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
import { CURRENCIES, Currency, defaultNetworkSettings } from '@alephium/shared'

import { SelectOption } from '@/components/Inputs/Select'
import { Language, Settings } from '@/features/settings/settingsTypes'

export const languageOptions: SelectOption<Language>[] = [
{ label: 'English', value: 'en-US' },
{ label: 'Български', value: 'bg-BG' },
{ label: 'Deutsch', value: 'de-DE' },
{ label: 'Español', value: 'es-ES' },
{ label: 'Français', value: 'fr-FR' },
{ label: 'Bahasa Indonesia', value: 'id-ID' },
{ label: 'Italiano', value: 'it-IT' },
{ label: 'Português', value: 'pt-PT' },
{ label: 'Русский', value: 'ru-RU' },
{ label: 'Türkçe', value: 'tr-TR' },
{ label: 'Tiếng Việt', value: 'vi-VN' },
{ label: 'Ελληνικά', value: 'el-GR' },
{ label: '简体中文', value: 'zh-CN' }
]
import { Settings } from '@/features/settings/settingsTypes'

export const fiatCurrencyOptions: SelectOption<Currency>[] = Object.values(CURRENCIES).map((currency) => ({
label: currency.ticker,
Expand Down
14 changes: 8 additions & 6 deletions apps/desktop-wallet/src/features/settings/settingsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ import { createListenerMiddleware, createSlice, isAnyOf } from '@reduxjs/toolkit
import dayjs from 'dayjs'
import posthog from 'posthog-js'

import i18next from '@/features/localization/i18n'
import {
analyticsToggled,
devToolsToggled,
discreetModeToggled,
languageChanged,
languageChangeFinished,
languageChangeStarted,
systemLanguageMatchFailed,
systemLanguageMatchSucceeded
} from '@/features/localization/localizationActions'
import {
analyticsToggled,
devToolsToggled,
discreetModeToggled,
localStorageGeneralSettingsMigrated,
numberFormatRegionChanged,
passwordRequirementToggled,
systemLanguageMatchFailed,
systemLanguageMatchSucceeded,
systemRegionMatchFailed,
systemRegionMatchSucceeded,
themeSettingsChanged,
Expand All @@ -36,7 +39,6 @@ import {
} from '@/features/settings/settingsActions'
import SettingsStorage from '@/features/settings/settingsPersistentStorage'
import { GeneralSettings } from '@/features/settings/settingsTypes'
import i18next from '@/i18n'
import { RootState } from '@/storage/store'

const initialState = SettingsStorage.load('general') as GeneralSettings
Expand Down
16 changes: 1 addition & 15 deletions apps/desktop-wallet/src/features/settings/settingsTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Currency, NetworkSettings } from '@alephium/shared'

import { Language } from '@/features/localization/languages'
import { ThemeSettings } from '@/features/theme/themeTypes'

export interface GeneralSettings {
Expand All @@ -18,18 +19,3 @@ export interface Settings {
general: GeneralSettings
network: NetworkSettings
}

export type Language =
| 'en-US'
| 'fr-FR'
| 'de-DE'
| 'vi-VN'
| 'pt-PT'
| 'ru-RU'
| 'bg-BG'
| 'es-ES'
| 'id-ID'
| 'tr-TR'
| 'it-IT'
| 'el-GR'
| 'zh-CN'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { upperFirst } from 'lodash'
import { useMemo } from 'react'

import { Language } from '@/features/settings/settingsTypes'
import { Language } from '@/features/localization/languages'
import { useAppSelector } from '@/hooks/redux'

import regionsLocales from './regions.json'
Expand Down
Loading
Loading