(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'
lastUpdate: 'Last Updated'
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:
# translationDisclaimer: >
# The following text is just an auxiliary translation.
# The only legally binding version of the Terms of Service is the English one, available
# {https://en.pronouns.page/terms=here}.
# you can leave the terms untranslated, or translate it (copy it from the English version)
# and include the following disclaimer:
translationDisclaimer: >
The following text is just an auxiliary translation.
The only legally binding version of the Terms of Service is the English one, available
{https://en.pronouns.page/terms=here}.
content:
intro: >
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';
const localeSpecificFlagAlt = /flags_alt\.-(.+)-/;
export function listMissingTranslations(translations, baseTranslations, config) {
const expectedTranslations = [...deepListKeys(baseTranslations)];
@ -32,6 +34,13 @@ export function listMissingTranslations(translations, baseTranslations, config)
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
if (keyMatches(
'home.welcome',
@ -41,6 +50,10 @@ export function listMissingTranslations(translations, baseTranslations, config)
'contact.team.extra',
'contact.team.join.',
'user.login.help',
'terms.content.',
'terms.update.',
'privacy.content.',
'privacy.consent.',
)) {
return false;
}
@ -75,6 +88,12 @@ export function listMissingTranslations(translations, baseTranslations, config)
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')) {
return false;
}
@ -103,6 +122,10 @@ export function listMissingTranslations(translations, baseTranslations, config)
return false;
}
if (config.api === null && keyMatches('profile.header', 'api.example', 'api.query')) {
return false;
}
return true;
});
}