Rename all french to english

This commit is contained in:
pikiou
2021-12-08 10:46:53 +01:00
parent d63f906206
commit 1844c6acad
66 changed files with 653 additions and 625 deletions

View File

@@ -75,7 +75,7 @@ export function listGet<Element>(
export function add<ElementNoId extends object, Element extends ElementNoId & ElementWithId>(
elementName: string,
translation: ElementTranslation
): (membreWithoutId: ElementNoId) => Promise<{
): (volunteerWithoutId: ElementNoId) => Promise<{
data?: Element
error?: Error
}> {
@@ -83,12 +83,13 @@ export function add<ElementNoId extends object, Element extends ElementNoId & El
data?: Element
error?: Error
}
return async (membreWithoutId: ElementNoId): Promise<ElementGetResponse> => {
return async (volunteerWithoutId: ElementNoId): Promise<ElementGetResponse> => {
try {
const invertedTranslationWithoutId = _.invert(_.omit(translation, "id"))
const frenchDataWithoutId = _.mapValues(
invertedTranslationWithoutId,
(englishProp: string, _frenchProp: string) => (membreWithoutId as any)[englishProp]
(englishProp: string, _frenchProp: string) =>
(volunteerWithoutId as any)[englishProp]
)
const { data } = await axios.post(
@@ -114,7 +115,7 @@ export function add<ElementNoId extends object, Element extends ElementNoId & El
export function set<Element>(
elementName: string,
translation: ElementTranslation
): (membre: Element) => Promise<{
): (volunteer: Element) => Promise<{
data?: Element
error?: Error
}> {
@@ -122,12 +123,12 @@ export function set<Element>(
data?: Element
error?: Error
}
return async (membre: Element): Promise<ElementGetResponse> => {
return async (volunteer: Element): Promise<ElementGetResponse> => {
try {
const invertedTranslation = _.invert(translation)
const frenchData = _.mapValues(
invertedTranslation,
(englishProp: string) => (membre as any)[englishProp]
(englishProp: string) => (volunteer as any)[englishProp]
)
const { data } = await axios.post(

View File

@@ -1,36 +0,0 @@
import { get, listGet, add, set } from "./accessors"
export class Envie {
id = 0
domain = ""
wish = ""
details = ""
teams: string[] = []
addedDate = ""
}
export const translationEnvie: { [k in keyof Envie]: string } = {
id: "id",
domain: "domaine",
wish: "envies",
details: "precisions",
teams: "equipes",
addedDate: "dateAjout",
}
const elementName = "Envie"
export type EnvieWithoutId = Omit<Envie, "id">
export const envieGet = get<Envie>(elementName, translationEnvie)
export const envieListGet = listGet<Envie>(elementName, translationEnvie)
export const envieAdd = add<EnvieWithoutId, Envie>(elementName, translationEnvie)
export const envieSet = set<Envie>(elementName, translationEnvie)

View File

@@ -1,6 +1,6 @@
import { get, listGet, add, set } from "./accessors"
export class JeuJav {
export class JavGame {
id = 0
title = ""
@@ -32,7 +32,7 @@ export class JeuJav {
bggPhoto = ""
}
export const translationJeuJav: { [k in keyof JeuJav]: string } = {
export const translationJavGame: { [k in keyof JavGame]: string } = {
id: "id",
title: "titre",
author: "auteur",
@@ -50,14 +50,14 @@ export const translationJeuJav: { [k in keyof JeuJav]: string } = {
bggPhoto: "bggPhoto",
}
const elementName = "JeuJav"
const elementName = "JavGame"
export type JeuJavWithoutId = Omit<JeuJav, "id">
export type JavGameWithoutId = Omit<JavGame, "id">
export const jeuJavGet = get<JeuJav>(elementName, translationJeuJav)
export const javGameGet = get<JavGame>(elementName, translationJavGame)
export const jeuJavListGet = listGet<JeuJav>(elementName, translationJeuJav)
export const javGameListGet = listGet<JavGame>(elementName, translationJavGame)
export const jeuJavAdd = add<JeuJavWithoutId, JeuJav>(elementName, translationJeuJav)
export const javGameAdd = add<JavGameWithoutId, JavGame>(elementName, translationJavGame)
export const jeuJavSet = set<JeuJav>(elementName, translationJeuJav)
export const javGameSet = set<JavGame>(elementName, translationJavGame)

View File

@@ -1,6 +1,6 @@
import { get, listGet, add, set } from "./accessors"
export class Membre {
export class Volunteer {
id = 0
lastname = ""
@@ -28,7 +28,7 @@ export class Membre {
password = ""
}
export const translationMember: { [k in keyof Membre]: string } = {
export const translationMember: { [k in keyof Volunteer]: string } = {
id: "id",
lastname: "nom",
firstname: "prenom",
@@ -44,26 +44,26 @@ export const translationMember: { [k in keyof Membre]: string } = {
password: "passe",
}
const elementName = "Membre"
const elementName = "Volunteer"
export const emailRegexp =
/^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i
export const passwordMinLength = 4
export interface MemberLogin {
membre?: {
volunteer?: {
firstname: string
}
jwt?: string
error?: string
}
export type MembreWithoutId = Omit<Membre, "id">
export type VolunteerWithoutId = Omit<Volunteer, "id">
export const membreGet = get<Membre>(elementName, translationMember)
export const volunteerGet = get<Volunteer>(elementName, translationMember)
export const membreListGet = listGet<Membre>(elementName, translationMember)
export const volunteerListGet = listGet<Volunteer>(elementName, translationMember)
export const membreAdd = add<MembreWithoutId, Membre>(elementName, translationMember)
export const volunteerAdd = add<VolunteerWithoutId, Volunteer>(elementName, translationMember)
export const membreSet = set<Membre>(elementName, translationMember)
export const volunteerSet = set<Volunteer>(elementName, translationMember)

36
src/services/wishes.ts Normal file
View File

@@ -0,0 +1,36 @@
import { get, listGet, add, set } from "./accessors"
export class Wish {
id = 0
domain = ""
wish = ""
details = ""
teams: string[] = []
addedDate = ""
}
export const translationWish: { [k in keyof Wish]: string } = {
id: "id",
domain: "domaine",
wish: "wishes",
details: "precisions",
teams: "equipes",
addedDate: "dateAjout",
}
const elementName = "Wish"
export type WishWithoutId = Omit<Wish, "id">
export const wishGet = get<Wish>(elementName, translationWish)
export const wishListGet = listGet<Wish>(elementName, translationWish)
export const wishAdd = add<WishWithoutId, Wish>(elementName, translationWish)
export const wishSet = set<Wish>(elementName, translationWish)