feat(mental-health): name the Dutch and Belgian crisis lines

A Dutch reader whose screener answer raised the safety path saw only
the international set, because no Dutch set existed.

The Netherlands gets 113 Zelfmoordpreventie (113, the free 0800-0113
and the chat on 113.nl), Belgium the Zelfmoordlijn (1813,
zelfmoord1813.be), both behind 112. The app's one Dutch bundle is read
in both countries and the account keeps no country, so a bare "nl"
lands on a combined set that names each line with its country, the way
the German and Portuguese sets already do; an explicit nl-NL, nl-BE or
region "be" gets its own country's set.
This commit is contained in:
Marc-André Bombeck committed 2026-10-29 09:22:00 +01:00
1 parent 6f60812132
commit 919d64947c
11 files changed
+150 -5

No files matched your search

@@ -53,13 +53,54 @@ describe("crisisResourcesForLocale", () => {
}
});
it("gives a Dutch reader with no region 112, then the Dutch and Belgian lines by name", () => {
for (const locale of ["nl", "nl-SR"]) {
const set = crisisResourcesForLocale(locale);
expect(set.emergencyNumber, locale).toBe("112");
expect(set.resources).toEqual([
{
id: "zelfmoordpreventie113",
contacts: ["113", "0800-0113", "113.nl"],
},
{ id: "zelfmoordlijn1813", contacts: ["1813", "zelfmoord1813.be"] },
{ id: "findahelpline", contacts: ["findahelpline.com"] },
]);
}
const { t } = getServerTranslator("nl");
expect(
t("mentalHealth.crisisResource.zelfmoordpreventie113.name"),
).toContain("Nederland");
expect(t("mentalHealth.crisisResource.zelfmoordlijn1813.name")).toContain(
"België",
);
});
it("gives an explicit Dutch region 113 and an explicit Belgian one 1813", () => {
for (const locale of ["nl-NL", "nl_NL"]) {
const ids = crisisResourcesForLocale(locale).resources.map((r) => r.id);
expect(ids, locale).toEqual(["zelfmoordpreventie113", "findahelpline"]);
}
for (const locale of ["nl-BE", "nl_BE", "be"]) {
const ids = crisisResourcesForLocale(locale).resources.map((r) => r.id);
expect(ids, locale).toEqual(["zelfmoordlijn1813", "findahelpline"]);
}
});
it("names every crisis resource in every language", () => {
// History re-derives the set from the row's stored locale and renders it
// in whatever language the reader uses now.
const ids = new Set(
["pt-BR", "pt-PT", "br", "de", "de-AT", "de-CH", "en-US", "fr"].flatMap(
(l) => crisisResourcesForLocale(l).resources.map((r) => r.id),
),
[
"pt-BR",
"pt-PT",
"br",
"de",
"de-AT",
"de-CH",
"en-US",
"fr",
"nl",
].flatMap((l) => crisisResourcesForLocale(l).resources.map((r) => r.id)),
);
for (const locale of locales) {
const { t } = getServerTranslator(locale);
+52 -2
View File
@@ -149,6 +149,51 @@ const PT_BR_AMBIGUOUS: CrisisResourceSet = {
],
};
/**
* The Netherlands (explicit "nl-NL" / "nl_NL"). 112 is the emergency number.
* 113 Zelfmoordpreventie answers by phone on 113 or the free 0800-0113 and by
* chat on 113.nl, anonymously.
*/
const NL: CrisisResourceSet = {
emergencyNumber: "112",
resources: [
{
id: "zelfmoordpreventie113",
contacts: ["113", "0800-0113", "113.nl"],
},
{ id: "findahelpline", contacts: ["findahelpline.com"] },
],
};
/**
* Belgium (explicit "nl-BE" / "nl_BE", or the bare region "be"). 112 is the
* emergency number. The Zelfmoordlijn answers 1813 around the clock and runs
* a chat in the evenings (zelfmoord1813.be).
*/
const BE: CrisisResourceSet = {
emergencyNumber: "112",
resources: [
{ id: "zelfmoordlijn1813", contacts: ["1813", "zelfmoord1813.be"] },
{ id: "findahelpline", contacts: ["findahelpline.com"] },
],
};
/**
* Dutch with no region signal. The app ships one Dutch bundle, `nl`, read in
* the Netherlands and in Flanders alike, and the account keeps no country to
* tell them apart. Following DE_AT_CH, the set leads with 112 (the emergency
* number in both countries) and names each country's line with the country
* in its label, so nothing reads as if it reached everyone.
*/
const NL_BE: CrisisResourceSet = {
emergencyNumber: "112",
resources: [
...NL.resources.filter((r) => r.id !== "findahelpline"),
...BE.resources.filter((r) => r.id !== "findahelpline"),
{ id: "findahelpline", contacts: ["findahelpline.com"] },
],
};
/**
* Resolve a crisis-resource set from the user's locale. Region detection is
* coarse (locale prefix) and defaults to the international set — the goal is to
@@ -156,8 +201,9 @@ const PT_BR_AMBIGUOUS: CrisisResourceSet = {
*
* A region-qualified tag ("de-AT", "de_CH", "pt-PT", …) resolves to the exact
* country set when the caller has one to give us. The web stores the app
* locale, which is a bare "de" or the folded "pt-BR", so it lands on the
* combined sets: never assume Germany or Brazil when the region is unknown.
* locale, which is a bare "de", "nl" or the folded "pt-BR", so it lands on the
* combined sets: never assume Germany, the Netherlands or Brazil when the
* region is unknown.
*/
export function crisisResourcesForLocale(
locale: string | null | undefined,
@@ -173,5 +219,9 @@ export function crisisResourcesForLocale(
// PT_BR_AMBIGUOUS. Any other Portuguese tag (pt, pt-AO, pt-MZ) lands here
// too, and still gets 112 and the worldwide directory first.
if (lc === "pt" || lc.startsWith("pt-")) return PT_BR_AMBIGUOUS;
if (lc === "nl-nl") return NL;
if (lc === "nl-be" || lc === "be") return BE;
// The bare "nl" the web stores, and any other Dutch tag: both countries.
if (lc === "nl" || lc.startsWith("nl-")) return NL_BE;
return INTERNATIONAL;
}