diff --git a/.prettierrc b/.prettierrc index de753c5..e515e10 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,4 @@ { - "printWidth": 100 + "printWidth": 100, + "quoteProps": "consistent" } diff --git a/src/content/config.ts b/src/content/config.ts index 4fae6f4..759bf1d 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -2,6 +2,9 @@ import { z, defineCollection } from "astro:content"; const intro = defineCollection({ type: "content", + schema: z.object({ + title: z.string(), + }), }); const confirmEmail = defineCollection({ diff --git a/src/content/intro/en.md b/src/content/intro/en.md index c892821..6d2379d 100644 --- a/src/content/intro/en.md +++ b/src/content/intro/en.md @@ -1,3 +1,7 @@ +--- +title: Tell your local branch of Vienna Insurance Group to stop supporting fossil fuel +--- + **Vienna Insurance Group is the biggest insurer in Central and Eastern Europe and still considers supporting the fossil fuel industry**. With its zero restriction on giving insurance to oil and gas companies and light restriction on coal, VIG continues to fund fossil fuels and therefore accelerating climate change. So far. Right now, we hold the power to pressure VIG and insurers all around the world to adopt stricter policies and make a major move in helping the burning planet! Together, we have the power to call out Vienna Insurance Group with its 50 branches in 20 CEE countries, and demand change. And now is the good time! Because this week is the Week of Action against insuring fossil fuels, by the Insure our Future network – tens of actions are happening worldwide. Join us to make voices from the CEE heard, and send an email to your local branch of Vienna Insurance Group in just a few clicks! diff --git a/src/i18n.ts b/src/i18n.ts index c76db16..479f412 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -1,65 +1,112 @@ +import type { RenderTemplateResult } from "astro/runtime/server/render/astro/render-template.js"; import { DEFAULT_LANG } from "./config"; import type { Lang } from "./lang"; -import noopTag, { type TagFn } from "./lib/noop-tag"; -type AnyString = string & {}; +export default function a( + strings: TemplateStringsArray, + ...expressions: RenderTemplateResult[] +): Array { + let result: Array = [strings[0]]; -// Reference -const en = { - website_name: "Let's stop dirty money", - website_description: undefined, - switch_country: "Switch country", + for (let i = 1, l = strings.length; i < l; i++) { + result.push(expressions[i - 1]); + result.push(strings[i]); + } + + return result; +} + +const reference = { + "website_name": "Let’s stop dirty money", + "website_description": + "Send an email to your local branch of the Vienna Insurance Group, the biggest insurer in Central and Eastern Europe, to push them to adopt serious fossil fuel policies.", + + "switch_country": "Switch country", "form.first_name": "First name", "form.last_name": "Last name", - "form.variant": "I'm most concerned that", - "form.variant.1": "EPH destroys global climate", - "form.variant.2": "EPH fuels energy crisis", - "form.variant.3": "EPH undermines democracy", - "form.gender": undefined, - "form.gender.f": undefined, - "form.gender.m": undefined, - "form.branch": "I'm client of", - "form.letter": "Letter body", + + "form.variant": "I'm most concerned about", + "form.variant.1": "lack of oil and gas policy", + "form.variant.2": "weak coal policy", + "form.variant.3": "Neptune Deep", + + "form.gender": "I wish to be referred to in", + "form.gender.f": "Feminine gender", + "form.gender.m": "Masculine gender", + "form.gender.n": "Neither/I'd rather not say", + + "form.branch": "I want to contact the responsible person of", + "form.is_client": "I’m a client of this branch", + + "form.message": "Message text", + "form.fill_the_options": "Fill the options", + "form.send_letter": "Send the letter", + + "form.few_more_details": "A few more details...", "form.email": "E-mail", - "form.phone": "Phone number", - "form.send": "Send", - "confirm_email.title": "Confirm your e-mail", - "confirm_email.body": "Click the link below to verify your e-mail address.", - "confirm_email.link": "Confirm", + "form.phone": "Phone (optional)", + "form.privacy_policy": "privacy policy", + "form.agree_with_privacy_policy": (privacyPolicy: any) => a`I agree with ${privacyPolicy}.`, + "form.subscribe": "I want to stay updated about this campaign.", + + "form_response.verification_required": "We need to verify your e-mail.", + "form_response.verification_follow_link": "Follow the link we have sent to your email address.", + + "form_response.already_sent.title": "You have already sent a message from this e-mail.", + "form_response.already_sent.body": "You can send only one message per branch.", } as const; -type TranslationKey = keyof typeof en; -type Translation = Partial>; +type TranslationKey = keyof typeof reference; +type Translation = Partial) => string>>; -const cs: Translation = { - website_name: "Zastavme špinavé prachy", - switch_country: "Změnit zemi", - "form.first_name": "Jméno", - "form.last_name": "Příjmení", - "form.variant": "Nejvíc mi vadí, že", - "form.variant.1": "EPH ničí klima", - "form.variant.2": "EPH způsobuje energetickou krizi", - "form.variant.3": "EPH ohrožuje demokracii", - "form.gender": "Preferuju být oslován/a v", - "form.gender.f": "ženském rodě", - "form.gender.m": "mužském rodě", - "form.branch": "Jsem klient/ka pobočky", - "form.letter": "Text dopisu", - "form.email": "E-mail", - "form.phone": "Telefonní číslo", - "form.send": "Odeslat", - "confirm_email.title": "Potvrď svůj e-mail", - "confirm_email.body": "Kliknutím na následující odkaz potvrdíš svou e-mailovou adresu.", - "confirm_email.link": "Potvrdit e-mail", +const translations: Record = { + en: reference, + cs: { + "website_name": "Zastavme špinavé prachy", + "switch_country": "Změnit zemi", + "form.first_name": "Jméno", + "form.last_name": "Příjmení", + "form.variant": "Nejvíc mi vadí, že", + "form.variant.1": "EPH ničí klima", + "form.variant.2": "EPH způsobuje energetickou krizi", + "form.variant.3": "EPH ohrožuje demokracii", + "form.gender": "Preferuju být oslován/a v", + "form.gender.f": "ženském rodě", + "form.gender.m": "mužském rodě", + "form.branch": "Jsem klient/ka pobočky", + "form.letter": "Text dopisu", + "form.email": "E-mail", + "form.phone": "Telefonní číslo", + "form.send": "Odeslat", + "confirm_email.title": "Potvrď svůj e-mail", + "confirm_email.body": "Kliknutím na následující odkaz potvrdíš svou e-mailovou adresu.", + "confirm_email.link": "Potvrdit e-mail", + }, + sk: {}, + pl: {}, + hu: {}, + ro: {}, + lt: {}, + de: {}, }; -const de: Translation = {}; - -const translations: Record = { en, cs, de }; - -export type TTag = TagFn; - export function makeT(lang: Lang = DEFAULT_LANG) { - // TODO - return noopTag; + return { + t(key: TranslationKey): string { + const translationDict = translations[lang]; + const value = translationDict[key] ?? reference[key]; + if (typeof value === "string") { + return value; + } + return key; + }, + jt(key: TranslationKey, params: any) { + const translationDict = translations[lang]; + const value = translationDict[key] ?? reference[key]; + if (typeof value === "function") { + return value(params); + } + return key; + }, + }; } diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 743abf2..ab8ff2a 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -9,12 +9,10 @@ interface Props { } const { lang = DEFAULT_LANG } = Astro.props; -const t = makeT(lang); +const { t } = makeT(lang); -// translator: website title – this will display in browser tab and also in search engine results. -const title = t`Let’s stop dirty money`; -// translator: website description – it will display in search engine results -const description = t`Send an email to your local branch of the Vienna Insurance Group, the biggest insurer in Central and Eastern Europe, to push them to adopt serious fossil fuel policies.`; +const title = t("website_name"); +const description = t("website_description"); --- diff --git a/src/letter/LetterBodyForm.astro b/src/letter/LetterBodyForm.astro index 2e4aa84..8f9b493 100644 --- a/src/letter/LetterBodyForm.astro +++ b/src/letter/LetterBodyForm.astro @@ -14,7 +14,7 @@ interface Props { } const { lang, options = {} } = Astro.props; -const t = makeT(lang); +const { t, jt } = makeT(lang); const result = letterOptionsSchema.safeParse(options); --- @@ -26,7 +26,7 @@ const result = letterOptionsSchema.safeParse(options); >