🧰 Sort les sitePaths de en.yaml
parent
bbe7933586
commit
3af9fdd29b
|
@ -895,46 +895,6 @@ pages:
|
|||
simulator language.</3>
|
||||
module: What module?
|
||||
par: per
|
||||
path:
|
||||
budget: /budget
|
||||
coronavirus: /coronavirus
|
||||
créer:
|
||||
après: /after-registration
|
||||
guideStatut:
|
||||
autoEntrepreneur: /auto-entrepreneur
|
||||
gérantMinoritaire: /chairman-or-managing-director
|
||||
index: /legal-status
|
||||
liste: /list
|
||||
nombreAssociés: /multiple-associates
|
||||
responsabilité: /liability
|
||||
statutDirigeant: /director
|
||||
index: /create
|
||||
documentation:
|
||||
exemples: /examples
|
||||
index: /documentation
|
||||
gérer:
|
||||
déclaration-indépendant:
|
||||
index: /declaration-aid-independent
|
||||
embaucher: /hiring
|
||||
index: /manage
|
||||
sécuritéSociale: /social-security
|
||||
integration:
|
||||
iframe: /iframe
|
||||
index: /integration
|
||||
library: /library
|
||||
nouveautés: /What's new
|
||||
simulateurs:
|
||||
artiste-auteur: /artist-author
|
||||
assimilé-salarié: /assimile-salarie
|
||||
auto-entrepreneur: /auto-entrepreneur
|
||||
comparaison: /social-scheme-comparaison
|
||||
index: /simulators
|
||||
indépendant: /independant
|
||||
salarié: /salaried
|
||||
stats: /stats
|
||||
économieCollaborative:
|
||||
index: /sharing-economy
|
||||
votreSituation: /your-situation
|
||||
payslip:
|
||||
disclaimer: >-
|
||||
It takes into account national law but not union negotiated rules. Lots of
|
|
@ -8,7 +8,7 @@ let { readRules } = require('../rules')
|
|||
|
||||
let { parse } = require('yaml')
|
||||
let rulesTranslationPath = path.resolve('source/locales/rules-en.yaml')
|
||||
let UiTranslationPath = path.resolve('source/locales/en.yaml')
|
||||
let UiTranslationPath = path.resolve('source/locales/ui-en.yaml')
|
||||
|
||||
let attributesToTranslate = [
|
||||
'titre',
|
||||
|
|
|
@ -51,6 +51,7 @@ import Stats from './pages/Stats/LazyStats'
|
|||
import ÉconomieCollaborative from './pages/ÉconomieCollaborative'
|
||||
import redirects from './redirects'
|
||||
import { constructLocalizedSitePath } from './sitePaths'
|
||||
import { AvailableLangs } from 'i18n'
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
const release =
|
||||
|
@ -90,7 +91,7 @@ function Root({ basename, rules }: RootProps) {
|
|||
rules = rulesFr
|
||||
}
|
||||
|
||||
const paths = constructLocalizedSitePath(language)
|
||||
const paths = constructLocalizedSitePath(language as AvailableLangs)
|
||||
return (
|
||||
<Provider
|
||||
basename={basename}
|
||||
|
|
|
@ -5,7 +5,7 @@ import { render } from 'react-dom'
|
|||
import 'regenerator-runtime/runtime'
|
||||
import rules from 'Rules'
|
||||
import i18next from '../../i18n'
|
||||
import translations from '../../locales/en.yaml'
|
||||
import translations from '../../locales/ui-en.yaml'
|
||||
import ruleTranslations from '../../locales/rules-en.yaml'
|
||||
import App from './App'
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ export default function SocialSecurity() {
|
|||
<Link
|
||||
className="ui__ interactive card box"
|
||||
to={{
|
||||
pathname: sitePaths.gérer.déclarationIndépendant.index
|
||||
pathname: sitePaths.gérer.déclarationIndépendant
|
||||
}}
|
||||
>
|
||||
<div className="ui__ big box-icon">{emoji('✍')}</div>
|
||||
|
|
|
@ -32,7 +32,7 @@ export default function Gérer() {
|
|||
<Route path={sitePaths.gérer.embaucher} component={Embaucher} />
|
||||
<Route
|
||||
exact
|
||||
path={sitePaths.gérer.déclarationIndépendant.index}
|
||||
path={sitePaths.gérer.déclarationIndépendant}
|
||||
component={AideDéclarationIndépendant}
|
||||
/>
|
||||
</Switch>
|
||||
|
|
|
@ -2,7 +2,6 @@ import { encodeRuleName } from 'Engine/ruleUtils'
|
|||
import { map, reduce, toPairs, zipObj } from 'ramda'
|
||||
import { DottedName } from 'Rules'
|
||||
import { LegalStatus } from 'Selectors/companyStatusSelectors'
|
||||
import i18n from '../../i18n'
|
||||
|
||||
export const LANDING_LEGAL_STATUS_LIST: Array<LegalStatus> = [
|
||||
'EI',
|
||||
|
@ -16,125 +15,131 @@ export const LANDING_LEGAL_STATUS_LIST: Array<LegalStatus> = [
|
|||
'SA'
|
||||
]
|
||||
|
||||
const translateTo = (language: string) => (
|
||||
str1: string,
|
||||
str2: string,
|
||||
options = {}
|
||||
) =>
|
||||
i18n.t([str1, str2].filter(Boolean), {
|
||||
...(language ? { lng: language } : {}),
|
||||
...options
|
||||
})
|
||||
type LocalizedPath = string
|
||||
type PathFactory = (...args: Array<any>) => LocalizedPath
|
||||
|
||||
interface HasIndex {
|
||||
index: string
|
||||
type SitePathObject<T> = {
|
||||
index: LocalizedPath
|
||||
} & {
|
||||
[key in keyof T]: string | PathFactory | SitePathObject<T[key]>
|
||||
}
|
||||
|
||||
type SitePathsObject<T> = {
|
||||
[key in keyof T]: string | Function | SitePathsObject<T[key]>
|
||||
}
|
||||
const sitePathsFr = {
|
||||
index: '',
|
||||
créer: {
|
||||
index: '/créer',
|
||||
...(Object.fromEntries(
|
||||
LANDING_LEGAL_STATUS_LIST.map(statut => [statut, `/${statut}`])
|
||||
) as { [statut in LegalStatus]: string }),
|
||||
après: '/après-la-création',
|
||||
guideStatut: {
|
||||
index: '/statut-juridique',
|
||||
liste: '/liste',
|
||||
soleProprietorship: '/responsabilité',
|
||||
directorStatus: '/dirigeant',
|
||||
autoEntrepreneur: '/auto-entrepreneur-ou-entreprise-individuelle',
|
||||
|
||||
function constructSitePaths<T extends SitePathsObject<HasIndex>>(
|
||||
multipleAssociates: '/nombre-associés',
|
||||
|
||||
minorityDirector: '/gérant-majoritaire-ou-minoritaire'
|
||||
}
|
||||
},
|
||||
gérer: {
|
||||
index: '/gérer',
|
||||
embaucher: '/embaucher',
|
||||
sécuritéSociale: '/sécurité-sociale',
|
||||
déclarationIndépendant: '/aide-declaration-independants'
|
||||
},
|
||||
simulateurs: {
|
||||
index: '/simulateurs',
|
||||
'assimilé-salarié': '/assimilé-salarié',
|
||||
indépendant: '/indépendant',
|
||||
'auto-entrepreneur': '/auto-entrepreneur',
|
||||
comparaison: '/comparaison-régimes-sociaux',
|
||||
salarié: '/salarié',
|
||||
'artiste-auteur': '/artiste-auteur'
|
||||
},
|
||||
économieCollaborative: {
|
||||
index: '/économie-collaborative',
|
||||
votreSituation: '/votre-situation'
|
||||
},
|
||||
nouveautés: '/nouveautés',
|
||||
stats: '/stats',
|
||||
budget: '/budget',
|
||||
coronavirus: '/coronavirus',
|
||||
integration: {
|
||||
index: '/intégration',
|
||||
iframe: '/iframe',
|
||||
library: '/bibliothèque-de-calcul'
|
||||
},
|
||||
documentation: {
|
||||
index: '/documentation',
|
||||
rule: (dottedName: DottedName) => '/' + encodeRuleName(dottedName)
|
||||
}
|
||||
} as const
|
||||
|
||||
const sitePathsEn = {
|
||||
...sitePathsFr,
|
||||
créer: {
|
||||
...sitePathsFr.créer,
|
||||
index: '/create',
|
||||
après: '/after-registration',
|
||||
guideStatut: {
|
||||
index: '/legal-status',
|
||||
liste: '/list',
|
||||
soleProprietorship: '/liability',
|
||||
directorStatus: '/director',
|
||||
autoEntrepreneur: '/auto-entrepreneur',
|
||||
multipleAssociates: '/multiple-associates',
|
||||
minorityDirector: '/chairman-or-managing-director'
|
||||
}
|
||||
},
|
||||
gérer: {
|
||||
index: '/manage',
|
||||
embaucher: '/hiring',
|
||||
sécuritéSociale: '/social-security',
|
||||
déclarationIndépendant: '/declaration-aid-independent'
|
||||
},
|
||||
simulateurs: {
|
||||
index: '/simulators',
|
||||
'assimilé-salarié': '/assimile-salarie',
|
||||
indépendant: '/independant',
|
||||
'auto-entrepreneur': '/auto-entrepreneur',
|
||||
comparaison: '/social-scheme-comparaison',
|
||||
salarié: '/salaried',
|
||||
'artiste-auteur': '/artist-author'
|
||||
},
|
||||
économieCollaborative: {
|
||||
index: '/sharing-economy',
|
||||
votreSituation: '/your-situation'
|
||||
},
|
||||
nouveautés: '/news',
|
||||
integration: {
|
||||
...sitePathsFr.integration,
|
||||
index: '/integration',
|
||||
library: '/library'
|
||||
}
|
||||
} as const
|
||||
|
||||
function constructSitePaths<T extends SitePathObject<T>>(
|
||||
root: string,
|
||||
{ index, ...sitePaths }: T
|
||||
): T {
|
||||
return {
|
||||
index: root + index,
|
||||
...map(value =>
|
||||
...map((value: LocalizedPath | PathFactory | SitePathObject<string>) =>
|
||||
typeof value === 'string'
|
||||
? root + index + value
|
||||
: typeof value === 'function'
|
||||
? (...args: any) => root + index + String(value(...args))
|
||||
? (...args: Array<unknown>) => root + index + String(value(...args))
|
||||
: constructSitePaths(root + index, value as any)
|
||||
)(sitePaths as any)
|
||||
} as any
|
||||
}
|
||||
|
||||
export const constructLocalizedSitePath = (language: string) => {
|
||||
const t = translateTo(language)
|
||||
return constructSitePaths('', {
|
||||
index: '',
|
||||
créer: {
|
||||
index: t('path.créer.index', '/créer'),
|
||||
...(Object.fromEntries(
|
||||
LANDING_LEGAL_STATUS_LIST.map(statut => [statut, `/${statut}`])
|
||||
) as { [statut in LegalStatus]: string }),
|
||||
après: t('path.créer.après', '/créer/après-la-création'),
|
||||
guideStatut: {
|
||||
index: t('path.créer.guideStatut.index', '/statut-juridique'),
|
||||
liste: t('path.créer.guideStatut.liste', '/liste'),
|
||||
soleProprietorship: t(
|
||||
'path.créer.guideStatut.responsabilité',
|
||||
'/responsabilité'
|
||||
),
|
||||
directorStatus: t(
|
||||
'path.créer.guideStatut.statutDirigeant',
|
||||
'/dirigeant'
|
||||
),
|
||||
autoEntrepreneur: t(
|
||||
'path.créer.guideStatut.autoEntrepreneur',
|
||||
'/auto-entrepreneur-ou-entreprise-individuelle'
|
||||
),
|
||||
multipleAssociates: t(
|
||||
'path.créer.guideStatut.nombreAssociés',
|
||||
'/nombre-associés'
|
||||
),
|
||||
minorityDirector: t(
|
||||
'path.créer.guideStatut.gérantMinoritaire',
|
||||
'/gérant-majoritaire-ou-minoritaire'
|
||||
)
|
||||
}
|
||||
},
|
||||
gérer: {
|
||||
index: t('path.gérer.index', '/gérer'),
|
||||
embaucher: t('path.gérer.embaucher', '/embaucher'),
|
||||
sécuritéSociale: t('path.gérer.sécuritéSociale', '/sécurité-sociale'),
|
||||
déclarationIndépendant: {
|
||||
index: t(
|
||||
'path.gérer.déclaration-indépendant.index',
|
||||
'/aide-declaration-independants'
|
||||
)
|
||||
}
|
||||
},
|
||||
simulateurs: {
|
||||
index: t('path.simulateurs.index', '/simulateurs'),
|
||||
'assimilé-salarié': t(
|
||||
'path.simulateurs.assimilé-salarié',
|
||||
'/assimilé-salarié'
|
||||
),
|
||||
indépendant: t('path.simulateurs.indépendant', '/indépendant'),
|
||||
'auto-entrepreneur': t(
|
||||
'path.simulateurs.auto-entrepreneur',
|
||||
'/auto-entrepreneur'
|
||||
),
|
||||
comparaison: t(
|
||||
'path.simulateurs.comparaison',
|
||||
'/comparaison-régimes-sociaux'
|
||||
),
|
||||
salarié: t('path.simulateurs.salarié', '/salarié'),
|
||||
'artiste-auteur': t('path.simulateurs.artiste-auteur', '/artiste-auteur')
|
||||
},
|
||||
économieCollaborative: {
|
||||
index: t('path.économieCollaborative.index', '/économie-collaborative'),
|
||||
votreSituation: t(
|
||||
'path.économieCollaborative.votreSituation',
|
||||
'/votre-situation'
|
||||
)
|
||||
},
|
||||
nouveautés: t('path.nouveautés', '/nouveautés'),
|
||||
budget: t('path.budget', '/budget'),
|
||||
stats: t('path.stats', '/stats'),
|
||||
documentation: {
|
||||
index: t('path.documentation.index', '/documentation'),
|
||||
rule: (dottedName: DottedName) => '/' + encodeRuleName(dottedName)
|
||||
},
|
||||
coronavirus: t('path.coronavirus', '/coronavirus'),
|
||||
integration: {
|
||||
index: t('path.integration.index', '/intégration'),
|
||||
iframe: t('path.integration.iframe', '/iframe'),
|
||||
library: t('path.integration.library', '/bibliothèque-de-calcul')
|
||||
}
|
||||
})
|
||||
export const constructLocalizedSitePath = (language: 'en' | 'fr') => {
|
||||
const sitePaths = language === 'fr' ? sitePathsFr : sitePathsEn
|
||||
return constructSitePaths('', sitePaths)
|
||||
}
|
||||
|
||||
export type SitePathsType = ReturnType<typeof constructLocalizedSitePath>
|
||||
|
|
Loading…
Reference in New Issue