(trans) exclude terms, privacy terms, locale-specific flags and some api keys from expected translations

This commit is contained in:
Valentyne Stigloher 2024-02-10 16:51:50 +01:00
parent c573f5c824
commit d277a672f5
2 changed files with 29 additions and 5 deletions

View File

@ -927,11 +927,12 @@ terms:
header: 'Terms of Service' header: 'Terms of Service'
lastUpdate: 'Last Updated' lastUpdate: 'Last Updated'
consent: 'By registering you''re accepting the {/terms=Terms of Service}.' consent: 'By registering you''re accepting the {/terms=Terms of Service}.'
# you can leave the terms untranslated, or translate it (copy it from the English version) and include the following disclaimer: # you can leave the terms untranslated, or translate it (copy it from the English version)
# translationDisclaimer: > # and include the following disclaimer:
# The following text is just an auxiliary translation. translationDisclaimer: >
# The only legally binding version of the Terms of Service is the English one, available The following text is just an auxiliary translation.
# {https://en.pronouns.page/terms=here}. The only legally binding version of the Terms of Service is the English one, available
{https://en.pronouns.page/terms=here}.
content: content:
intro: > intro: >
These Terms of Service govern your access to and use of the Service provided on the website These Terms of Service govern your access to and use of the Service provided on the website

View File

@ -1,5 +1,7 @@
import { deepGet, deepListKeys } from './helpers.js'; import { deepGet, deepListKeys } from './helpers.js';
const localeSpecificFlagAlt = /flags_alt\.-(.+)-/;
export function listMissingTranslations(translations, baseTranslations, config) { export function listMissingTranslations(translations, baseTranslations, config) {
const expectedTranslations = [...deepListKeys(baseTranslations)]; const expectedTranslations = [...deepListKeys(baseTranslations)];
@ -32,6 +34,13 @@ export function listMissingTranslations(translations, baseTranslations, config)
return false; return false;
} }
// disclaimer is only required when optional translations are present for a non-English locale
if ((!has('terms.content') && !has('privacy.content') || config.locale === 'en') &&
keyMatches('terms.translationDisclaimer')
) {
return false;
}
// optional keys // optional keys
if (keyMatches( if (keyMatches(
'home.welcome', 'home.welcome',
@ -41,6 +50,10 @@ export function listMissingTranslations(translations, baseTranslations, config)
'contact.team.extra', 'contact.team.extra',
'contact.team.join.', 'contact.team.join.',
'user.login.help', 'user.login.help',
'terms.content.',
'terms.update.',
'privacy.content.',
'privacy.consent.',
)) { )) {
return false; return false;
} }
@ -75,6 +88,12 @@ export function listMissingTranslations(translations, baseTranslations, config)
return false; return false;
} }
// locale specific flags
const match = k.match(localeSpecificFlagAlt);
if (match && match[1] !== config.locale) {
return false;
}
if (!config.pronouns.honorifics && keyMatches('pronouns.slashes.pluralHonorific')) { if (!config.pronouns.honorifics && keyMatches('pronouns.slashes.pluralHonorific')) {
return false; return false;
} }
@ -103,6 +122,10 @@ export function listMissingTranslations(translations, baseTranslations, config)
return false; return false;
} }
if (config.api === null && keyMatches('profile.header', 'api.example', 'api.query')) {
return false;
}
return true; return true;
}); });
} }