Refactor Encounters, use new translations format for save space

This commit is contained in:
Roman Jaroš 2025-04-17 19:04:49 +02:00
parent 7d9f58650a
commit 908f45eb9b
59 changed files with 103852 additions and 58396 deletions

View file

@ -0,0 +1,30 @@
import { TolgeeKey } from '../types';
export const normalize = (translation: string | null | undefined) => {
if (translation == null) {
return '';
}
return translation.replace(/\n/g, '\\n').replace(/"/g, "'");
};
export const writeMaleTranslation = (value: TolgeeKey['translations']) => {
let text = '';
const normalizedValue = normalize(value?.['cs']?.text);
if (normalizedValue != '') {
text += '\tm = "' + normalizedValue + '", \n';
}
return text;
};
export const writeAlsoFemaleTranslation = (value: TolgeeKey['translations']) => {
let text = '';
const normalizedMaleValue = normalize(value?.['cs']?.text);
const normalizedFemaleValue = normalize(value?.['csf']?.text);
if (normalizedMaleValue != '') {
text += '\tm = "' + normalizedMaleValue + '", \n';
}
if (normalizedFemaleValue != '' && normalizedMaleValue != normalizedFemaleValue) {
text += '\tf = "' + normalizedFemaleValue + '", \n';
}
return text;
};