// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
// SPDX-License-Identifier: AGPL-3.0-or-later WITH AdditionRef-Progmasoft-Patent-Grant-1.1
export const supportedLocales = ["en-US", "de-DE", "ru-RU", "he-IL"] as const;
export type Locale = (typeof supportedLocales)[number];
/** The language of a visitor whose browser asks for none that is published. */
export const fallbackLocale: Locale = "en-US";
export function isLocale(value: string | undefined): value is Locale {
return supportedLocales.includes(value as Locale);
}
/** Each language named in that language, as a language menu shows it. */
export const localeNames: Record<Locale, string> = {
"en-US": "English",
"de-DE": "Deutsch",
"ru-RU": "Русский",
"he-IL": "עברית",
};
/**
* The direction in which the text of a language runs.
*
* Only text follows it. The page layout, the navigation and code samples keep
* their left-to-right arrangement in every language.
*/
export function textDirection(locale: Locale): "ltr" | "rtl" {
return locale === "he-IL" ? "rtl" : "ltr";
}
/** The arrow that points onward in the reading direction of a language. */
export function forwardArrow(locale: Locale): string {
return textDirection(locale) === "rtl" ? "←" : "→";
}
// Primary language subtags and the published locale each one selects. `iw` is
// the former code for Hebrew, which some browsers still send.
const localeByLanguage = new Map<string, Locale>([
["en", "en-US"],
["de", "de-DE"],
["ru", "ru-RU"],
["he", "he-IL"],
["iw", "he-IL"],
]);
/**
* Chooses the published locale a browser prefers.
*
* The argument is an `Accept-Language` header: a list of language ranges,
* each with an optional quality. The range with the highest quality whose
* primary language is published wins, and the order of the header breaks
* ties. A missing header, a header without a published language and a range
* the visitor refuses with quality zero all give the fallback locale. The
* header comes from the browser and is not trusted, so only its beginning is
* read.
*/
export function negotiateLocale(acceptLanguage: string | null): Locale {
if (!acceptLanguage) {
return fallbackLocale;
}
let selected: Locale = fallbackLocale;
let selectedQuality = 0;
for (const range of acceptLanguage.slice(0, 1024).split(",")) {
const [tag = "", ...parameters] = range.trim().split(";");
const language = tag.trim().split("-", 1)[0] ?? "";
const locale = localeByLanguage.get(language.toLowerCase());
if (!locale) {
continue;
}
let quality = 1;
for (const parameter of parameters) {
const [name, value] = parameter.trim().split("=");
if (name === "q") {
quality = /^(?:0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/.test(value ?? "")
? Number(value)
: 0;
}
}
if (quality > selectedQuality) {
selected = locale;
selectedQuality = quality;
}
}
return selected;
}
export const localeCookieName = "progmasoft_locale";
export interface LocaleCookieOptions {
domain: string | undefined;
httpOnly: true;
maxAge: number;
sameSite: "lax";
secure: boolean;
}
/**
* Attributes of the language-preference cookie.
*
* The preference is shared by every Progmasoft host, so on a production host
* the cookie belongs to the registrable domain. Any other host, such as a
* local development name, keeps a host-only cookie. The proxy redirect and
* the in-page language switch must write the same cookie, or one would leave
* a second cookie behind that shadows the other.
*/
export function localeCookieOptions(
host: string,
secure: boolean,
): LocaleCookieOptions {
const isProductionHost =
host === "progmasoft.com" || host.endsWith(".progmasoft.com");
return {
domain: isProductionHost ? ".progmasoft.com" : undefined,
httpOnly: true,
maxAge: 60 * 60 * 24 * 365,
sameSite: "lax",
secure,
};
}
/** The host a request was addressed to, without its port and in lower case. */
export function requestHost(
forwardedHost: string | null,
host: string | null,
): string {
return (forwardedHost ?? host)?.split(":", 1)[0]?.toLowerCase() ?? "";
}
export const messages = {
"en-US": {
metadata: {
homeTitle: "Progmasoft",
homeDescription:
"Progmasoft builds programming-language, package-management, and developer-tooling systems.",
accountTitle: "Account",
accountDescription: "Access and manage your Progmasoft account.",
loginTitle: "Sign in",
registerTitle: "Create account",
recoveryTitle: "Recover your account",
recoveryDescription: "Get help regaining access to a Progmasoft account.",
dashboardTitle: "Dashboard",
vigetTitle: "ViGet Package Registry by Progmasoft",
vigetDescription:
"The Tala package registry is online, but no packages have been published yet.",
dslPluginsTitle: "DSL Plugins · ViGet Package Registry by Progmasoft",
dslPluginsDescription:
"The ViGet Kotlin DSL plugin catalog is online, but no plugins have been published yet.",
},
navigation: {
primary: "Primary navigation",
organization: "Organization",
products: "Products",
principles: "Principles",
account: "Account",
dashboard: "Dashboard",
signIn: "Sign in",
createAccount: "Create account",
theme: "Theme",
light: "Light",
dark: "Dark",
language: "Language",
},
footer: {
summary:
"Programming-language infrastructure and developer systems built with durable contracts.",
products: "Products",
openSource: "Open source",
organization: "Organization",
support: "Support",
websiteSource: "Website source",
closing: "Designed for clarity, security, and long-term maintenance.",
},
home: {
heroEyebrow: "Developer systems by Progmasoft",
heroTitleStart: "Tools should make hard work",
heroTitleAccent: "understandable.",
heroDescription:
"We build programming-language infrastructure, package systems, and developer tools around explicit contracts instead of accidental complexity.",
exploreProducts: "Explore products",
browseSource: "Browse source",
facts: [
["Open", "Public engineering"],
["Typed", "Contracts before shortcuts"],
["Native", "Performance without mystery"],
],
visualLabel: "Progmasoft product principles",
stack: [
[
"Products",
"Focused experiences",
"Clear purpose · durable names · public identity",
],
[
"Platform",
"Shared account foundation",
"Authentication · service access · recovery",
],
[
"Operations",
"First-party infrastructure",
"Observable · maintainable · directly operated",
],
],
productsEyebrow: "Products and projects",
productsTitle: "One ecosystem, clear boundaries.",
productsDescription:
"Each surface has one responsibility and a documented contract with the next layer.",
products: [
[
"Programming language",
"Tala",
"A modern programming language developed by Progmasoft, with its own dedicated product and documentation site.",
"Explore Tala",
],
[
"Package registry",
"ViGet",
"The canonical package and DSL-plugin registry for the Tala ecosystem, operated directly by Progmasoft.",
"Open ViGet",
],
[
"Developer tooling",
"Open engineering",
"Compiler, formatter, linter, analyzer, project-system, and editor work developed in public repositories.",
"View on GitHub",
],
],
principlesEyebrow: "Engineering principles",
principlesTitle: "Built to remain legible.",
principlesDescription:
"Architecture is useful only when a new contributor can understand where a decision belongs and how to verify it.",
principles: [
[
"Explicit contracts",
"Typed boundaries make ownership, compatibility, and failure behavior visible.",
],
[
"Real verification",
"Tests exercise installed artifacts, production-shaped paths, and observable beha
|