mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 06:40:50 +00:00
The matrix derives each row's label from the event name, so a new event type gets a row whether or not anybody wrote the strings for it. That is how SECURITY_ALERT has been rendering its own raw key since v1.23: the forward i18n coverage test only sees literal call sites, and this key is assembled from a runtime value. Move the derivation out of the page so a test can compute the keys the page computes, assert both resolve in all six bundles, and name the missing one. Write the sign-in row's strings, and the strings for the delegated-dose row and its push body.
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
/**
|
|
* The i18n key an event type is rendered under.
|
|
*
|
|
* The /notifications matrix builds its rows from the event list the server
|
|
* publishes, so the label for a new event type is never written at a call site
|
|
* — it is derived here. Extracted from the page so the derivation can be
|
|
* pinned by a test without rendering anything, and so the guard that asserts
|
|
* every event type actually HAS its two strings (label + description, six
|
|
* locales) computes the key exactly the way the page does rather than a way
|
|
* that agrees with it today.
|
|
*
|
|
* `MEDICATION_REMINDER` → `notifications.eventMedicationReminder`; the
|
|
* description key is that plus `Desc`.
|
|
*/
|
|
export function eventTranslationKey(eventType: string): string {
|
|
return (
|
|
"notifications.event" +
|
|
eventType
|
|
.toLowerCase()
|
|
.replace(/_([a-z])/g, (_, c: string) => c.toUpperCase())
|
|
.replace(/^./, (c) => c.toUpperCase())
|
|
);
|
|
}
|
|
|
|
/** The description key that sits under the label in the matrix row. */
|
|
export function eventDescriptionTranslationKey(eventType: string): string {
|
|
return `${eventTranslationKey(eventType)}Desc`;
|
|
}
|