Merge branch 'translations-using-base-route-name' into 'main'

Check for routes inside translations

See merge request PronounsPage/PronounsPage!419
This commit is contained in:
Valentyne Stigloher 2024-02-17 20:16:46 +00:00
commit a765140982
17 changed files with 115 additions and 98 deletions

View File

@ -26,10 +26,14 @@ check:
# the referenced SHA needs to be additionally changed in yarn.lock
- 'sed -i "s/f00db606f659dca78b143b7bcab5671b2cb459a8/0d322c775cbe9bf99da261700be30251291b51a8/" yarn.lock'
- yarn install --frozen-lockfile || record_failure
- git restore package.json yarn.lock
- end_section
- start_section "Setup"
- make install
# revert the changes for the FontAwesomePro dependency only now because `make install` calls `yarn`
- git restore package.json yarn.lock
- make switch LANG=en
- end_section
- start_section "Unit Tests"
- >

View File

@ -195,7 +195,8 @@ If you're having issues with [HRM](https://webpack.js.org/concepts/hot-module-re
You can either translate on-site via the translation mode, which will get merged eventually by the team
or by directly editing the corresponding `translation.suml`.
If a locale does not have a value translated, those inside `_base/translation.suml` are used.
Please check `TODO` comments and translation values which have been copied, not translated from `_base`.
Please check `TODO` comments and translation values which have been copied, but not translated from `_base`.
If the original contains internal links, ensure that the route is also valid for your locale.
To check for missing translations, you can use the `admin/translations/missing` route.
### Creating a new language version

View File

@ -469,7 +469,7 @@ contact:
header: 'Erstelle eine neue Sprachversion'
description: >
Anweisungen zum Erstellen einer neuen Sprachversion findest du
{https://en.pronouns.page/new-version=hier}. Bevor du beginnst, {/contact=kontaktiere uns} bitte, um sich
{https://en.pronouns.page/new-version=hier}. Bevor du beginnst, {/kontakt=kontaktiere uns} bitte, um sich
mit anderen abzustimmen, die möglicherweise auch daran arbeiten können.
translations:
header: 'Übersetzungen hinzufügen oder korrigieren'

View File

@ -1246,7 +1246,7 @@ privacy:
optional:
header: 'Optional cookies'
description: >
We show ads to fund the project {/why-ads=(more details here)}.
We show ads to fund the project {/blog/why-ads=(more details here)}.
You can agree for related third-parties to store information about you
for the purposes of gathering statistics and personalising ads.
details: 'You can read more in Ezoic''s {https://g.ezoic.net/privacy/pronouns.page=Privacy Policy}.'

View File

@ -491,7 +491,7 @@ contact:
header: 'Crea una versión nueva en otro idioma'
description: >
Las intrucciones para crear una nueva versión en otro idioma están disponibles
{https://en.pronouns.page/new-version=aquí}. Antes de empezar, por favor {/contact=contáctanos} para
{https://en.pronouns.page/new-version=aquí}. Antes de empezar, por favor {/contacto=contáctanos} para
coordinarte con otres que también puedan estar trabajando en esa versión también.
translations:
header: 'Agrega correcciones y traducciones'
@ -668,7 +668,7 @@ profile:
Puedes también usar nuestro sitio web para crear una tarjeta {/@example=como esta},
que contenga tus nombres, pronombres, banderas de orgullo, palabras preferidas etc.
Después podrás poner un enlace a la tarjeta en tu biografía o tu firma de correo electrónico.
Simplemente crea una cuenta {/account=aquí}.
Simplemente crea una cuenta {/cuenta=aquí}.
bannerButton: 'Crear una tarjeta'
card:
link: 'Imagen de la tarjeta'
@ -708,7 +708,7 @@ profile:
sensitive:
header: 'Advertencia de contenido'
info: >
Cierto contenido debe seguir nuestro {/terms=Terminos de Servicio} pero aún no es apropiado para menores, ser
Cierto contenido debe seguir nuestro {/terminos=Terminos de Servicio} pero aún no es apropiado para menores, ser
potencialmente desencadenante para personas con traumas, etc. Porfavor se reapetuoso con las personas que
visitan tu tarjeta y advierte antes de que avancen. Algunos ejemplos de CW pueden ser, "mención al alcohol",
"insinuaciones sexuales", "menciones a situaciones queerphobicas", etc.
@ -1050,15 +1050,6 @@ ban:
header: 'Tu perfil no se mostrará a nadie.'
banned: 'Tu perfil no se mostrará a nadie.'
termsIntro: 'De acuerdo con nuestros {/terminos=Términos de Servicio}'
# TODO
appeal: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our {/terms=Terms of Service},
please contact us at {mailto:contact@pronouns.page=contact@pronouns.page} and we might get another look in a bigger group.
appealEmail: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our Terms of Service,
please respond to this email and we might get another look in a bigger group.
report:
action: 'Reportar abuso'

View File

@ -71,7 +71,6 @@ pronouns:
description: >
Even though for many people it's incredibly important that people use specific pronouns to talk about them,
others don't mind being addressed in any way as long as the context is clear as to who one talks about.
options: 'check out the options [share]{/pronouns=here}.'
others: ''
othersRaw: ''
or: 'või'
@ -613,15 +612,6 @@ profile:
description: 'Kirjeldus'
names: 'Nimed'
pronouns: 'Asesõnad'
pronounsInfo: >
You can enter a <strong>pronoun</strong> (eg. “they” or “she/her”)
or a <strong>link</strong> (eg. “https://en.pronouns.page/e”)
or the custom five forms (eg. “ze/zem/zir/zirs/zirself”).
Keep in mind that <strong>all five forms</strong> are required in that case,
otherwise the app can only guess what exactly do you mean.
You can also use {/pronouns#generator=<strong>the generator</strong>} to fill out sentences with custom forms.
If your pronouns follow the {/pronouns#nameself=<strong>nameself pattern</strong>},
you can also use a colon shorthand (eg. “:star”).
pronounsNotFound: 'Unrecognised format. Please check out the instruction above.'
words: 'Sõnad'
wordsColumnHeader: 'Veeru päis'

View File

@ -570,7 +570,8 @@ profile:
sensitive:
header: 'Avertissement de contenu'
info: >
Certains contenus peuvent être autorisés par nos {/terms=Conditions d'utilisation}, mais ne pas convenir aux
Certains contenus peuvent être autorisés par nos {/termes=Conditions d'utilisation},
mais ne pas convenir aux
mineurs, être potentiellement déclencheurs pour les personnes souffrant de traumatismes, etc. Veuillez
respecter les personnes visitant votre carte et les avertir à l'avance. Des exemples de CW pourraient être
"mention d'alcool", "insinuations sexuelles", "mention d'une situation queerphobe".
@ -615,7 +616,7 @@ profile:
Vous pouvez utiliser ce site pour créer votre carte, {/@example=comme celle ci},
avec vos noms, pronoms, drapeaux, mots préférés, etc…
Vous pourrez ensuite copier le lien dans votre bio ou dans vos signatures de mail.
Créez votre compte {/account=ici}.
Créez votre compte {/compte=ici}.
example: 'Voir un exemple de carte'
bannerButton: 'Créer une carte'
@ -710,7 +711,7 @@ confirm:
terms:
header: 'Conditions d''utilisation'
lastUpdate: 'Dernière mise à jour'
consent: 'En vous inscrivant, vous acceptez les {/terms=Conditions d''utilisation}.'
consent: 'En vous inscrivant, vous acceptez les {/termes=Conditions d''utilisation}.'
update:
header: 'Nous avons mis à jour nos conditions d''utilisation.'
intro: >
@ -783,7 +784,7 @@ ban:
termsIntro: 'Selon nos {/termes=Termes de service}'
appeal: >
La modération est un sujet complexe et délicat. Elle est assurée par des bénévoles qui ne sont pas toujours d'accord entre elleux
ou ne sont pas toujours au courant de certains problèmes. Si vous pensez que votre compte n'a pas enfreint nos {/terms=Conditions d'utilisation},
ou ne sont pas toujours au courant de certains problèmes. Si vous pensez que votre compte n'a pas enfreint nos {/termes=Conditions d'utilisation},
veuillez nous contacter à {mailto:contact@pronouns.page=contact@pronouns.page} et nous pourrons peut-être nous pencher à nouveau sur la question au sein d'un groupe plus important.
appealEmail: >
La modération est un sujet complexe et délicat. Elle est assurée par des bénévoles qui ne sont pas toujours d'accord entre elleux

View File

@ -545,7 +545,7 @@ profile:
hide: 'カードをぼかす'
display: 'カードを続ける'
info: >
一部のコンテンツは{/terms=Terms of Service}で許可されていることがありますが、未成年やPTSDを抱えている人にとって不適切で刺激的になる可能性があります。
一部のコンテンツは{/利用規約=Terms of Service}で許可されていることがありますが、未成年やPTSDを抱えている人にとって不適切で刺激的になる可能性があります。
あなたのカードを訪問する人に敬意を払い、事前に警告してください。コンテンツの警告の例としては「アルコールの言及」、「性的ほのめかし」、「同性愛嫌悪の状況についての言及」などが挙げられます。
flagsCustomForm:
label: 'ラベル名'
@ -754,7 +754,7 @@ ban:
# TODO
appeal: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our {/terms=Terms of Service},
or be aware of some issues. If you think your account didn't breach our {/利用規約=Terms of Service},
please contact us at {mailto:contact@pronouns.page=contact@pronouns.page} and we might get another look in a bigger group.
appealEmail: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
@ -766,7 +766,7 @@ report:
comment: 'このプロフィールのどこが問題かを簡潔に書いてください。'
confirm: '@%username%のプロフィールを報告してもよろしいですか?'
sent: '報告が送信されました。ご協力ありがとうございました!'
terms: '{/terms=利用規約}で何が禁止されているかを確認してください:'
terms: '{/利用規約=利用規約}で何が禁止されているかを確認してください:'
hoarding: 'ユーザー名が他の人に予約されているという報告はしないでください。一定期間利用がないカードなしのアカウントは自動的に削除されます。報告しても削除が早くなることはありません。'
flags:

View File

@ -502,7 +502,7 @@ profile:
Puedes tambien uzar muestro sitio internetiko para krear una karta {/@example=komo esta},
ke kontenga tus nombres, pronombres, bandieras de orgolyo, biervos preferidos ets.
Dospues podras meter un atadijo a la karta en tu biografia o tu sinyatura de posta elektronika.
Simplemente krea un kuento {/account=aki}.
Simplemente krea un kuento {/kuento=aki}.
bannerButton: 'Krear una karta'
card:
link: 'Imaje de la karta'
@ -624,15 +624,6 @@ ban:
header: 'Tu profil no se amostrara a dinguno.'
banned: 'Tu profil no se amostrara a dinguno.'
termsIntro: 'De akodro kon muestros {/terminos=Terminos de Servisio}:'
# TODO
appeal: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our {/terms=Terms of Service},
please contact us at {mailto:contact@pronouns.page=contact@pronouns.page} and we might get another look in a bigger group.
appealEmail: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our Terms of Service,
please respond to this email and we might get another look in a bigger group.
report:
action: 'Denusyar abuzo'

View File

@ -638,7 +638,7 @@ confirm:
terms:
header: 'Gebruiksvoorwaarden'
lastUpdate: 'Laatst bijgewerkt'
consent: 'Door te registreren accepteer je de {/terms=gebruiksvoorwaarden}.'
consent: 'Door te registreren accepteer je de {/voorwaarden=gebruiksvoorwaarden}.'
privacy:
header: 'Privacy Policy' # TODO
@ -706,7 +706,7 @@ ban:
# TODO
appeal: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our {/terms=Terms of Service},
or be aware of some issues. If you think your account didn't breach our {/voorwaarden=Terms of Service},
please contact us at {mailto:contact@pronouns.page=contact@pronouns.page} and we might get another look in a bigger group.
appealEmail: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
@ -718,7 +718,7 @@ report:
comment: 'Leg kort uit wat ongepast is aan dit profiel'
confirm: 'Weet je zeker dat je @%username% wilt rapporteren?'
sent: 'Jouw rapportering was verzonden. Bedankt voor je hulp!'
terms: 'Houd datgene wat verboden is volgens onze {/terms=Gebruiksvoorwaarden} in jouw achterhoofd.'
terms: 'Houd datgene wat verboden is volgens onze {/voorwaarden=Gebruiksvoorwaarden} in jouw achterhoofd.'
hoarding: ' Rapporteer alsjeblieft geen gebruikers die gebruikersnamen hamsteren. We verwijderen automatisch accounts zonder kaarten na een periode van inactiviteit. Jouw melding zal dit proces niet verspoedigen.'
translationMode:

View File

@ -398,7 +398,7 @@ contact:
header: 'Lag en ny språk versjon'
description: >
Intruksjoner for å lage en ny språk versjon er tilgjengelige {https://en.pronouns.page/new-version=her}.
Før du starter, vennligst {/contact=kontakt oss} for å koordinere med andre om det.
Før du starter, vennligst {/kontakt=kontakt oss} for å koordinere med andre om det.
translations:
header: 'Legg til eller rett oversettelser'
description: >
@ -543,7 +543,7 @@ profile:
Du kan også bruke nettsiden vår til å lage et kort, {/@example=sånn som denne},
som inneholder navnene dine, pronomen, pride flagg, likte ord, osv.
Så kan du linke den til din bio eller epost-signatur.
Bare lag en bruker {/account=her}.
Bare lag en bruker {/bruker=her}.
bannerButton: 'Lag et kort'
card:
link: 'Kortbilde'
@ -646,7 +646,7 @@ crud:
search: 'Søk…'
author: 'Lagt til av'
saved: 'Endringer er lagret!'
loginRequired: '{/account=Log in} for å'
loginRequired: '{/bruker=Log in} for å'
copy: 'Kopier link'
download: 'Last ned'
loadAll: 'Last inn alle…'
@ -696,7 +696,7 @@ confirm:
terms:
header: 'Vilkår og betingelser'
lastUpdate: 'Sist oppdatert'
consent: 'Ved å registrere deg sier du ja til våre vilkår og betingelser {/vilkår=vilkår og betingelser}.'
consent: 'Ved å registrere deg sier du ja til våre vilkår og betingelser {/vilkar=vilkår og betingelser}.'
privacy:
header: 'Personvernerklæring '
@ -760,24 +760,13 @@ ban:
confirm: 'Er du sikker på at du vil forby @%username%?'
header: 'Du er forbydd. Profilen din vil ikke bli vist til noen.'
banned: 'Forbydd'
termsIntro: 'Ifølge våre {/termes=Terms of Service}'
# TODO
appeal: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our {/terms=Terms of Service},
please contact us at {mailto:contact@pronouns.page=contact@pronouns.page} and we might get another look in a bigger group.
appealEmail: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our Terms of Service,
please respond to this email and we might get another look in a bigger group.
termsIntro: 'Ifølge våre {/vilkar=Terms of Service}'
report:
action: 'Rapporter problem'
comment: 'Vennligst forklar enkelt hva som er galt med denne profilen'
confirm: 'Er du sikker på at du vil rapportere @%username%?'
sent: 'Rapport sendt. Takk for hjelpen!'
terms: 'Keep in mind what''s forbidden according to our {/terms=Terms of Service}' # TODO
hoarding: 'Please don''t report for “username hoarding”. We automatically remove accounts without cards after a period of inactivity. Your report will not make it faster.' # TODO
translationMode:
changes: 'Endringer'

View File

@ -1368,7 +1368,7 @@ contact:
header: 'Stwórz nową wersję językową'
description: >
Instrukcje tworzenia nowej wersji językowej strony dostępne są {https://en.pronouns.page/new-version=tutaj}.
Zanim zaczniesz pracę, {/contact=skontaktuj się z nami}, by skoordynować z innymi osobami.
Zanim zaczniesz pracę, {/kontakt=skontaktuj się z nami}, by skoordynować z innymi osobami.
technical:
header: 'Zgłoś pull requesta'
description: >
@ -1834,7 +1834,7 @@ terms:
translationDisclaimer: >
Poniższy tekst jest wyłącznie pomocniczym tłumaczeniem.
Jedyną prawnie wiążącą wersją Regulaminu jest wersja anglojęzyczna dostępna
{https://en.pronouns.page/terms=tutaj}.
{https://en.pronouns.page/regulamin=tutaj}.
content:
intro: >
Poniższy Regulamin reguluje Twój dostęp do oraz warunki użytkowania Usług dostępnych poprzez stronę
@ -1901,10 +1901,6 @@ terms:
advertisement: 'reklamy'
copyright: 'naruszenia praw autorskich i znaków towarowych'
miscellaneous: 'inne'
# TODO
violationsStrict: >
We reserve the right to interpret as hate-speech all instances of non-obvious, concealed hate speech
(eg. telling some people to “DNI” because of their queer identity, transphobic dogwhistles like “superstraight” or “semibisexual”, etc.).
responsibility: >
Ponosisz odpowiedzialność za Treść, którą umieszczasz w Usługach.
Jeśli złamiesz ten Regulamin, usuniemy Twoje Treści bez uprzedniego powiadomienia,
@ -2022,15 +2018,6 @@ ban:
header: 'Twoje konto jest zablokowane. Twoje profile nie są widoczne publicznie.'
banned: 'Konto nieaktywne'
termsIntro: 'Zgodnie z naszym {/regulamin=Regulaminem}'
# TODO
appeal: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our {/terms=Terms of Service},
please contact us at {mailto:contact@pronouns.page=contact@pronouns.page} and we might get another look in a bigger group.
appealEmail: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our Terms of Service,
please respond to this email and we might get another look in a bigger group.
report:
action: 'Zgłoś profil'

View File

@ -439,7 +439,7 @@ contact:
header: 'Crie uma nova versão em outro idioma '
description: >
Instruções para criar uma nova versão em outro idioma estão disponíveis
{https://en.pronouns.page/new-version=aqui}. Antes de começar, por favor, {/contact=contate-nos} para que
{https://en.pronouns.page/new-version=aqui}. Antes de começar, por favor, {/contato=contate-nos} para que
assim a gente possa coordenar com outres um trabalho em conjunto.
entries:
header: 'Adicione páginas'
@ -665,7 +665,7 @@ profile:
Você pode usar o nosso site para criar cartões, {/@example=como esse},
que está incluindo seus nomes, prononomes, bandeiras, palavras de que se gosta, etc.
Depois pode por no seu bio ou rodapé de e-mail.
Somente crie a sua conta {/account=aqui}.
Somente crie a sua conta {/conta=aqui}.
bannerButton: 'Crie um cartão'
card:
link: 'Imagem do cartão'
@ -682,7 +682,7 @@ profile:
sensitive:
header: 'Aviso de conteúdo'
info: >
Alguns conteúdos são permitidos pelos nossos {/terms=Termos de Serviço}, mas que ainda podem não ser
Alguns conteúdos são permitidos pelos nossos {/termos=Termos de Serviço}, mas que ainda podem não ser
apropriados para menores de idade, potencialmente engatilhando pessoas com traumas, etc. Por favor, aja com
respeito com quem visita seu cartão e avise previamente sobre tal conteúdo. Exemplos de Aviso de Conteúdo
podem ser a "menção ao álcool", "insinuações sexuais", "menção á uma situação queerfóbica"...
@ -774,7 +774,7 @@ confirm:
terms:
header: 'Termos de Serviço'
lastUpdate: 'Atualizados pela última vez em'
consent: 'Ao se registrar, você aceita os {/terinos=Termos de Serviço}.'
consent: 'Ao se registrar, você aceita os {/termos=Termos de Serviço}.'
privacy:
header: 'Política de Privacidade' # TODO
@ -842,15 +842,6 @@ ban:
header: 'Seu perfil não mais aparecerá em nosso site.'
banned: 'Seu perfil não mais aparecerá em nosso site.'
termsIntro: 'De acordo com nossos {/termos=termos de uso}'
# TODO
appeal: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our {/terms=Terms of Service},
please contact us at {mailto:contact@pronouns.page=contact@pronouns.page} and we might get another look in a bigger group.
appealEmail: >
Moderation is a complex and delicate subject. It's being done by volunteers who might not always agree with each other
or be aware of some issues. If you think your account didn't breach our Terms of Service,
please respond to this email and we might get another look in a bigger group.
report:
action: 'Reportar abuso'

View File

@ -570,7 +570,7 @@ profile:
eller alla formerna (t.ex. “hen/henom/hens”).
Kom ihåg att <strong>alla tre formerna</strong> är nödvändiga i sådana fall,
annars kommer appen gissa vilka pronomen det är du menar.
Du kan även använda {/pronouns#generator=<strong>generatorn</strong>} för att fylla ut meningar med anpassade former.
Du kan även använda {/pronomen#generator=<strong>generatorn</strong>} för att fylla ut meningar med anpassade former.
pronounsNotFound: 'Vi kan inte hitta någonting om dessa pronomen!'
words: 'Ord'
wordsColumnHeader: 'Kolumnrubrik'
@ -727,7 +727,7 @@ crud:
search: 'Sök…'
author: 'Tillagd av'
saved: 'Ändringarna har sparats!'
loginRequired: '{/account=Logga in} För att skicka in ett nytt inlägg'
loginRequired: '{/konto=Logga in} För att skicka in ett nytt inlägg'
copy: 'Kopiera länk'
download: 'Ladda ner'
loadAll: 'Ladda alla...'

View File

@ -624,7 +624,7 @@ profile:
pronounsInfo: >
Bạn có thể nhập một <strong>danh xưng</strong> (ví dụ “anh ấy” hoặc “cô ấy”)
hoặc một <strong>đường link</strong> (ví dụ “https://vi.pronouns.page/:Vanh”).
Bạn cũng có thể dùng {/pronouns#generator=<strong>trình tạo danh xưng</strong>} để điền vào câu với các danh xưng tùy ý.
Bạn cũng có thể dùng {/danh-xưng#generator=<strong>trình tạo danh xưng</strong>} để điền vào câu với các danh xưng tùy ý.
Nếu danh xưng của bạn là {/tránh=<strong>tên</strong>},
bạn cũng có thể sử dụng dấu hai chấm (ví dụ “:Vanh”).
pronounsNotFound: 'Định dạng không được chấp nhận. Vui lòng xem hướng dẫn ở trên.'

View File

@ -4,6 +4,7 @@ import { loadSuml } from './server/loader.js';
import autoprefixer from 'autoprefixer';
import fs from 'fs';
import path from 'path';
import rtlcss from 'rtlcss';
import { buildDict, buildList } from './src/helpers.js';
import buildLocaleList from './src/buildLocaleList.js';
import formatError from './src/error.js';
@ -18,6 +19,9 @@ const description = translations.description;
const keywords = (translations?.seo?.keywords || []).join(', ');
const banner = `${process.env.BASE_URL}/api/banner/zaimki.png`;
const colour = '#C71585';
const __dirname = new URL('.', import.meta.url).pathname;
const logo = fs.readFileSync(`${__dirname}/static/logo/logo.svg`).toString('utf-8')
.replace('/></svg>', 'fill="currentColor"/></svg>');
const versionFile = `${__dirname}/cache/version`;
@ -88,7 +92,7 @@ const postCssPlugins = [
];
if (config.dir === 'rtl') {
postCssPlugins.push(require('rtlcss'));
postCssPlugins.push(rtlcss);
}
const getAllFiles = function (dirPath, arrayOfFiles) {

View File

@ -1,7 +1,9 @@
import { expect, test } from '@jest/globals';
import { afterEach, beforeEach, describe, expect, jest, test } from '@jest/globals';
import pathToRegexp from 'path-to-regexp';
import { loadSumlFromBase } from '../../server/loader.js';
import locales from '../../locale/locales.js';
import { deepGet, deepListKeys } from '../../src/helpers.js';
const baseTranslations = loadSumlFromBase('locale/_base/translations');
const typeFlexibleKeys = new Set(['home.generator.alt']);
@ -52,9 +54,75 @@ function recursivelyValidateSchema(actual, base, parentKey = '') {
return messages;
}
test.each(locales)('translations of $code match schema of base translations', ({ code }) => {
function toBeValidPath(actual, paths, key) {
const encoded = encodeURI(actual);
const pass = paths.some((matcher) => encoded.match(matcher));
if (pass) {
return {
message: () => `expected ${this.utils.printReceived(actual)} inside ${this.utils.printReceived(key)} ` +
'to not be a known internal link',
pass: true,
};
} else {
return {
message: () => `expected ${this.utils.printReceived(actual)} inside ${this.utils.printReceived(key)} ` +
'to be a known internal link',
pass: false,
};
}
}
const pathRegex = /\{(\/[^}]+?)(?:#[^}]+)?=[^}]+\}/g;
describe.each(locales)('translations for $code', ({ code, published }) => {
const config = loadSumlFromBase(`locale/${code}/config`);
const translations = loadSumlFromBase(`locale/${code}/translations`);
expect(translations).toMatchBaseTranslationSchema();
beforeEach(() => {
jest.unstable_mockModule('../../server/loader.js', () => {
return {
loadSuml(name) {
if (name === 'config') {
return config;
} else if (name === 'translations') {
return translations;
}
},
};
});
});
afterEach(() => {
jest.resetModules();
});
test('match schema of base translations', () => {
expect(translations).toMatchBaseTranslationSchema();
});
test('contain valid internal links', async () => {
if (!published) {
// unpublished versions are ignored for now because they have a lot of errors
return;
}
// use query string to force reload
const { default: nuxtConfig } = await import(`../../nuxt.config.js?${code}`);
const routes = [];
nuxtConfig.router.extendRoutes(routes, () => null);
const paths = routes.filter((route) => route.name !== 'all').map((route) => pathToRegexp(route.path));
for (const key of deepListKeys(translations)) {
const translation = deepGet(translations, key);
if (typeof translation !== 'string') {
continue;
}
for (const match of translation.matchAll(pathRegex)) {
expect(match[1]).toBeValidPath(paths, key);
}
}
});
});
expect.extend({ toMatchBaseTranslationSchema: toMatchBaseTranslationsSchema });
expect.extend({ toMatchBaseTranslationSchema: toMatchBaseTranslationsSchema, toBeValidPath });