Update reference translations

This commit is contained in:
Ondřej 2024-02-20 16:57:23 +01:00
parent bdd6d50264
commit 5b3230a90d
4 changed files with 86 additions and 74 deletions

View file

@ -9,17 +9,16 @@ export async function handler(
) {
const lang = ctx.params.lang;
if (lang && isLang(lang) && lang !== "en") {
let file;
try {
file = await Deno.readTextFile(
const file = await Deno.readTextFile(
join(Deno.cwd(), `languages/${lang}.po.json`),
);
const translations = JSON.parse(file);
addLocale(lang, translations);
useLocale(lang);
} catch (e) {
throw new Error(`There are no translations for language '${lang}'`);
console.error(`Couldn't load translations for locale '${lang}'`);
}
const translations = JSON.parse(file);
addLocale(lang, translations);
useLocale(lang);
}
return await ctx.next();

View file

@ -42,11 +42,19 @@ export function LetterOptions({ lang }: { lang: Lang }) {
<Radio
name="variant"
value="1"
label={c("form").t`TODO variant 1`}
label={c("form.variant").t`oil and gas policy`}
checked
/>
<Radio name="variant" value="2" label={c("form").t`TODO variant 2`} />
<Radio name="variant" value="3" label={c("form").t`TODO variant 3`} />
<Radio
name="variant"
value="2"
label={c("form.variant").t`coal policy`}
/>
<Radio
name="variant"
value="3"
label={c("form.variant").t`neptun deep`}
/>
</RadioGroup>
{lang !== "en" && (
// translator: this make sense only in gendered languages like Czech;
@ -115,7 +123,7 @@ export function LetterBody(
class="block w-full px-4 py-3 bg-white text-black text-lg"
style="white-space: pre-wrap"
>
{renderText(lang, options)}
{renderText(options)}
</textarea>
{!result.success && (
<div class="absolute inset-0 grid place-content-center bg-white/75 text-black">

View file

@ -1,68 +1,73 @@
import { Lang } from "$src/lang.ts";
import { LetterOptions } from "$src/letter/schema.ts";
import { c } from "ttag";
interface TemplateParams {
gender: string;
variant: string;
name: string;
}
type TemplateFn = (options: TemplateParams) => string;
const templates: Partial<Record<Lang, TemplateFn>> = {
en: () => "",
cs: (options) =>
`Vážený pane, Vážená paní,
${
options.gender === "f"
? "Zjistila"
: "Zjistil"
} jsem, že Vaše banka je významným partnerem oligarchy Daniela Křetínského, který ${
options.variant === "1"
? `ohrožuje moji i vaší budoucnost. Jeho firma EPH je totiž jednou z největších fosilních firem v celé Evropě. Jenom v uhlí má EPH větší emise než celé Finsko. Navíc má největší plány na rozvoj plynové infrastruktury ze všech evropských energetických firem.
Jak jistě víte, spalování plynu a uhlí způsobuje klimatickou krizi, která ohrožuje budoucnost nás všech. Byznys Daniela Křetínského je jednou z příčin, proč po celé Zemi stále častěji zažíváme vlny veder či sucha, ale i záplav, lesních požárů či hurikánů. Vědci říkají jasně, že katastrofě zabráníme jen tím, že se uhlí i plynu zbavíme co nejdříve.
Vím, že Vaše banka se snaží k otázce klimatu přistupovat zodpovědně. Není mi proto jasné, jak můžete finančně podporovat firmu jako je EPH.`
: ""
}${
options.variant === "2"
? `je jednou z hlavních příčin současné energetické krize. Křetínského firma EPH je největším dovozcem plynu z Ruska a zároveň má velké plány na rozšiřování plynové infrastruktury. Právě drahý plyn přitom může za vysoké ceny elektřiny a tepla, kvůli kterým už téměř milion lidí přežívá v energetické chudobě.
Naproti tomu firma EPH se nedávno stala největší českou firmou a svůj zisk loni zvýšila o šedesát procent. Peníze vytáhnuté z kapes lidí za ceny energií pak Křetínský používá k nákupu zámků ve Francii nebo paláců v Praze. EPH se navíc na řešení energetické krize nechce podílet, jelikož ukrývá své firmy v daňových skrýších a zároveň nechce platit daň z neočekávaných zisků.
Není mi jasné, jak můžete finančně podporovat firmu jako je EPH, která se podílá na ničení klimatu i sociálního smíru.`
: ""
}${
options.variant === "3"
? `je největším evropským dovozcem ruského plynu. Právě na dovozu plynu z Ruska firma EPH vydělávala v minulosti miliardy, přičemž nás tento byznys dlouhé roky držel v závislosti na režimu Vladimíra Putina. Kam nás tato závislost dovedla nyní sledujeme v přímém přenosu.
Daniel Křetínský zároveň pokřivuje veřejnou debatu podobným způsobem jako Andrej Babiš, protože je jedním z největších tuzemských vlastníků médií. Jeho noviny často útočí na snahy o ochranu klimatu a vystupují v zájmu svého majitele.
Vím, že Vaše banka se snaží k otázce bezpečnosti i demokracie přistupovat zodpovědně. I proto jste udělali dobrou věc, když jste odešli z Ruska. Není mi proto jasné, jak můžete finančně podporovat firmu jako je EPH.`
: ""
}
Jako ${
options.gender === "f" ? "klientka" : "klient"
} Vás proto žádám, abyste neprodleně přestali spolupracovat s firmou EPH Daniela Křetínského. V opačném případě budu muset do budoucna zvážit své setrvání u Vaší banky. Budu ${
options.gender === "f" ? "ráda" : "rád"
}, když mi dáte vědět svůj názor a co nejdříve mi odpovíte.
S pozdravem,
${options.name}`,
de: () => "",
type Variant = (branch: string) => {
exposure: string;
demands: string;
};
export function renderText(
lang: Lang,
{ firstName, lastName, variant = "1", gender = "f" }: Partial<LetterOptions>,
): string {
const nameParts = [firstName, lastName].filter(Boolean);
const name = nameParts.length > 0 ? nameParts.join(" ") : "Jana Novák";
const templateFn = templates[lang];
if (!templateFn) {
throw new Error(`WIP: Language ${lang} is not implemented`);
}
return templateFn({ name, variant, gender });
const variants: Record<string, Variant> = {
1: (branch: string) => ({
exposure: c("letter")
.t`I recently learned that the Vienna Insurance Group, which ${branch} belongs to, does not have any policies against insuring oil and gas businesses. I believe you are well aware that continuing with oil and gas accelerates climate change, and keeps our economy dependent on dirty fuels that wont be useful for long. It is unclear to me why ${branch} still considers working with oil and gas companies, when this industry threatens our health, homes, businesses - everything you, as an insurer, try to keep safe.`,
demands: c("letter")
.t`Therefore, I ask you, ${branch}, to publicly commit to stop insuring oil and gas projects or companies, and to persuade your group to do so.`,
}),
2: (branch: string) => ({
exposure: c("letter")
.t`I am contacting you to raise my concerns about the coal policy of the Vienna Insurance Group, to which ${branch} belongs. As of today, your policy (thresholds 30%/20Mt/10GWh in countries with a coal exit strategy, no threshold in the others) still allows you to give insurance to coal companies. I am sure you perfectly know that burning coal emits greenhouse gases that contribute to the unprecedented current climate crisis, so I dont understand why you still support this industry that threatens our health, homes, businesses - everything you, as an insurer, try to keep safe.`,
demands: c("letter")
.t`I am consequently urging you ${branch} and your group to improve your coal insurance policy (thresholds 20%/10Mt /5GWh for all countries).`,
}),
3: (branch: string) => ({
exposure: c("letter")
.t`I am writing to you because I am deeply concerned about the Neptun Deep project, a gas extraction plan in the Romanian Black Sea scheduled to start drilling this year. This project would have devastating consequences for the climate, biodiversity, landscape, and local communities. ${branch}, as an insurer and as part of the Vienna Insurance Group, has important power in helping to stop this project: by refusing to insure it and by publicly speaking out against it.`,
demands: c("letter")
.t`This is why I would like you, ${branch}, to make a public statement declaring that you do not insure the Neptun Deep project, and to urge your group to do the same.`,
}),
};
function getName(
{ firstName, lastName }: { firstName?: string; lastName?: string },
) {
return [firstName, lastName].filter(Boolean).join(" ");
}
export function renderText(
{
firstName,
lastName,
variant = "1",
branch = "",
isClient = false,
}: Partial<
LetterOptions
>,
) {
const { exposure, demands } = variants[variant]?.(branch);
const name = getName({ firstName, lastName });
const responsability = c("letter")
.t`According to the values you defend as a company, it seems that you should be taking environmental and social concerns seriously. As the top insurer in Central and Eastern Europe, your group has the responsibility to set a positive example and truly “protect what matters” as you promise to do.`;
const client = c("letter")
.t`As a client of your company, Ill have to reconsider staying with you if you do not take on more responsibility.`;
const closing = c("letter")
.t`I would appreciate it if you could respond as soon as possible.
Sincerely,
${name}
`;
const letter = [
exposure,
responsability,
demands,
isClient ? client : undefined,
closing,
].filter(Boolean).join(
"\n\n",
);
return letter;
}

View file

@ -5,7 +5,7 @@ export const letterOptionsSchema = z.object({
firstName: z.string().min(1),
lastName: z.string().min(1),
variant: z.string().min(1),
gender: z.string().min(1),
gender: z.string().min(1).optional(),
branch: z.string().min(1),
isClient: checkbox(),
});