Skip to content

Commit

Permalink
chore: improve readability - wip
Browse files Browse the repository at this point in the history
  • Loading branch information
RMCampos committed Nov 30, 2024
1 parent f403905 commit bf8797e
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 201 deletions.
69 changes: 69 additions & 0 deletions client/src/utils/PortugueseUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Translates a time ago message from English to Brazilian Portuguese.
*
* @param {string} textValue The text message to be translated.
* @param {number} numberValue The number value to be used in the message.
* @returns The message translated.
*/
function translateTimeAgoPtBr(textValue: string, numberValue: number): string {
if (textValue.includes('year')) {
return textValue.includes('s ')
? `${numberValue} anos atrás`
: `${numberValue} ano atrás`;
}
else if (textValue.includes('month')) {
return textValue.includes('s ')
? `${numberValue} meses atrás`
: `${numberValue} mês atrás`;
}
else if (textValue.includes('days')) {
return textValue.includes('s ')
? `${numberValue} dias atrás`
: `${numberValue} dia atrás`;
}
else if (textValue.includes('hour')) {
return textValue.includes('s ')
? `${numberValue} horas atrás`
: `${numberValue} hora atrás`;
}
else if (textValue.includes('minutes')) {
return textValue.includes('s ')
? `${numberValue} minutos atrás`
: `${numberValue} minuto atrás`;
}
else if (textValue.includes('seconds')) {
return textValue.includes('s ')
? `${numberValue} segundos atrás`
: `${numberValue} segundo atrás`;
}

return 'Momentos atrás';
}

/**
* Translates a time left message from English to Brazilian Portuguese.
*
* @param {string} textValue The text message to be translated.
* @param {number} numberValue The number value to be used in the message.
* @returns The message translated.
*/
function translateTimeLeftPtBr(textValue: string, numberValue: number): string {
if (textValue.includes('year')) {
return textValue.includes('s ')
? `${numberValue} anos restantes`
: `${numberValue} ano restante`;
}
else if (textValue.includes('month')) {
return textValue.includes('s ')
? `${numberValue} meses restantes`
: `${numberValue} mês restante`;
}
else if (textValue.includes('day')) {
return textValue.includes('s ')
? `${numberValue} dias restantes`
: `${numberValue} dia restante`;
}
return textValue;
}

export { translateTimeAgoPtBr, translateTimeLeftPtBr };
36 changes: 36 additions & 0 deletions client/src/utils/RussianUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function translateTimeAgoRu(textValue: string, numberValue: number): string {
if (textValue.includes('year')) {
return textValue.includes('s ')
? `${numberValue} года назад`
: `${numberValue} год назад`;
}
else if (textValue.includes('month')) {
return textValue.includes('s ')
? `${numberValue} месяца назад`
: `${numberValue} месяц назад`;
}
else if (textValue.includes('days')) {
return textValue.includes('s ')
? `${numberValue} дня назад`
: `${numberValue} день назад`;
}
else if (textValue.includes('hour')) {
return textValue.includes('s ')
? `${numberValue} часа назад`
: `${numberValue} час назад`;
}
else if (textValue.includes('minutes')) {
return textValue.includes('s ')
? `${numberValue} минуты назад`
: `${numberValue} минуту назад`;
}
else if (textValue.includes('seconds')) {
return textValue.includes('s ')
? `${numberValue} секунд назад`
: `${numberValue} секунду назад`;
}

return 'Несколько минут назад';
}

export { translateTimeAgoRu };
69 changes: 69 additions & 0 deletions client/src/utils/SpanishUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Translates a time ago message from English to Spanish.
*
* @param {string} textValue The text message to be translated.
* @param {number} numberValue The number value to be used in the message.
* @returns The message translated.
*/
function translateTimeAgoEs(textValue: string, numberValue: number): string {
if (textValue.includes('year')) {
return textValue.includes('s ')
? `Hace ${numberValue} años`
: `Hace ${numberValue} año`;
}
else if (textValue.includes('month')) {
return textValue.includes('s ')
? `Hace ${numberValue} meses`
: `Hace ${numberValue} mes`;
}
else if (textValue.includes('days')) {
return textValue.includes('s ')
? `Hace ${numberValue} días`
: `Hace ${numberValue} día`;
}
else if (textValue.includes('hour')) {
return textValue.includes('s ')
? `Hace ${numberValue} horas`
: `Hace ${numberValue} hora`;
}
else if (textValue.includes('minutes')) {
return textValue.includes('s ')
? `Hace ${numberValue} minutos`
: `Hace ${numberValue} minuto`;
}
else if (textValue.includes('seconds')) {
return textValue.includes('s ')
? `Hace ${numberValue} segundos`
: `Hace ${numberValue} segundo`;
}

return 'Hace momentos';
}

/**
* Translates a time left message from English to Spanish.
*
* @param {string} textValue The text message to be translated.
* @param {number} numberValue The number value to be used in the message.
* @returns The message translated.
*/
function translateTimeLeftEs(textValue: string, numberValue: number): string {
if (textValue.includes('year')) {
return textValue.includes('s ')
? `Faltan ${numberValue} años`
: `Falta ${numberValue} año`;
}
else if (textValue.includes('month')) {
return textValue.includes('s ')
? `Faltan ${numberValue} meses`
: `Falta ${numberValue} mes`;
}
else if (textValue.includes('day')) {
return textValue.includes('s ')
? `Faltan ${numberValue} días`
: `Falta ${numberValue} día`;
}
return textValue;
}

export { translateTimeAgoEs, translateTimeLeftEs };
Loading

0 comments on commit bf8797e

Please sign in to comment.