@manyducks.co/dolla 2.0.0-alpha.11 → 2.0.0-alpha.12

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.
@@ -1,5 +1,5 @@
1
- import { q as s } from "./passthrough-Bu7iYKPr.js";
2
- import { P as m } from "./passthrough-Bu7iYKPr.js";
1
+ import { r as s } from "./passthrough-Bz5ZF4jn.js";
2
+ import { P as m } from "./passthrough-Bz5ZF4jn.js";
3
3
  function d(n, r, t, e, a, l) {
4
4
  const i = { ...o(["children", "key"], r) }, c = Array.isArray(r.children) ? r.children : [r.children];
5
5
  return s(n, i, ...c);
@@ -1,5 +1,5 @@
1
- import { q as t } from "./passthrough-Bu7iYKPr.js";
2
- import { P as l } from "./passthrough-Bu7iYKPr.js";
1
+ import { r as t } from "./passthrough-Bz5ZF4jn.js";
2
+ import { P as l } from "./passthrough-Bz5ZF4jn.js";
3
3
  function d(n, e, r) {
4
4
  return t(n, e ? { ...u(["children", "key"], e) } : void 0, e.children);
5
5
  }
@@ -1,4 +1,4 @@
1
- import { MaybeState, type State } from "../state.js";
1
+ import { type MaybeState, type State } from "../state.js";
2
2
  import type { Dolla } from "./dolla.js";
3
3
  /**
4
4
  * An object where values are either a translated string or another nested Translation object.
@@ -36,6 +36,7 @@ export type TOptions = {
36
36
  context?: MaybeState<string>;
37
37
  [value: string]: MaybeState<any>;
38
38
  };
39
+ export type Formatter = (locale: string, value: unknown, options: Record<string, any>) => string;
39
40
  /**
40
41
  * Dolla's I(nternationalizatio)n module. Manages language translations and locale-based formatting.
41
42
  */
@@ -49,13 +50,28 @@ export declare class I18n {
49
50
  /**
50
51
  * Returns a State containing the value at `key`.
51
52
 
52
- * @param key - Key to the translated value.
53
- * @param options - A map of {{placeholder}} names and the values to replace them with.
53
+ * @param selector - Key to the translated value.
54
+ * @param options - A map of `{{placeholder}}` names and the values to replace them with.
54
55
  *
55
56
  * @example
56
- * const $value = t("your.key.here");
57
+ * const $value = t("your.key.here", { count: 5 });
57
58
  */
58
- t(key: string, options?: TOptions): State<string>;
59
+ t(selector: string, options?: TOptions): State<string>;
60
+ /**
61
+ * Add a custom format callback.
62
+ *
63
+ * @example
64
+ * Dolla.i18n.addFormat("myCurrency", (locale, value, options) => {
65
+ * // ...
66
+ * });
67
+ *
68
+ * {
69
+ * "exampleKey": "{{count | myCurrency}} dollars"
70
+ * }
71
+ *
72
+ * t("exampleKey", {count: 5}); // State<"&5 dollars">
73
+ */
74
+ addFormat(name: string, callback: (locale: string, value: unknown, options: Record<string, any>) => string): void;
59
75
  /**
60
76
  * Creates an `Intl.Collator` configured for the current locale.
61
77
  * NOTE: The Collator remains bound to the locale it was created with, even when the app's locale changes.
@@ -1244,35 +1244,36 @@ function ze(t, e) {
1244
1244
  return e.outlet();
1245
1245
  }
1246
1246
  export {
1247
- _e as A,
1248
- We as B,
1249
- Ke as C,
1247
+ S as A,
1248
+ _e as B,
1249
+ We as C,
1250
+ Ke as D,
1250
1251
  ze as P,
1251
1252
  I as a,
1252
1253
  A as b,
1253
1254
  Re as c,
1254
1255
  ge as d,
1255
1256
  O as e,
1256
- V as f,
1257
- Pe as g,
1257
+ _ as f,
1258
+ V as g,
1258
1259
  Be as h,
1259
1260
  L as i,
1260
- Fe as j,
1261
- Le as k,
1262
- qe as l,
1263
- Ge as m,
1264
- He as n,
1265
- ne as o,
1266
- je as p,
1267
- x as q,
1268
- Ue as r,
1269
- pe as s,
1261
+ Pe as j,
1262
+ Fe as k,
1263
+ Le as l,
1264
+ qe as m,
1265
+ Ge as n,
1266
+ He as o,
1267
+ ne as p,
1268
+ je as q,
1269
+ x as r,
1270
+ Ue as s,
1270
1271
  q as t,
1271
- Ie as u,
1272
+ pe as u,
1272
1273
  T as v,
1273
1274
  G as w,
1274
- K as x,
1275
- M as y,
1276
- S as z
1275
+ Ie as x,
1276
+ K as y,
1277
+ M as z
1277
1278
  };
1278
- //# sourceMappingURL=passthrough-Bu7iYKPr.js.map
1279
+ //# sourceMappingURL=passthrough-Bz5ZF4jn.js.map