@intlayer/core 9.0.0-canary.11 → 9.0.0-canary.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/cjs/dictionaryManipulator/index.cjs +3 -3
  2. package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs +8 -6
  3. package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs.map +1 -1
  4. package/dist/cjs/dictionaryManipulator/qualifiedDictionary.cjs +81 -40
  5. package/dist/cjs/dictionaryManipulator/qualifiedDictionary.cjs.map +1 -1
  6. package/dist/cjs/index.cjs +10 -3
  7. package/dist/cjs/localization/domainUtils.cjs +82 -0
  8. package/dist/cjs/localization/domainUtils.cjs.map +1 -0
  9. package/dist/cjs/localization/getLocalizedUrl.cjs +4 -11
  10. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  11. package/dist/cjs/localization/getPrefix.cjs +5 -9
  12. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  13. package/dist/cjs/localization/index.cjs +5 -0
  14. package/dist/cjs/messageFormat/index.cjs +2 -0
  15. package/dist/cjs/messageFormat/navigatePath.cjs +38 -0
  16. package/dist/cjs/messageFormat/navigatePath.cjs.map +1 -0
  17. package/dist/esm/dictionaryManipulator/index.mjs +2 -2
  18. package/dist/esm/dictionaryManipulator/mergeQualifiedDictionaries.mjs +9 -7
  19. package/dist/esm/dictionaryManipulator/mergeQualifiedDictionaries.mjs.map +1 -1
  20. package/dist/esm/dictionaryManipulator/qualifiedDictionary.mjs +79 -38
  21. package/dist/esm/dictionaryManipulator/qualifiedDictionary.mjs.map +1 -1
  22. package/dist/esm/index.mjs +4 -2
  23. package/dist/esm/localization/domainUtils.mjs +77 -0
  24. package/dist/esm/localization/domainUtils.mjs.map +1 -0
  25. package/dist/esm/localization/getLocalizedUrl.mjs +4 -11
  26. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  27. package/dist/esm/localization/getPrefix.mjs +5 -9
  28. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  29. package/dist/esm/localization/index.mjs +2 -1
  30. package/dist/esm/messageFormat/index.mjs +2 -1
  31. package/dist/esm/messageFormat/navigatePath.mjs +36 -0
  32. package/dist/esm/messageFormat/navigatePath.mjs.map +1 -0
  33. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +1 -1
  34. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +1 -1
  35. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +1 -1
  36. package/dist/types/dictionaryManipulator/index.d.ts +2 -2
  37. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts +33 -22
  38. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts.map +1 -1
  39. package/dist/types/index.d.ts +4 -2
  40. package/dist/types/localization/domainUtils.d.ts +70 -0
  41. package/dist/types/localization/domainUtils.d.ts.map +1 -0
  42. package/dist/types/localization/getLocalizedUrl.d.ts.map +1 -1
  43. package/dist/types/localization/getPrefix.d.ts.map +1 -1
  44. package/dist/types/localization/index.d.ts +2 -1
  45. package/dist/types/messageFormat/index.d.ts +2 -1
  46. package/dist/types/messageFormat/navigatePath.d.ts +22 -0
  47. package/dist/types/messageFormat/navigatePath.d.ts.map +1 -0
  48. package/package.json +6 -6
@@ -0,0 +1,70 @@
1
+ import { LocalesValues } from "@intlayer/types/module_augmentation";
2
+ import { Locale } from "@intlayer/types/allLocales";
3
+ import { RoutingConfig } from "@intlayer/types/config";
4
+
5
+ //#region src/localization/domainUtils.d.ts
6
+ /**
7
+ * The locale → domain map configured under `routing.domains`
8
+ * (e.g. `{ en: 'intlayer.org', zh: 'intlayer.cn' }`).
9
+ */
10
+ type LocaleDomainMap = RoutingConfig['domains'];
11
+ /**
12
+ * Strips the protocol from a domain string and returns only the hostname.
13
+ *
14
+ * Example:
15
+ *
16
+ * ```ts
17
+ * getDomainHostname('https://intlayer.cn') // 'intlayer.cn'
18
+ * getDomainHostname('intlayer.cn') // 'intlayer.cn'
19
+ * ```
20
+ *
21
+ * @param domain - A domain value from `routing.domains`, with or without protocol.
22
+ * @returns The bare hostname.
23
+ */
24
+ declare const getDomainHostname: (domain: string) => string;
25
+ /**
26
+ * Returns the absolute origin for a domain value, prepending `https://`
27
+ * when no protocol is present.
28
+ *
29
+ * Example:
30
+ *
31
+ * ```ts
32
+ * getDomainOrigin('intlayer.cn') // 'https://intlayer.cn'
33
+ * getDomainOrigin('http://intlayer.cn') // 'http://intlayer.cn'
34
+ * ```
35
+ *
36
+ * @param domain - A domain value from `routing.domains`, with or without protocol.
37
+ * @returns The origin usable as a URL base.
38
+ */
39
+ declare const getDomainOrigin: (domain: string) => string;
40
+ /**
41
+ * Returns the locale exclusively mapped to a given hostname via `routing.domains`,
42
+ * or `undefined` when zero or more than one locale share that hostname.
43
+ *
44
+ * Example: with `domains = { zh: 'intlayer.cn', en: 'intlayer.org', fr: 'intlayer.org' }`
45
+ *
46
+ * ```ts
47
+ * getLocaleFromDomain('intlayer.cn', domains) // 'zh'
48
+ * getLocaleFromDomain('intlayer.org', domains) // undefined (en and fr share it)
49
+ * getLocaleFromDomain('example.com', domains) // undefined (not mapped)
50
+ * ```
51
+ *
52
+ * @param hostname - The bare hostname of the incoming request.
53
+ * @param domains - The configured locale → domain map.
54
+ * @returns The exclusively mapped locale, or `undefined`.
55
+ */
56
+ declare const getLocaleFromDomain: (hostname: string, domains: LocaleDomainMap) => Locale | undefined;
57
+ /**
58
+ * Checks whether a locale is the only locale mapped to its configured domain.
59
+ * When true, the domain alone identifies the locale and no URL prefix is needed.
60
+ * Hostnames are compared after protocol stripping, so
61
+ * `{ en: 'https://intlayer.org', fr: 'intlayer.org' }` counts as a shared domain.
62
+ *
63
+ * @param locale - The locale to check.
64
+ * @param domains - The configured locale → domain map.
65
+ * @returns `true` when the locale has a domain shared with no other locale.
66
+ */
67
+ declare const isLocaleExclusiveOnDomain: (locale: LocalesValues, domains: LocaleDomainMap) => boolean;
68
+ //#endregion
69
+ export { LocaleDomainMap, getDomainHostname, getDomainOrigin, getLocaleFromDomain, isLocaleExclusiveOnDomain };
70
+ //# sourceMappingURL=domainUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domainUtils.d.ts","names":[],"sources":["../../../src/localization/domainUtils.ts"],"mappings":";;;;;;;AAQA;;KAAY,eAAA,GAAkB,aAAA;;;AAe9B;;;;;AAsBA;;;;;AAmBA;cAzCa,iBAAA,GAAqB,MAAA;;;;;;;;;AAmElC;;;;;;cA7Ca,eAAA,GAAmB,MAAA;;;;;;;;;;;;;;;;;cAmBnB,mBAAA,GACX,QAAA,UACA,OAAA,EAAS,eAAA,KACR,MAAA;;;;;;;;;;;cAuBU,yBAAA,GACX,MAAA,EAAQ,aAAA,EACR,OAAA,EAAS,eAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getLocalizedUrl.d.ts","names":[],"sources":["../../../src/localization/getLocalizedUrl.ts"],"mappings":";;;;;AAgFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,eAAA,2CAEK,aAAA,GAAgB,qBAAA,EAEhC,GAAA,EAAK,CAAA,EACL,aAAA,GAAe,CAAA,EACf,OAAA,GAAS,cAAA,KACR,YAAA,CAAa,CAAA,EAAG,CAAA"}
1
+ {"version":3,"file":"getLocalizedUrl.d.ts","names":[],"sources":["../../../src/localization/getLocalizedUrl.ts"],"mappings":";;;;;AAwEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,eAAA,2CAEK,aAAA,GAAgB,qBAAA,EAEhC,GAAA,EAAK,CAAA,EACL,aAAA,GAAe,CAAA,EACf,OAAA,GAAS,cAAA,KACR,YAAA,CAAa,CAAA,EAAG,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPrefix.d.ts","names":[],"sources":["../../../src/localization/getPrefix.ts"],"mappings":";;;;;;;AAuBA;KAAY,cAAA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U,aAAA;EAAA;;;;;;;;;;;EAYV,aAAA;AAAA;;;;AAOF;cAAa,oBAAA,GACX,OAAA,GAAS,cAAA,KACR,IAAA,CAAK,cAAA;EACN,aAAA,EAAe,aAAA;EACf,IAAA,EAAM,aAAA;EACN,OAAA,EAAS,aAAA;AAAA;AAAA,KAUC,gBAAA;EACV,aAAA,GAAgB,aAAA;EAChB,IAAA,GAAO,aAAA;AAAA;AAAA,KAGG,eAAA;EAnBD;;;;EAwBT,MAAA;EAtBe;;;EA0Bf,YAAA,EAAc,MAAA;AAAA;;;AAdhB;;;;;;;KA0BY,uBAAA,WACA,aAAA,oCACY,mBAAA,kBACN,aAAA,GAAgB,qBAAA,IAC9B,CAAA,oCACkB,CAAA,IAChB,uBAAA,CAAwB,eAAA,EAAiB,IAAA,EAAM,OAAA,sBAC7B,IAAA,IAChB,eAAA,GACA,IAAA;EACI,MAAA,KAAW,CAAA;EAAM,YAAA,EAAc,CAAA;AAAA,IACjC,IAAA,+BACE,CAAA,SAAU,OAAA;EACN,MAAA;EAAY,YAAA;AAAA;EACZ,MAAA,KAAW,CAAA;EAAM,YAAA,EAAc,CAAA;AAAA;EACjC,MAAA;EAAY,YAAA;AAAA;EACpB,MAAA;EAAY,YAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmCL,SAAA,mBAA6B,aAAA,cACxC,MAAA,EAAQ,CAAA,EACR,OAAA,GAAS,cAAA,KACR,uBAAA,CAAwB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { comparePaths, normalizePath } from "./comparePaths.js";
2
+ import { LocaleDomainMap, getDomainHostname, getDomainOrigin, getLocaleFromDomain, isLocaleExclusiveOnDomain } from "./domainUtils.js";
2
3
  import { GenerateSitemapOptions, SitemapUrlEntry, generateSitemap, generateSitemapUrl } from "./generateSitemap.js";
3
4
  import { getBrowserLocale } from "./getBrowserLocale.js";
4
5
  import { getHTMLTextDir } from "./getHTMLTextDir.js";
@@ -15,4 +16,4 @@ import { localeFlatMap, localeMap, localeRecord } from "./localeMapper.js";
15
16
  import { localeResolver } from "./localeResolver.js";
16
17
  import { LocalizedPathResult, getCanonicalPath, getInternalPath, getLocalizedPath, getRewritePath, getRewriteRules } from "./rewriteUtils.js";
17
18
  import { validatePrefix } from "./validatePrefix.js";
18
- export { type GenerateSitemapOptions, type GetPrefixOptions, type GetPrefixResult, type LocalizedPathResult, type SitemapUrlEntry, comparePaths, generateSitemap, generateSitemapUrl, getBrowserLocale, getCanonicalPath, getHTMLTextDir, getInternalPath, getLocale, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, getRewritePath, getRewriteRules, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, normalizePath, validatePrefix };
19
+ export { type GenerateSitemapOptions, type GetPrefixOptions, type GetPrefixResult, type LocaleDomainMap, type LocalizedPathResult, type SitemapUrlEntry, comparePaths, generateSitemap, generateSitemapUrl, getBrowserLocale, getCanonicalPath, getDomainHostname, getDomainOrigin, getHTMLTextDir, getInternalPath, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, getRewritePath, getRewriteRules, isLocaleExclusiveOnDomain, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, normalizePath, validatePrefix };
@@ -1,6 +1,7 @@
1
1
  import { JsonValue, icuToIntlayerFormatter, intlayerToICUFormatter } from "./ICU.js";
2
2
  import { i18nextToIntlayerFormatter, intlayerToI18nextFormatter } from "./i18next.js";
3
+ import { navigatePath } from "./navigatePath.js";
3
4
  import { PortableObject, intlayerToPortableObjectFormatter, portableObjectToIntlayerFormatter } from "./po.js";
4
5
  import { MessageFormatDialect, MessageValues, TaggedMessageToken, interpolateMessage, parseTaggedMessage, resolveMessage, resolveMessageNode } from "./resolveMessage.js";
5
6
  import { intlayerToVueI18nFormatter, vueI18nToIntlayerFormatter } from "./vue-i18n.js";
6
- export { JsonValue, MessageFormatDialect, MessageValues, PortableObject, TaggedMessageToken, i18nextToIntlayerFormatter, icuToIntlayerFormatter, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, parseTaggedMessage, portableObjectToIntlayerFormatter, resolveMessage, resolveMessageNode, vueI18nToIntlayerFormatter };
7
+ export { JsonValue, MessageFormatDialect, MessageValues, PortableObject, TaggedMessageToken, i18nextToIntlayerFormatter, icuToIntlayerFormatter, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, navigatePath, parseTaggedMessage, portableObjectToIntlayerFormatter, resolveMessage, resolveMessageNode, vueI18nToIntlayerFormatter };
@@ -0,0 +1,22 @@
1
+ //#region src/messageFormat/navigatePath.d.ts
2
+ /**
3
+ * Reads a dotted `path` (e.g. `counter.label`) out of a nested content value.
4
+ *
5
+ * The full path is first tried as a *flat* property, supporting catalogs that
6
+ * use dotted keys as literal field names (i18next flat JSON files, lingui
7
+ * catalogs: `{ "section.title": "value" }`). When that misses, the path is
8
+ * split on `keySeparator` and walked segment by segment.
9
+ *
10
+ * Shared by every compat adapter's translation lookup — do not re-implement
11
+ * it locally.
12
+ *
13
+ * @param contentValue - The object (dictionary content) to read from.
14
+ * @param path - Separator-delimited path. An empty path returns `contentValue`.
15
+ * @param keySeparator - Segment separator; `false` disables nested traversal
16
+ * (flat lookup only), mirroring i18next's `keySeparator: false`.
17
+ * @returns The value found at `path`, or `undefined` when any segment is absent.
18
+ */
19
+ declare const navigatePath: (contentValue: unknown, path: string, keySeparator?: string | false) => unknown;
20
+ //#endregion
21
+ export { navigatePath };
22
+ //# sourceMappingURL=navigatePath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigatePath.d.ts","names":[],"sources":["../../../src/messageFormat/navigatePath.ts"],"mappings":";;AAiBA;;;;;;;;;;;;;;;;cAAa,YAAA,GACX,YAAA,WACA,IAAA,UACA,YAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/core",
3
- "version": "9.0.0-canary.11",
3
+ "version": "9.0.0-canary.13",
4
4
  "private": false,
5
5
  "description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
6
6
  "keywords": [
@@ -172,11 +172,11 @@
172
172
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
173
173
  },
174
174
  "dependencies": {
175
- "@intlayer/api": "9.0.0-canary.11",
176
- "@intlayer/config": "9.0.0-canary.11",
177
- "@intlayer/dictionaries-entry": "9.0.0-canary.11",
178
- "@intlayer/types": "9.0.0-canary.11",
179
- "@intlayer/unmerged-dictionaries-entry": "9.0.0-canary.11",
175
+ "@intlayer/api": "9.0.0-canary.13",
176
+ "@intlayer/config": "9.0.0-canary.13",
177
+ "@intlayer/dictionaries-entry": "9.0.0-canary.13",
178
+ "@intlayer/types": "9.0.0-canary.13",
179
+ "@intlayer/unmerged-dictionaries-entry": "9.0.0-canary.13",
180
180
  "defu": "6.1.7"
181
181
  },
182
182
  "devDependencies": {