Skip to content

Commit

Permalink
refactor(i18n): use 'en' instead of 'en-us'
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileRolley committed Oct 30, 2023
1 parent 0e6dc93 commit 1198838
Show file tree
Hide file tree
Showing 25 changed files with 28 additions and 28 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions source/locales/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import { i18n } from 'i18next'
import type { MDXContent } from 'mdx/types'

import uiEn from '!locale-yaml-loader!./ui/ui-en-us.yaml'
import uiEn from '!locale-yaml-loader!./ui/ui-en.yaml'
// import uiEs from '!locale-yaml-loader!./ui/ui-es.yaml'
import uiFr from '!locale-yaml-loader!./ui/ui-fr.yaml'
// import uiIt from '!locale-yaml-loader!./ui/ui-it.yaml'

import faqEn from '!locale-yaml-loader!./faq/FAQ-en-us.yaml'
import faqEn from '!locale-yaml-loader!./faq/FAQ-en.yaml'
// import faqEs from '!locale-yaml-loader!./faq/FAQ-es.yaml'
import faqFr from '!locale-yaml-loader!./faq/FAQ-fr.yaml'
// import faqIt from '!locale-yaml-loader!./faq/FAQ-it.yaml'

import releasesEn from './releases/releases-en-us.json'
import releasesEn from './releases/releases-en.json'
// import releasesEs from './releases/releases-es.json'
import releasesFr from './releases/releases-fr.json'
// import releasesIt from './releases/releases-it.json'
Expand Down Expand Up @@ -123,22 +123,22 @@ export function changeLangTo(i18n: i18n, currentLangState: Lang) {

export function getMarkdownInCurrentLang(
markdownFiles: Array<[Lang, string]>,
currentLangState: Lang
currentLangState: Lang,
) {
return (
markdownFiles.find(
([lang]) => getLangInfos(lang).abrv === currentLangState
([lang]) => getLangInfos(lang).abrv === currentLangState,
)?.[1] || markdownFiles[0][1]
)
}

export function getMarkdownXInCurrentLang(
markdownFiles: Array<[Lang, MDXContent]>,
currentLangState: Lang
currentLangState: Lang,
): MDXContent {
return (
markdownFiles.find(
([lang]) => getLangInfos(lang).abrv === currentLangState
([lang]) => getLangInfos(lang).abrv === currentLangState,
)?.[1] || markdownFiles[0][1]
)
}
2 changes: 1 addition & 1 deletion source/sites/publicodes/LandingExplanations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import avantages from './avantages.yaml'
import LandingContent from './LandingContent'
import MarkdownPage from './pages/MarkdownPage'

import contentEn from '../../locales/pages/en-us/landing.md'
import contentEn from '../../locales/pages/en/landing.md'
import contentEs from '../../locales/pages/es/landing.md'
import contentFr from '../../locales/pages/fr/landing.md'
import contentIt from '../../locales/pages/it/landing.md'
Expand Down
12 changes: 6 additions & 6 deletions source/sites/publicodes/Personas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const visualisationChoices = {

export default () => {
const selectedPersona = useSelector(
(state: AppState) => state.simulation?.persona
(state: AppState) => state.simulation?.persona,
)

const [searchParams, setSearchParams] = useSearchParams({
Expand All @@ -72,7 +72,7 @@ export default () => {
const engine = useEngine()
const rules = useSelector((state: AppState) => state.rules)
const personasQuestions = getQuestionsInRules(engine, rules).filter(
({ type }) => !type.includes('Mosaïque')
({ type }) => !type.includes('Mosaïque'),
)

const visualisationComponentProps = {
Expand Down Expand Up @@ -186,7 +186,7 @@ export const PersonaGrid = ({
const engine = useEngine()

const branchData: BranchData = useBranchData()
const lang = i18n.language === 'en' ? 'en-us' : i18n.language
const lang = i18n.language

const navigate = useNavigate()
const [params] = useSearchParams()
Expand All @@ -197,7 +197,7 @@ export const PersonaGrid = ({
fetchAndSetAvailablePersonas(
`/personas-${lang}.json`,
branchData,
setAvailablePersonas
setAvailablePersonas,
)
}
}, [branchData.loaded, branchData.deployURL, lang])
Expand All @@ -209,7 +209,7 @@ export const PersonaGrid = ({
const setPersona = (persona: Persona) => {
const safeSituation = safeGetSituation(
persona.situation,
engine.getParsedRules() as NGCRulesNodes
engine.getParsedRules() as NGCRulesNodes,
)
setSituationForValidKeys({
engine,
Expand Down Expand Up @@ -394,7 +394,7 @@ export const PersonaExplanations = ({ personasQuestionList }) => {
className="ui__ button small"
onClick={() => {
navigator.clipboard.writeText(
JSON.stringify(personasQuestionList)
JSON.stringify(personasQuestionList),
)
}}
>
Expand Down
2 changes: 1 addition & 1 deletion source/sites/publicodes/pages/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next'
import { Lang } from '../../../locales/translation'
import MarkdownXPage from './MarkdownXPage'

import contentEn from '../../../locales/pages/en-us/about.mdx'
import contentEn from '../../../locales/pages/en/about.mdx'

import contentFr from '../../../locales/pages/fr/about.mdx'

Expand Down
2 changes: 1 addition & 1 deletion source/sites/publicodes/pages/Accessibility.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next'
import { Lang } from '../../../locales/translation'
import MarkdownPage from './MarkdownPage'

import contentEn from '../../../locales/pages/en-us/accessibility.md'
import contentEn from '../../../locales/pages/en/accessibility.md'
// import contentEs from '../../../locales/pages/es/accessibility.md'
import contentFr from '../../../locales/pages/fr/accessibility.md'
// import contentIt from '../../../locales/pages/it/accessibility.md'
Expand Down
8 changes: 4 additions & 4 deletions source/sites/publicodes/pages/Budget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Markdown } from '@/components/utils/markdown'
import Meta from '@/components/utils/Meta'
import { getMarkdownInCurrentLang, Lang } from '@/locales/translation'
import { useTranslation } from 'react-i18next'
import contentEnBottom from '../../../locales/pages/en-us/budgetBottom.md'
import contentEnTop from '../../../locales/pages/en-us/budgetTop.md'
import contentEnBottom from '../../../locales/pages/en/budgetBottom.md'
import contentEnTop from '../../../locales/pages/en/budgetTop.md'
import contentFrBottom from '../../../locales/pages/fr/budgetBottom.md'
import contentFrTop from '../../../locales/pages/fr/budgetTop.md'
import SelectYear from './budget/SelectYear'
Expand All @@ -18,15 +18,15 @@ export default () => {
[Lang.Fr, contentFrTop],
[Lang.En, contentEnTop],
],
lang
lang,
)

const contentBottom = getMarkdownInCurrentLang(
[
[Lang.Fr, contentFrBottom],
[Lang.En, contentEnBottom],
],
lang
lang,
)

return (
Expand Down
2 changes: 1 addition & 1 deletion source/sites/publicodes/pages/CGU.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next'
import { Lang } from '../../../locales/translation'
import MarkdownPage from './MarkdownPage'

import contentEn from '../../../locales/pages/en-us/CGU.md'
import contentEn from '../../../locales/pages/en/CGU.md'
// import contentEs from '../../../locales/pages/es/CGU.md'
import contentFr from '../../../locales/pages/fr/CGU.md'
// import contentIt from '../../../locales/pages/it/CGU.md'
Expand Down
2 changes: 1 addition & 1 deletion source/sites/publicodes/pages/Diffuser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next'
import { Lang } from '../../../locales/translation'
import MarkdownPage from './MarkdownPage'

import contentEn from '../../../locales/pages/en-us/diffuser.md'
import contentEn from '../../../locales/pages/en/diffuser.md'
// import contentEs from '../../../locales/pages/es/diffuser.md'
import contentFr from '../../../locales/pages/fr/diffuser.md'
// import contentIt from '../../../locales/pages/it/diffuser.md'
Expand Down
6 changes: 3 additions & 3 deletions source/sites/publicodes/pages/DocumentationContexte.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Link } from 'react-router-dom'
import { getMarkdownInCurrentLang, Lang } from '@/locales/translation'

import AutoCanonicalTag from '@/components/utils/AutoCanonicalTag'
import contentEn from '../../../locales/pages/en-us/documentation.md'
import contentEn from '../../../locales/pages/en/documentation.md'
import contentFr from '../../../locales/pages/fr/documentation.md'

export default () => {
Expand All @@ -19,15 +19,15 @@ export default () => {
[Lang.Fr, contentFr],
[Lang.En, contentEn],
],
l
l,
)

return (
<div css="padding: 0 .3rem 1rem; max-width: 600px; margin: 1rem auto;">
<Meta
title={t('Documentation Contexte Sondage')}
description={t(
"Informations relatives à la création d'un contexte spécifique."
"Informations relatives à la création d'un contexte spécifique.",
)}
/>
<AutoCanonicalTag />
Expand Down
2 changes: 1 addition & 1 deletion source/sites/publicodes/pages/Méthode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next'
import { Lang } from '../../../locales/translation'
import MarkdownPage from './MarkdownPage'

import contentEn from '../../../locales/pages/en-us/méthode.md'
import contentEn from '../../../locales/pages/en/méthode.md'
// import contentEs from '../../../locales/pages/es/méthode.md'
import contentFr from '../../../locales/pages/fr/méthode.md'
// import contentIt from '../../../locales/pages/it/méthode.md'
Expand Down
2 changes: 1 addition & 1 deletion source/sites/publicodes/pages/PetrogazLanding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next'
import { Lang } from '../../../locales/translation'
import MarkdownPage from './MarkdownPage'

import contentEn from '../../../locales/pages/en-us/petrogazLanding.md'
import contentEn from '../../../locales/pages/en/petrogazLanding.md'
import contentFr from '../../../locales/pages/fr/petrogazLanding.md'

export default () => {
Expand Down
2 changes: 1 addition & 1 deletion source/sites/publicodes/pages/Privacy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next'
import { Lang } from '../../../locales/translation'
import MarkdownPage from './MarkdownPage'

import contentEn from '../../../locales/pages/en-us/privacy.md'
import contentEn from '../../../locales/pages/en/privacy.md'
// import contentEs from '../../../locales/pages/es/privacy.md'
import contentFr from '../../../locales/pages/fr/privacy.md'
// import contentIt from '../../../locales/pages/it/privacy.md'
Expand Down

0 comments on commit 1198838

Please sign in to comment.