gt-i18n 1.0.2 → 1.0.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # gt-i18n
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1861](https://github.com/generaltranslation/gt/pull/1861) [`6345dc5`](https://github.com/generaltranslation/gt/commit/6345dc5e3fe0a1e3ead9a3c30a0adaa4037d50a8) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Skip interpolation in compiler-injected string prefetch calls so dev hot reload no longer logs "String interpolation failed" for messages with placeholders
8
+
3
9
  ## 1.0.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_versionId = require("./versionId-CSjMQCR_.cjs");
2
+ const require_versionId = require("./versionId-Bm1R4Gnm.cjs");
3
3
  let generaltranslation_internal = require("generaltranslation/internal");
4
4
  let _generaltranslation_format = require("@generaltranslation/format");
5
5
  let generaltranslation = require("generaltranslation");
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { E as logger_default, a as getDefaultLocale, b as createInterpolationFailureMessage, c as getLocales, d as getWritableConditionStore, g as resolveStringContentWithFallback, h as resolveStringContent, i as hashMessage, l as getRegion, n as isEncodedTranslationOptions, o as getLocale, r as decodeOptions, s as getLocaleProperties, t as getVersionId, u as resolveCanonicalLocale, x as extractVariables, y as interpolateIcuMessage } from "./versionId-CfPcJY78.mjs";
1
+ import { D as logger_default, S as extractVariables, _ as resolveStringContentWithFallback, a as getDefaultLocale, b as interpolateIcuMessage, c as getLocales, d as getWritableConditionStore, g as resolveStringContent, i as hashMessage, l as getRegion, n as isEncodedTranslationOptions, o as getLocale, r as decodeOptions, s as getLocaleProperties, t as getVersionId, u as resolveCanonicalLocale, x as createInterpolationFailureMessage } from "./versionId-BMLrkyzj.mjs";
2
2
  import { VAR_IDENTIFIER, encode, libraryDefaultLocale } from "generaltranslation/internal";
3
3
  import { formatMessage } from "@generaltranslation/format";
4
4
  import { declareVar, decodeVars, derive } from "generaltranslation";
package/dist/internal.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_versionId = require("./versionId-CSjMQCR_.cjs");
2
+ const require_versionId = require("./versionId-Bm1R4Gnm.cjs");
3
3
  let generaltranslation_internal = require("generaltranslation/internal");
4
4
  let _generaltranslation_format = require("@generaltranslation/format");
5
5
  //#region src/translation-functions/internal/getGT.ts
@@ -382,15 +382,39 @@ async function tx(content, options = {}) {
382
382
  * Condition store agnostic tx function
383
383
  */
384
384
  async function txInternal({ locale, enableI18n, content, options }) {
385
- return require_versionId.resolveStringContentWithRuntimeFallback(enableI18n ? typeof options.$locale === "string" ? options.$locale : locale : require_versionId.getI18nConfig().getDefaultLocale(), content, {
385
+ return require_versionId.resolveStringContentWithRuntimeFallback(getTargetLocale({
386
+ locale,
387
+ enableI18n,
388
+ options
389
+ }), content, {
386
390
  $format: "STRING",
387
391
  ...options
388
392
  });
389
393
  }
394
+ /**
395
+ * Registers a message for runtime translation without interpolating the
396
+ * result. For compiler-injected prefetch calls: their return value is
397
+ * discarded and variable values only exist at the render-time call site, so
398
+ * interpolating here would fail for any message with placeholders.
399
+ */
400
+ async function txPrefetch(content, options = {}) {
401
+ const conditionStore = require_versionId.getWritableConditionStore();
402
+ await require_versionId.prefetchStringContentWithRuntimeFallback(getTargetLocale({
403
+ locale: conditionStore.getLocale(),
404
+ enableI18n: conditionStore.getEnableI18n(),
405
+ options
406
+ }), content, {
407
+ $format: "STRING",
408
+ ...options
409
+ });
410
+ }
411
+ function getTargetLocale({ locale, enableI18n, options }) {
412
+ return enableI18n ? typeof options.$locale === "string" ? options.$locale : locale : require_versionId.getI18nConfig().getDefaultLocale();
413
+ }
390
414
  //#endregion
391
415
  //#region src/translation-functions/internal/runtime-translate.ts
392
416
  const GtInternalRuntimeTranslateString = (content, options = {}) => {
393
- return tx(content, {
417
+ return txPrefetch(content, {
394
418
  $format: "ICU",
395
419
  ...options
396
420
  });