@intlayer/lingui 8.12.5-canary.0

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 (60) hide show
  1. package/README.md +330 -0
  2. package/dist/cjs/I18nClass.cjs +127 -0
  3. package/dist/cjs/I18nClass.cjs.map +1 -0
  4. package/dist/cjs/I18nProvider.cjs +64 -0
  5. package/dist/cjs/I18nProvider.cjs.map +1 -0
  6. package/dist/cjs/LinguiContext.cjs +23 -0
  7. package/dist/cjs/LinguiContext.cjs.map +1 -0
  8. package/dist/cjs/Trans.cjs +71 -0
  9. package/dist/cjs/Trans.cjs.map +1 -0
  10. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  11. package/dist/cjs/eventEmitter.cjs +37 -0
  12. package/dist/cjs/eventEmitter.cjs.map +1 -0
  13. package/dist/cjs/formats.cjs +66 -0
  14. package/dist/cjs/formats.cjs.map +1 -0
  15. package/dist/cjs/index.cjs +19 -0
  16. package/dist/cjs/plugin/index.cjs +64 -0
  17. package/dist/cjs/plugin/index.cjs.map +1 -0
  18. package/dist/cjs/setupI18n.cjs +33 -0
  19. package/dist/cjs/setupI18n.cjs.map +1 -0
  20. package/dist/cjs/useLingui.cjs +40 -0
  21. package/dist/cjs/useLingui.cjs.map +1 -0
  22. package/dist/esm/I18nClass.mjs +126 -0
  23. package/dist/esm/I18nClass.mjs.map +1 -0
  24. package/dist/esm/I18nProvider.mjs +63 -0
  25. package/dist/esm/I18nProvider.mjs.map +1 -0
  26. package/dist/esm/LinguiContext.mjs +22 -0
  27. package/dist/esm/LinguiContext.mjs.map +1 -0
  28. package/dist/esm/Trans.mjs +70 -0
  29. package/dist/esm/Trans.mjs.map +1 -0
  30. package/dist/esm/eventEmitter.mjs +35 -0
  31. package/dist/esm/eventEmitter.mjs.map +1 -0
  32. package/dist/esm/formats.mjs +64 -0
  33. package/dist/esm/formats.mjs.map +1 -0
  34. package/dist/esm/index.mjs +11 -0
  35. package/dist/esm/plugin/index.mjs +60 -0
  36. package/dist/esm/plugin/index.mjs.map +1 -0
  37. package/dist/esm/setupI18n.mjs +31 -0
  38. package/dist/esm/setupI18n.mjs.map +1 -0
  39. package/dist/esm/useLingui.mjs +39 -0
  40. package/dist/esm/useLingui.mjs.map +1 -0
  41. package/dist/types/I18nClass.d.ts +92 -0
  42. package/dist/types/I18nClass.d.ts.map +1 -0
  43. package/dist/types/I18nProvider.d.ts +39 -0
  44. package/dist/types/I18nProvider.d.ts.map +1 -0
  45. package/dist/types/LinguiContext.d.ts +21 -0
  46. package/dist/types/LinguiContext.d.ts.map +1 -0
  47. package/dist/types/Trans.d.ts +38 -0
  48. package/dist/types/Trans.d.ts.map +1 -0
  49. package/dist/types/eventEmitter.d.ts +24 -0
  50. package/dist/types/eventEmitter.d.ts.map +1 -0
  51. package/dist/types/formats.d.ts +32 -0
  52. package/dist/types/formats.d.ts.map +1 -0
  53. package/dist/types/index.d.ts +10 -0
  54. package/dist/types/plugin/index.d.ts +25 -0
  55. package/dist/types/plugin/index.d.ts.map +1 -0
  56. package/dist/types/setupI18n.d.ts +37 -0
  57. package/dist/types/setupI18n.d.ts.map +1 -0
  58. package/dist/types/useLingui.d.ts +21 -0
  59. package/dist/types/useLingui.d.ts.map +1 -0
  60. package/package.json +115 -0
@@ -0,0 +1,32 @@
1
+ //#region src/formats.d.ts
2
+ /**
3
+ * Reimplementation of `@lingui/core`'s `formats` namespace.
4
+ *
5
+ * These static helpers are deliberately kept independent of any I18n instance
6
+ * so that they can be used without a Provider.
7
+ *
8
+ * @deprecated Use `Intl.*` APIs directly — these helpers will be removed in
9
+ * a future version of lingui.
10
+ */
11
+ type DateTimeFormatSize = 'short' | 'default' | 'long' | 'full';
12
+ type DateTimeFormatValue = Parameters<Intl.DateTimeFormat['format']>[0];
13
+ type NumberFormatValue = Parameters<Intl.NumberFormat['format']>[0];
14
+ type PluralOptions = {
15
+ [key: string]: string | undefined;
16
+ } & {
17
+ offset?: number;
18
+ other: string;
19
+ };
20
+ declare const formats: {
21
+ date: (locales: string | string[], value: string | DateTimeFormatValue, format?: Intl.DateTimeFormatOptions | DateTimeFormatSize) => string;
22
+ time: (locales: string | string[], value: string | DateTimeFormatValue, format?: Intl.DateTimeFormatOptions | DateTimeFormatSize) => string;
23
+ number: (locales: string | string[], value: NumberFormatValue, format?: Intl.NumberFormatOptions) => string;
24
+ plural: (locales: string | string[], ordinal: boolean, value: number, {
25
+ offset,
26
+ ...rules
27
+ }: PluralOptions) => string;
28
+ defaultLocale: string;
29
+ };
30
+ //#endregion
31
+ export { DateTimeFormatSize, DateTimeFormatValue, NumberFormatValue, PluralOptions, formats };
32
+ //# sourceMappingURL=formats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.d.ts","names":[],"sources":["../../src/formats.ts"],"mappings":";;AAUA;;;;AAA8B;AAC9B;;;KADY,kBAAA;AAAA,KACA,mBAAA,GAAsB,UAAU,CAAC,IAAA,CAAK,cAAA;AAAA,KACtC,iBAAA,GAAoB,UAAU,CAAC,IAAA,CAAK,YAAA;AAAA,KAEpC,aAAA;EAAA,CACT,GAAA;AAAA;EAED,MAAA;EACA,KAAA;AAAA;AAAA,cAwFW,OAAA;qCAlEe,KAAA,WACV,mBAAA,EAAmB,MAAA,GAC1B,IAAA,CAAK,qBAAA,GAAwB,kBAAA;qCAgBZ,KAAA,WACV,mBAAA,EAAmB,MAAA,GAC1B,IAAA,CAAK,qBAAA,GAAwB,kBAAA;uCAgBZ,KAAA,EACnB,iBAAA,EAAiB,MAAA,GACf,IAAA,CAAK,mBAAA;uCASY,OAAA,WACV,KAAA;IACH,MAAA;IAAA,GAAA;EAAA,GACa,aAAA"}
@@ -0,0 +1,10 @@
1
+ import { I18nClass } from "./I18nClass.js";
2
+ import { I18nProvider } from "./I18nProvider.js";
3
+ import { LinguiContext } from "./LinguiContext.js";
4
+ import { Trans } from "./Trans.js";
5
+ import { formats } from "./formats.js";
6
+ import { i18n, setupI18n } from "./setupI18n.js";
7
+ import { useLingui } from "./useLingui.js";
8
+ import { AllMessages, Locale, Locales, MessageDescriptor, MessageId, MessageOptions, Messages, Register } from "@lingui/core";
9
+ import { I18nContext, I18nProviderProps, TransProps, TransRenderCallbackOrComponent, TransRenderProps } from "@lingui/react";
10
+ export { type AllMessages, I18nClass as I18n, type I18nContext, I18nProvider, type I18nProviderProps, LinguiContext, type Locale, type Locales, type MessageDescriptor, type MessageId, type MessageOptions, type Messages, type Register, Trans, type TransProps, type TransRenderCallbackOrComponent, type TransRenderProps, formats, i18n, setupI18n, useLingui };
@@ -0,0 +1,25 @@
1
+ import { PluginOption } from "vite";
2
+ import { intlayer } from "vite-intlayer";
3
+
4
+ //#region src/plugin/index.d.ts
5
+ /**
6
+ * A Vite plugin for the lingui compat adapter.
7
+ *
8
+ * Wraps `vite-intlayer` and adds resolve aliases so that both
9
+ * `@lingui/core` **and** `@lingui/react` are redirected to
10
+ * `@intlayer/lingui` at bundle time.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * // vite.config.ts
15
+ * import { linguiVitePlugin } from '@intlayer/lingui/plugin';
16
+ *
17
+ * export default defineConfig({
18
+ * plugins: [linguiVitePlugin()],
19
+ * });
20
+ * ```
21
+ */
22
+ declare const linguiVitePlugin: (options?: Parameters<typeof intlayer>[0]) => PluginOption[];
23
+ //#endregion
24
+ export { linguiVitePlugin as default, linguiVitePlugin };
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugin/index.ts"],"mappings":";;;;;;AAsCA;;;;;;;;;;;;;AAEe;;cAFF,gBAAA,GACX,OAAA,GAAU,UAAA,QAAkB,QAAA,SAC3B,YAAA"}
@@ -0,0 +1,37 @@
1
+ import { AllMessages, I18n, Locale, Locales } from "@lingui/core";
2
+
3
+ //#region src/setupI18n.d.ts
4
+ /** Mirrors the unexported `I18nProps` type from `@lingui/core`. */
5
+ type I18nProps = {
6
+ locale?: Locale;
7
+ locales?: Locales;
8
+ messages?: AllMessages;
9
+ missing?: string | ((locale: string, id: string) => string);
10
+ };
11
+ /**
12
+ * Drop-in for `@lingui/core`'s `setupI18n`.
13
+ *
14
+ * Creates a new intlayer-backed `I18n` instance. The `messages` and
15
+ * `missing` properties from `params` are accepted for API compatibility
16
+ * but are ignored — messages are served by intlayer's compiled dictionaries.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { setupI18n } from '@lingui/core';
21
+ *
22
+ * const i18n = setupI18n({ locale: 'en' });
23
+ * i18n.activate('fr');
24
+ * ```
25
+ */
26
+ declare const setupI18n: (params?: I18nProps) => I18n;
27
+ /**
28
+ * Global `i18n` singleton — drop-in for `@lingui/core`'s `i18n`.
29
+ *
30
+ * Call `i18n.activate(locale)` to set the active locale before rendering.
31
+ * In React apps, prefer using `useLingui()` inside components so that
32
+ * locale updates are handled reactively via `I18nProvider`.
33
+ */
34
+ declare const i18n: I18n;
35
+ //#endregion
36
+ export { i18n, setupI18n };
37
+ //# sourceMappingURL=setupI18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupI18n.d.ts","names":[],"sources":["../../src/setupI18n.ts"],"mappings":";;;;KAIK,SAAA;EACH,MAAA,GAAS,MAAA;EACT,OAAA,GAAU,OAAA;EACV,QAAA,GAAW,WAAA;EACX,OAAA,cAAqB,MAAA,UAAgB,EAAA;AAAA;;;;;;;;;;;;;;AAAU;AAkBjD;cAAa,SAAA,GAAa,MAAA,GAAS,SAAA,KAAY,IACL;;;;;;;AAAA;cAS7B,IAAA,EAAM,IAAkC"}
@@ -0,0 +1,21 @@
1
+ import { I18nContext } from "@lingui/react";
2
+
3
+ //#region src/useLingui.d.ts
4
+ /**
5
+ * Drop-in for `@lingui/react`'s `useLingui`.
6
+ *
7
+ * Returns `{ i18n, _, defaultComponent }` from the nearest `I18nProvider`.
8
+ * When used outside a provider, derives a locale-aware `i18n` instance from
9
+ * `react-intlayer`'s `useLocale()` so that Server Components and test contexts
10
+ * work without an explicit provider.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const { _ } = useLingui();
15
+ * return <h1>{_({ id: 'home.title', message: 'Welcome' })}</h1>;
16
+ * ```
17
+ */
18
+ declare const useLingui: () => I18nContext;
19
+ //#endregion
20
+ export { useLingui };
21
+ //# sourceMappingURL=useLingui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLingui.d.ts","names":[],"sources":["../../src/useLingui.ts"],"mappings":";;;;;AAuBA;;;;AAiBC;;;;;;;;cAjBY,SAAA,QAAgB,WAiB5B"}
package/package.json ADDED
@@ -0,0 +1,115 @@
1
+ {
2
+ "name": "@intlayer/lingui",
3
+ "version": "8.12.5-canary.0",
4
+ "private": false,
5
+ "description": "lingui API adapter for intlayer — drop-in compatibility layer",
6
+ "keywords": [
7
+ "intlayer",
8
+ "i18next",
9
+ "i18n",
10
+ "adapter",
11
+ "compatibility"
12
+ ],
13
+ "homepage": "https://intlayer.org",
14
+ "bugs": {
15
+ "url": "https://github.com/aymericzip/intlayer/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/aymericzip/intlayer.git"
20
+ },
21
+ "license": "Apache-2.0",
22
+ "author": {
23
+ "name": "Aymeric PINEAU",
24
+ "url": "https://github.com/aymericzip"
25
+ },
26
+ "contributors": [
27
+ {
28
+ "name": "Aymeric Pineau",
29
+ "email": "ay.pineau@gmail.com",
30
+ "url": "https://github.com/aymericzip"
31
+ }
32
+ ],
33
+ "sideEffects": false,
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/types/index.d.ts",
37
+ "require": "./dist/cjs/index.cjs",
38
+ "import": "./dist/esm/index.mjs"
39
+ },
40
+ "./plugin": {
41
+ "types": "./dist/types/plugin/index.d.ts",
42
+ "require": "./dist/cjs/plugin/index.cjs",
43
+ "import": "./dist/esm/plugin/index.mjs"
44
+ },
45
+ "./package.json": "./package.json"
46
+ },
47
+ "main": "dist/cjs/index.cjs",
48
+ "module": "dist/esm/index.mjs",
49
+ "types": "dist/types/index.d.ts",
50
+ "typesVersions": {
51
+ "*": {
52
+ "plugin": [
53
+ "./dist/types/plugin/index.d.ts"
54
+ ]
55
+ }
56
+ },
57
+ "files": [
58
+ "./dist",
59
+ "./package.json"
60
+ ],
61
+ "scripts": {
62
+ "build": "bun --bun tsdown --config tsdown.config.ts",
63
+ "build:ci": "bun --bun tsdown --config tsdown.config.ts",
64
+ "clean": "bun --bun rimraf ./dist .turbo",
65
+ "dev": "bun --bun tsdown --config tsdown.config.ts --watch",
66
+ "format": "bun --bun biome format . --check",
67
+ "format:fix": "bun --bun biome format --write .",
68
+ "lint": "bun --bun biome lint .",
69
+ "lint:fix": "bun --bun biome lint --write .",
70
+ "prepublish": "cp -f ../../README.md ./README.md",
71
+ "publish": "bun publish || true",
72
+ "publish:canary": "bun publish --access public --tag canary || true",
73
+ "publish:latest": "bun publish --access public --tag latest || true",
74
+ "test": "bun --bun vitest run",
75
+ "test:watch": "bun --bun vitest",
76
+ "typecheck": "tsc --noEmit --project tsconfig.types.json"
77
+ },
78
+ "dependencies": {
79
+ "@intlayer/chokidar": "9.0.0-canary.1",
80
+ "@intlayer/config": "9.0.0-canary.1",
81
+ "@intlayer/core": "9.0.0-canary.1",
82
+ "@intlayer/dictionaries-entry": "9.0.0-canary.1",
83
+ "@intlayer/types": "9.0.0-canary.1",
84
+ "react-intlayer": "9.0.0-canary.1",
85
+ "vite-intlayer": "9.0.0-canary.1"
86
+ },
87
+ "devDependencies": {
88
+ "@lingui/core": "^6.3.0",
89
+ "@lingui/react": "^6.3.0",
90
+ "@types/node": "25.9.3",
91
+ "@types/react": "19.1.8",
92
+ "@utils/ts-config": "1.0.4",
93
+ "@utils/ts-config-types": "1.0.4",
94
+ "@utils/tsdown-config": "1.0.4",
95
+ "rimraf": "6.1.3",
96
+ "tsdown": "0.22.2",
97
+ "typescript": "6.0.3",
98
+ "vite": "8.0.16",
99
+ "vitest": "4.1.9"
100
+ },
101
+ "peerDependencies": {
102
+ "@lingui/core": ">=6.3.0",
103
+ "@lingui/react": ">=6.3.0",
104
+ "react": ">=16.0.0",
105
+ "vite": ">=4.0.0"
106
+ },
107
+ "peerDependenciesMeta": {
108
+ "vite": {
109
+ "optional": true
110
+ }
111
+ },
112
+ "engines": {
113
+ "node": ">=14.18"
114
+ }
115
+ }