Refactor Encounters, use new translations format for save space
This commit is contained in:
parent
7d9f58650a
commit
908f45eb9b
59 changed files with 103852 additions and 58396 deletions
30
.support/utils/translation.ts
Normal file
30
.support/utils/translation.ts
Normal 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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue