Files
easy-png-tools2/web/src/lib/i18n/dict.ts
T

74 lines
2.6 KiB
TypeScript

import type { CategoryId } from "../categories";
export const LOCALES = ["ru", "en"] as const;
export type Locale = (typeof LOCALES)[number];
export const BASE_LOCALE: Locale = "en";
export const LOCALE_TAGS: Record<Locale, string> = {
ru: "ru-RU",
en: "en-US",
};
export function isLocale(value: unknown): value is Locale {
return (
typeof value === "string" && (LOCALES as readonly string[]).includes(value)
);
}
/** Тексты страницы (`pages.<slug>`): адрес, имя файла и иконка — по slug. */
export type PageStrings = {
title?: string;
description?: string;
};
/** Тексты инструмента (`tools.<id>`): подписи полей, verdict-ключи. */
export type ToolStrings = {
/** Подписи параметров по их id. */
params?: Record<string, string>;
/** Подписи опций select: paramId -> value -> label. */
options?: Record<string, Record<string, string>>;
/** Тексты-результаты текстовых инструментов (analyze): ключ -> строка. */
results?: Record<string, string>;
};
export type HeaderStrings = {
workspace: string;
catalog: string;
sectionsAria: string;
footerNote: string;
home: string;
uiKit: string;
};
export type Dict = {
header: HeaderStrings;
categories: Record<CategoryId | "all", string>;
home: Record<string, string>;
catalog: Record<string, string>;
toolPage: Record<string, string>;
chain: Record<string, string>;
sourceCard: Record<string, string>;
resultCard: Record<string, string>;
paramsCard: Record<string, string>;
textInput: Record<string, string>;
textResult: Record<string, string>;
download: Record<string, string>;
infoPanel: Record<string, string>;
dropZone: Record<string, string>;
search: Record<string, string>;
ui: Record<string, string>;
errors: Record<string, string>;
/** Заголовки и описания страниц; в базовой локали их нет — берётся EN из реестра. */
pages?: Record<string, PageStrings>;
tools: Record<string, ToolStrings>;
/** Действия панели результата/генерации (Generate, Open image…). */
actions?: Record<string, string>;
/** Поля ввода текста нового UI (placeholder, Try sample…). */
textSource?: Record<string, string>;
/** Подписи полей по ключу (решение C: label-ключ на поле). */
fields?: Record<string, string>;
/** Заголовки групп полей по ключу (решение A). */
groups?: Record<string, string>;
};