import type { Locale, Plurality } from './locales/index.js'; export type TranslationKey = string & {}; export type TranslationValue = string & {}; /** * An entry in a translation dataset, * containing translations for multiple locales, * along with optional metadata such as tags and description. */ export interface TranslationEntry { translations: TranslationLocalizedEntries; tags?: string[]; description?: string; plurals?: TranslationPluralization; } export type TranslationLocalizedEntries = Partial>; /** * Pluralization entries for different quantities, * each containing localized translations. * @example * const plural: TranslationPluralization = { * en_US: { * [Plurality.ONE]: 'something' * } * } */ export type TranslationPluralization = Partial>>>; /** * A dataset of translation entries, * where each key is a unique identifier for a translation entry. */ export type TranslationDataset = Record; /** * Extensible options for parsing functions */ export interface ParsingOptions { /** * The locale to prioritize when parsing translations. */ referenceLocale: Locale; /** * An optional target locale for the parsing process. * This can be useful for formats that are specific to a single locale, * and/or that are missing locale information in their structure. */ targetLocale?: Locale; } /** * Options for serialization functions */ export interface SerializationOptions { /** * The reference locale for the serialization process. * This is necessary for formats that require a base language, * e.g., Android Strings, Apple Strings or TS. */ referenceLocale: Locale; /** * The list of locales to include in the serialization output. * This can be a list smaller than the locales contained in the dataset, so that * you can selectively include only a subset of the available locales. */ locales: Locale[]; } export interface SerializationFileFragment { filename: string; content: string; } export interface SerializationFile { content: string; } /** * Serialization output, keyed by file name */ export type SerializationResult = { [filename: string]: SerializationFile; }; export type MaybeArray = Array | T; export type MakeOptional = Omit & Partial>;