{"release_id":"01a1998d-9802-0000-b0f7-33a23307f4ed","chunk_id":"01a1998d-9916-79d2-86ba-255132b108be","file":"Cs9_53iZ.mjs","mappings":"gaAWO,SAASA,EAAOC,EAAkBC,EAAyB,CACjE,OAAKA,EACED,EAAS,QAAQ,aAAc,CAACE,EAAOC,IAC7CA,KAAQF,EAAS,OAAOA,EAAOE,CAAI,CAAC,EAAID,CAAA,EAFrBF,CAIrB,CAEO,SAASI,EAAUC,EAAgCC,EAAgBL,EAAyB,CAGlG,MAAMM,EAAMF,GAAY,OAAO,OAAOA,EAAUC,CAAM,EAAID,EAASC,CAAM,EAAI,OAC7E,OAAOP,EAAO,OAAOQ,GAAQ,UAAYA,IAAQ,GAAKA,EAAMD,EAAQL,CAAM,CAC3E,CCdO,SAASO,GAAiB,CAChC,MAAMC,EAAIC,EAAK,MAAM,OACrB,OAAOC,EAASF,CAAC,EAAIA,EAAIG,CAC1B,CAGO,SAASC,EAAEP,EAAgBL,EAAyB,CAC1D,OAAOG,EAAUM,EAAK,MAAM,KAA8BJ,EAAQL,CAAM,CACzE,CAIO,SAASa,EAAeR,EAAyB,CACvD,GAAIE,EAAA,IAAaI,EAAgB,MAAO,GACxC,MAAMG,EAAIL,EAAK,MAAM,KACrB,MAAO,CAAC,CAACK,GAAK,OAAO,OAAOA,EAAGT,CAAM,GAAK,OAAOS,EAAET,CAAM,GAAM,UAAYS,EAAET,CAAM,IAAM,EAC1F,CAGO,SAASU,EAAMC,EAAsB,CAC3C,OAAOC,EAAaD,EAAMT,GAAQ,CACnC","names":["format","template","params","whole","name","translate","messages","source","hit","locale","l","page","isLocale","DEFAULT_LOCALE","t","hasTranslation","m","lhref","href","localizeHref"],"sources":["../../../../../../src/lib/i18n/translate.ts","../../../../../../src/lib/i18n/index.ts"],"sourcesContent":["/**\n * Messages are keyed by their English text (gettext style): `t('Play now')`\n * renders \"Play now\" in English with no lookup, and the other languages map the\n * same English string to theirs. A string missing from a language falls back\n * to English rather than to a key name.\n */\nexport type Messages = Record<string, string>;\n\nexport type Params = Record<string, string | number>;\n\n/** Fills `{name}` placeholders. Unknown names stay as written. */\nexport function format(template: string, params?: Params): string {\n\tif (!params) return template;\n\treturn template.replace(/\\{(\\w+)\\}/g, (whole, name: string) =>\n\t\tname in params ? String(params[name]) : whole\n\t);\n}\n\nexport function translate(messages: Messages | undefined, source: string, params?: Params): string {\n\t// own string keys only: a stray array or an inherited name ('length',\n\t// 'constructor') must never stand in for the text\n\tconst hit = messages && Object.hasOwn(messages, source) ? messages[source] : undefined;\n\treturn format(typeof hit === 'string' && hit !== '' ? hit : source, params);\n}\n\n/** The English text with its placeholders filled: what a translator gives\n *  when there is no other language to give. */\nexport const english = (source: string, params?: Params): string => format(source, params);\n","import { page } from '$app/state';\nimport { DEFAULT_LOCALE, isLocale, type Locale } from './locales';\nimport { localizeHref } from './localized-paths';\nimport { translate, type Messages, type Params } from './translate';\n\nexport * from './locales';\nexport { isLocalizedPath, localizeHref, LOCALIZED_PATHS } from './localized-paths';\n\n/** The page's language. Read during render or in a handler, like `page`. */\nexport function locale(): Locale {\n\tconst l = page.data?.locale;\n\treturn isLocale(l) ? l : DEFAULT_LOCALE;\n}\n\n/** `t('Play now')` → the page's language; English text is the key. */\nexport function t(source: string, params?: Params): string {\n\treturn translate(page.data?.i18n as Messages | undefined, source, params);\n}\n\n/** Whether `source` reads in the page's language — always, in English. Content\n *  that may lack a translation (a deck card) checks before it shows. */\nexport function hasTranslation(source: string): boolean {\n\tif (locale() === DEFAULT_LOCALE) return true;\n\tconst m = page.data?.i18n as Messages | undefined;\n\treturn !!m && Object.hasOwn(m, source) && typeof m[source] === 'string' && m[source] !== '';\n}\n\n/** A link in the page's language (prefixed only where a translated copy exists). */\nexport function lhref(href: string): string {\n\treturn localizeHref(href, locale());\n}\n"],"version":3}