Skip to content

Commit

Permalink
Merge branch 'staging' into bugfix/validator-homepage-link-custom-net…
Browse files Browse the repository at this point in the history
…work
  • Loading branch information
ckniffen authored Oct 30, 2023
2 parents 9306cc8 + 89603f3 commit 9076098
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 41 deletions.
10 changes: 4 additions & 6 deletions docs/how-to-define-a-language.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# How Languages Are Defined

1. Add the new language code to the array `supportedLanguages` in [/src/i18n/baseConfig.ts](../src/i18n/baseConfig.ts)
2. Add an entry to default language file [/public/locales/en-US/translations.json](../public/locales/en-US/translations.json) with the key being `language_{languageCode}`.
Example: `language_en-US`
3. Create a folder in [/public/locales/](../public/locales) with the language code as its name.
4. Add a new file, `translations.json`, to the new folder.
5. Translate all the entries. If you prefer to use the English version just set the value to `null`.
1. Add the new language code and language name to the map `supportedLanguages` in [/src/i18n/baseConfig.ts](../src/i18n/baseConfig.ts)
2. Create a folder in [/public/locales/](../public/locales) with the language code as its name.
3. Add a new file, `translations.json`, to the new folder.
4. Translate all the entries. If you prefer to use the English version just set the value to `null`.

Example file: [/public/locales/ja-JP/translations.json](../public/locales/ja-JP/translations.json)
5 changes: 0 additions & 5 deletions public/locales/en-US/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,6 @@
"check_crawl_existed": "Please contact the operator to make sure they have /crawl accessible or a vl set.",
"peer_crawled_context": "For more context, see https://xrpl.org/peer-crawler.html",
"xchainbridge": "XChainBridge",
"language_en-US": "English",
"language_fr-FR": "French",
"language_ja-JP": "Japanese",
"language_ko-KR": "Korean",
"language_es-ES": "Spanish",
"xchain_account_claim_count": "XChain Account Claim Count",
"xchain_account_create_count": "XChain Account Create Count",
"min_signer_quorum": "Minimum weight <0>{{quorum}}</0> required",
Expand Down
5 changes: 0 additions & 5 deletions public/locales/es-ES/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,6 @@
"check_crawl_existed": "Por favor, contacta con el operador para asegurarte de que tienen acceso a /crawl o un vl incluido.",
"peer_crawled_context": "Para más contexto, mira https://xrpl.org/peer-crawler.html",
"xchainbridge": "XChainBridge",
"language_en-US": "Inglés",
"language_ja-JP": "Japonés",
"language_kr-KR": "Coreano",
"language_fr-FR": "Francés",
"language_es-ES": "Español",
"xchain_account_claim_count": "Contador de Reclamación de Cuentas XChain",
"xchain_account_create_count": "Contador de Creación de Cuentas XChain",
"min_signer_quorum": "Peso mínimo <0>{{quorum}}</0> requerido",
Expand Down
3 changes: 0 additions & 3 deletions public/locales/fr-FR/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,6 @@
"check_crawl_existed": "Veuillez contacter l'opérateur pour vous assurer qu'il dispose d'un accès /crawl accessible ou d'un ensemble vl.",
"peer_crawled_context": "Pour plus de contexte, voir https://xrpl.org/peer-crawler.html",
"xchainbridge": "Pont XChain",
"language_en-US": "Anglais",
"language_ja-JP": "Japonais",
"language_fr-FR": "Français",
"xchain_account_claim_count": "Nombre de réclamations de compte XChain",
"xchain_account_create_count": "Nombre de compte XChain créés",
"min_signer_quorum": "Poids minimum <0>{{quorum}}</0> requis.",
Expand Down
5 changes: 0 additions & 5 deletions public/locales/ja-JP/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,6 @@
"check_crawl_existed": null,
"peer_crawled_context": null,
"xchainbridge": null,
"language_en-US": null,
"language_fr-FR": null,
"language_ja-JP": null,
"language_ko-KR": null,
"language_es-ES": null,
"xchain_account_claim_count": null,
"xchain_account_create_count": null,
"min_signer_quorum": null,
Expand Down
7 changes: 1 addition & 6 deletions public/locales/ko-KR/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,6 @@
"check_crawl_existed": "운영자에게 연락하여 /crawl이 접근 가능하거나 vl 세트가 있는지 확인하세요",
"peer_crawled_context": "더 자세한 정보는 https://xrpl.org/peer-crawler.html 를 참조하세요",
"xchainbridge": "XChain 브리지",
"language_en-US": "영어",
"language_fr-FR": "프랑스말",
"language_ja-JP": "일본어",
"language_ko-KR": "한국어",
"language_es-ES": "null",
"xchain_account_claim_count": "XChain 계정 요구 수",
"xchain_account_create_count": "XChain 계정 생성 수",
"min_signer_quorum": "최소 가중치 <0>{{quorum}}</0>가 필요합니다",
Expand Down Expand Up @@ -484,4 +479,4 @@
"namespace": "Namespace",
"api_version": "API 버전",
"triggered_on": "Triggered On"
}
}
15 changes: 6 additions & 9 deletions src/containers/Header/LanguagePicker/LanguagePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './LanguagePicker.scss'
import { supportedLanguages } from '../../../i18n/baseConfig'

export const LanguagePicker = () => {
const { t, i18n } = useTranslation()
const { i18n } = useTranslation()
const currentLanguage = useLanguage()

const handleLanguageClick = (language: string) => () => {
Expand All @@ -15,21 +15,18 @@ export const LanguagePicker = () => {
return (
<div className="language-picker">
<Dropdown
title={t(`language`, { context: currentLanguage, defaultValue: '' })}
title={supportedLanguages[currentLanguage]}
className="dropdown-right"
>
{supportedLanguages
.filter((language) => language !== currentLanguage)
.map((language) => (
{Object.entries(supportedLanguages)
.filter(([language]) => language !== currentLanguage)
.map(([language, languageName]) => (
<DropdownItem
key={language}
className={`language-picker-${language}`}
handler={handleLanguageClick(language)}
>
{t(`language`, {
context: language,
defaultValue: '',
})}
{languageName}
</DropdownItem>
))}
</Dropdown>
Expand Down
10 changes: 8 additions & 2 deletions src/i18n/baseConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { InitOptions } from 'i18next'

export const supportedLanguages = ['en-US', 'ja-JP', 'ko-KR', 'es-ES', 'fr-FR']
export const supportedLanguages = {
'en-US': 'English',
'ja-JP': '日本語',
'ko-KR': '한국어',
'es-ES': 'Español',
'fr-FR': 'Français',
}

export const options: InitOptions = {
returnNull: false,
Expand All @@ -13,7 +19,7 @@ export const options: InitOptions = {
escapeValue: false, // not needed for react!!
formatSeparator: ',',
},
supportedLngs: supportedLanguages,
supportedLngs: Object.keys(supportedLanguages),
react: {
useSuspense: true,
},
Expand Down

0 comments on commit 9076098

Please sign in to comment.