Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 431x 431x 1002x 1013x | // The Finnish original of a tax term's label (openspec: year-summary,
// "Finnish originals of tax terms"): in Swedish and English the form 7H page
// and the PDF show the words MyTax's Finnish pages use after the label.
import { getLocale, type Locale } from '#/paraglide/runtime.js'
/**
* A Finnish label as an original in brackets: lower case at the start, and a
* bracket inside it a comma, so that "Rahoitusvastikkeet (rahastoitu)" is
* shown as "(rahoitusvastikkeet, rahastoitu)" and never a bracket in a bracket.
*/
export function originalText(fi: string) {
const lowered = fi.charAt(0).toLocaleLowerCase('fi-FI') + fi.slice(1)
return lowered.replace(/\s*\(([^)]*)\)/g, ', $1')
}
/** A label with its original, which is null in Finnish. */
export interface WithOriginal {
text: string
original: string | null
}
/** `label` in the current language with the Finnish `fi()` as its original. */
export function withOriginal(
label: string,
fi: () => string,
locale: Locale = getLocale(),
): WithOriginal {
return { text: label, original: locale === 'fi' ? null : originalText(fi()) }
}
/** One string, "Label (original)", for text that has no markup, e.g. the PDF. */
export function labelWithOriginal(item: WithOriginal) {
return item.original === null ? item.text : `${item.text} (${item.original})`
}
|