@fluenti/vue 0.1.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.
@@ -0,0 +1,69 @@
1
+ import { FluentInstanceExtended, Locale, Messages, DateFormatOptions, NumberFormatOptions } from '@fluenti/core';
2
+ export { detectLocale, getSSRLocaleScript, getHydratedLocale, isRTL, getDirection } from '@fluenti/core';
3
+ export type { DetectLocaleOptions } from '@fluenti/core';
4
+ /**
5
+ * Configuration for `createServerI18n`.
6
+ */
7
+ export interface ServerI18nConfig {
8
+ /** Load messages for a given locale. Called once per locale per request. */
9
+ loadMessages: (locale: string) => Promise<Messages | {
10
+ default: Messages;
11
+ }>;
12
+ /** Fallback locale when a translation is missing */
13
+ fallbackLocale?: string;
14
+ /**
15
+ * Auto-resolve locale when `setLocale()` was not called.
16
+ *
17
+ * Common patterns for Vue/Nuxt SSR:
18
+ * - Read from a cookie via `useCookie()` or `useRequestEvent()`
19
+ * - Read from a request header set by middleware
20
+ *
21
+ * If omitted and `setLocale()` was not called, `getI18n()` will throw.
22
+ */
23
+ resolveLocale?: () => string | Promise<string>;
24
+ /** Custom fallback chains per locale */
25
+ fallbackChain?: Record<string, Locale[]>;
26
+ /** Custom date format styles */
27
+ dateFormats?: DateFormatOptions;
28
+ /** Custom number format styles */
29
+ numberFormats?: NumberFormatOptions;
30
+ /** Handler for missing translation keys */
31
+ missing?: (locale: Locale, id: string) => string | undefined;
32
+ }
33
+ /**
34
+ * The object returned by `createServerI18n`.
35
+ */
36
+ export interface ServerI18n {
37
+ /**
38
+ * Set the locale for the current server request.
39
+ * Call this once in your server plugin or middleware before any `getI18n()` calls.
40
+ */
41
+ setLocale: (locale: string) => void;
42
+ /**
43
+ * Get a fully configured i18n instance for the current request.
44
+ * Messages are loaded lazily and cached.
45
+ */
46
+ getI18n: () => Promise<FluentInstanceExtended & {
47
+ locale: string;
48
+ }>;
49
+ }
50
+ /**
51
+ * Create server-side i18n utilities for Vue SSR / Nuxt.
52
+ *
53
+ * Uses a simple module-level store for locale state and message caching.
54
+ * For per-request isolation in Nuxt, use `useRequestEvent()` in your
55
+ * `resolveLocale` callback, or call `setLocale()` in a server plugin.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * // server/i18n.ts
60
+ * import { createServerI18n } from '@fluenti/vue/server'
61
+ *
62
+ * export const { setLocale, getI18n } = createServerI18n({
63
+ * loadMessages: (locale) => import(`../locales/compiled/${locale}.ts`),
64
+ * fallbackLocale: 'en',
65
+ * })
66
+ * ```
67
+ */
68
+ export declare function createServerI18n(config: ServerI18nConfig): ServerI18n;
69
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EAEtB,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACxG,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAExD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,GAAG;QAAE,OAAO,EAAE,QAAQ,CAAA;KAAE,CAAC,CAAA;IAC3E,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9C,wCAAwC;IACxC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACxC,gCAAgC;IAChC,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,kCAAkC;IAClC,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,2CAA2C;IAC3C,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;CAC7D;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAEnC;;;OAGG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,sBAAsB,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACpE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAmErE"}
@@ -0,0 +1,11 @@
1
+ import { FluentVueContext } from './plugin';
2
+ /**
3
+ * Composable that returns the Fluenti i18n context.
4
+ *
5
+ * Must be called inside a component whose ancestor app has installed the
6
+ * `createFluentVue()` plugin.
7
+ *
8
+ * @throws If the plugin has not been installed
9
+ */
10
+ export declare function useI18n(): FluentVueContext;
11
+ //# sourceMappingURL=use-i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-i18n.d.ts","sourceRoot":"","sources":["../src/use-i18n.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE7D;;;;;;;GAOG;AACH,wBAAgB,OAAO,IAAI,gBAAgB,CAM1C"}
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@fluenti/vue",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Vue 3 compile-time i18n — v-t directive, Trans/Plural/Select components, useI18n composable",
6
+ "homepage": "https://fluenti.dev",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/usefluenti/fluenti.git",
10
+ "directory": "packages/vue"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/usefluenti/fluenti/issues"
14
+ },
15
+ "license": "MIT",
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "keywords": [
20
+ "i18n",
21
+ "internationalization",
22
+ "compile-time",
23
+ "icu",
24
+ "messageformat",
25
+ "vue",
26
+ "vue3",
27
+ "directive",
28
+ "composable"
29
+ ],
30
+ "main": "./dist/index.cjs",
31
+ "module": "./dist/index.js",
32
+ "types": "./dist/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "import": {
36
+ "types": "./dist/index.d.ts",
37
+ "default": "./dist/index.js"
38
+ },
39
+ "require": {
40
+ "types": "./dist/index.d.ts",
41
+ "default": "./dist/index.cjs"
42
+ }
43
+ }
44
+ },
45
+ "files": [
46
+ "dist"
47
+ ],
48
+ "peerDependencies": {
49
+ "vue": "^3.5"
50
+ },
51
+ "dependencies": {
52
+ "@fluenti/core": "0.1.0"
53
+ },
54
+ "devDependencies": {
55
+ "typescript": "^5.9",
56
+ "vite": "^8",
57
+ "vite-plugin-dts": "^4",
58
+ "vitest": "^4",
59
+ "@vitest/coverage-v8": "^4",
60
+ "vue": "^3.5",
61
+ "@vue/test-utils": "^2",
62
+ "happy-dom": "^20"
63
+ },
64
+ "scripts": {
65
+ "build": "vite build",
66
+ "dev": "vite build --watch",
67
+ "test": "vitest run",
68
+ "typecheck": "tsc --noEmit"
69
+ }
70
+ }