origam 2.36.0 → 2.37.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.
- package/CHANGELOG.md +9 -0
- package/dist/src/interfaces/Commons/locale.interface.d.ts +2 -2
- package/dist/src/interfaces/Commons/nuxt-module.interface.d.ts +16 -0
- package/dist/src/nuxt/module.cjs +4 -2
- package/dist/src/nuxt/module.js +4 -2
- package/dist/src/nuxt/plugin.client.cjs +3 -1
- package/dist/src/nuxt/plugin.client.js +2 -1
- package/dist/src/nuxt/plugin.server.cjs +3 -1
- package/dist/src/nuxt/plugin.server.js +2 -1
- package/dist/src/utils/Commons/nuxt-locale.util.cjs +11 -0
- package/dist/src/utils/Commons/nuxt-locale.util.d.ts +15 -0
- package/dist/src/utils/Commons/nuxt-locale.util.js +3 -0
- package/dist/src/utils/index.cjs +11 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,15 @@ This project follows [Semantic Versioning](https://semver.org).
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [2.37.0] - 2026-10-19
|
|
22
|
+
|
|
23
|
+
### Added — module Nuxt : options `locale` transmises à `createOrigam` (#1181)
|
|
24
|
+
|
|
25
|
+
- Le module accepte `origam: { locale: { locale, fallbackLocale, messages } }` (même forme que `createOrigam({ locale })`, type `ILocaleOptions`). Les options transitent par `runtimeConfig.public.origam.locale` et sont passées à l'identique par les plugins client et serveur : pas d'écart d'hydratation.
|
|
26
|
+
- Avant, les deux plugins appelaient `createOrigam({ themes, ssr: true })` sans locale : sous Nuxt, `useLocale().current` valait toujours `en`, et les libellés intégrés (noms accessibles des blocs de code, palette de commandes…) restaient en anglais sur un site ja/ko/zh.
|
|
27
|
+
- `messages` est fusionné avec les locales intégrées `en` et `fr` : un site peut fournir `ja` complet ou surcharger quelques clés `fr`. `fallbackLocale` et `messages` deviennent optionnels dans `ILocaleOptions`.
|
|
28
|
+
- Doc : section « Ajouter une langue (gabarit de traduction) » dans le guide i18n ; la liste des clés est `origam/assets/locales/en.json`.
|
|
29
|
+
|
|
21
30
|
## [2.36.0] - 2026-10-19
|
|
22
31
|
|
|
23
32
|
### Added — `OrigamCodeGroup` : groupe de code à onglets (npm / pnpm / yarn) en une seule surface (#1179)
|
|
@@ -13,8 +13,8 @@ export interface ILocaleInstance {
|
|
|
13
13
|
}
|
|
14
14
|
export interface ILocaleOptions {
|
|
15
15
|
locale?: string;
|
|
16
|
-
fallbackLocale
|
|
17
|
-
messages
|
|
16
|
+
fallbackLocale?: string;
|
|
17
|
+
messages?: Record<string, unknown>;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Formes STRUCTURELLES de vue-i18n, declarees localement.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ILocaleOptions } from './locale.interface';
|
|
1
2
|
import type { IOrigamTheme } from './theme.interface';
|
|
2
3
|
import type { TMode, TTheme } from '../../types/Commons/theme.type';
|
|
3
4
|
/**
|
|
@@ -26,6 +27,20 @@ export interface IOrigamNuxtModuleOptions {
|
|
|
26
27
|
* When omitted, `createOrigam` installs the DS built-in baseline (neutral identity).
|
|
27
28
|
*/
|
|
28
29
|
themes?: IOrigamTheme[];
|
|
30
|
+
/*********************************************************
|
|
31
|
+
* locale
|
|
32
|
+
*
|
|
33
|
+
* @description
|
|
34
|
+
* Locale of Origam's built-in strings (aria-labels, button labels, …), forwarded to `createOrigam({ locale })` by BOTH plugins (client and server) so the SSR markup and the hydration render agree.
|
|
35
|
+
* @description
|
|
36
|
+
* Must stay serialisable — it travels through `runtimeConfig`. `messages` is MERGED over the built-in `en` / `fr` catalogues: a site can supply a complete `ja`, or override a few `fr` keys. Origam does NOT follow `<html lang>`.
|
|
37
|
+
* @description
|
|
38
|
+
* The key list to translate is `origam/assets/locales/en.json`.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* origam: { locale: { locale: 'ja', fallbackLocale: 'en', messages: { ja } } }
|
|
42
|
+
********************************************************/
|
|
43
|
+
locale?: ILocaleOptions;
|
|
29
44
|
/**
|
|
30
45
|
* Theme (brand) applied when no cookie is set. Use `'auto'` to render no
|
|
31
46
|
* `data-theme` attribute (the default brand).
|
|
@@ -111,6 +126,7 @@ export interface IOrigamNuxtRuntimeConfig {
|
|
|
111
126
|
cookieName: string;
|
|
112
127
|
modeCookieName: string;
|
|
113
128
|
cookieMaxAge: number;
|
|
129
|
+
locale?: ILocaleOptions;
|
|
114
130
|
}
|
|
115
131
|
/*********************************************************
|
|
116
132
|
* IOrigamNuxtProvide
|
package/dist/src/nuxt/module.cjs
CHANGED
|
@@ -23,7 +23,8 @@ const DEFAULTS = {
|
|
|
23
23
|
cookieMaxAge: 60 * 60 * 24 * 365,
|
|
24
24
|
autoImport: true,
|
|
25
25
|
includeUtilities: true,
|
|
26
|
-
prefix: "Origam"
|
|
26
|
+
prefix: "Origam",
|
|
27
|
+
locale: {}
|
|
27
28
|
};
|
|
28
29
|
const SCALAR_DEFAULTS = {
|
|
29
30
|
defaultTheme: DEFAULTS.defaultTheme,
|
|
@@ -139,7 +140,8 @@ const origamNuxtModule = (0, _kit.defineNuxtModule)({
|
|
|
139
140
|
defaultMode,
|
|
140
141
|
cookieName,
|
|
141
142
|
modeCookieName,
|
|
142
|
-
cookieMaxAge
|
|
143
|
+
cookieMaxAge,
|
|
144
|
+
locale: options.locale
|
|
143
145
|
};
|
|
144
146
|
}
|
|
145
147
|
});
|
package/dist/src/nuxt/module.js
CHANGED
|
@@ -22,7 +22,8 @@ const DEFAULTS = {
|
|
|
22
22
|
cookieMaxAge: 60 * 60 * 24 * 365,
|
|
23
23
|
autoImport: true,
|
|
24
24
|
includeUtilities: true,
|
|
25
|
-
prefix: "Origam"
|
|
25
|
+
prefix: "Origam",
|
|
26
|
+
locale: {}
|
|
26
27
|
};
|
|
27
28
|
const SCALAR_DEFAULTS = {
|
|
28
29
|
defaultTheme: DEFAULTS.defaultTheme,
|
|
@@ -135,7 +136,8 @@ const origamNuxtModule = defineNuxtModule({
|
|
|
135
136
|
defaultMode,
|
|
136
137
|
cookieName,
|
|
137
138
|
modeCookieName,
|
|
138
|
-
cookieMaxAge
|
|
139
|
+
cookieMaxAge,
|
|
140
|
+
locale: options.locale
|
|
139
141
|
};
|
|
140
142
|
}
|
|
141
143
|
});
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
var _vue = require("vue");
|
|
8
8
|
var _theme = require("../composables/Commons/theme.composable.cjs");
|
|
9
9
|
var _origam = require("../origam.cjs");
|
|
10
|
+
var _nuxtLocale = require("../utils/Commons/nuxt-locale.util.cjs");
|
|
10
11
|
var _applyTheme = require("../utils/Commons/apply-theme.util.cjs");
|
|
11
12
|
var _app = require("#app");
|
|
12
13
|
module.exports = (0, _app.defineNuxtPlugin)({
|
|
@@ -31,7 +32,8 @@ module.exports = (0, _app.defineNuxtPlugin)({
|
|
|
31
32
|
const themes = config.themes ?? [];
|
|
32
33
|
const origam = (0, _origam.createOrigam)({
|
|
33
34
|
themes,
|
|
34
|
-
ssr: true
|
|
35
|
+
ssr: true,
|
|
36
|
+
...(0, _nuxtLocale.nuxtLocaleOptions)(config)
|
|
35
37
|
});
|
|
36
38
|
nuxtApp.vueApp.use(origam);
|
|
37
39
|
const themeApi = (0, _theme.useTheme)();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ref, watch } from "vue";
|
|
2
2
|
import { useTheme } from "../composables/Commons/theme.composable.js";
|
|
3
3
|
import { createOrigam } from "../origam.js";
|
|
4
|
+
import { nuxtLocaleOptions } from "../utils/Commons/nuxt-locale.util.js";
|
|
4
5
|
import { isModePinned } from "../utils/Commons/apply-theme.util.js";
|
|
5
6
|
import { defineNuxtPlugin, useCookie, useRuntimeConfig } from "#app";
|
|
6
7
|
export default defineNuxtPlugin({
|
|
@@ -23,7 +24,7 @@ export default defineNuxtPlugin({
|
|
|
23
24
|
const initialTheme = themeFromDom ?? themeCookie.value ?? config.defaultTheme;
|
|
24
25
|
const initialMode = modeCookie.value ?? config.defaultMode;
|
|
25
26
|
const themes = config.themes ?? [];
|
|
26
|
-
const origam = createOrigam({ themes, ssr: true });
|
|
27
|
+
const origam = createOrigam({ themes, ssr: true, ...nuxtLocaleOptions(config) });
|
|
27
28
|
nuxtApp.vueApp.use(origam);
|
|
28
29
|
const themeApi = useTheme();
|
|
29
30
|
themeApi.setTheme(initialTheme);
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _origam = require("../origam.cjs");
|
|
8
|
+
var _nuxtLocale = require("../utils/Commons/nuxt-locale.util.cjs");
|
|
8
9
|
var _applyTheme = require("../utils/Commons/apply-theme.util.cjs");
|
|
9
10
|
var _ssrStyles = require("../utils/Commons/ssr-styles.util.cjs");
|
|
10
11
|
var _theme = require("../consts/Commons/theme.const.cjs");
|
|
@@ -67,7 +68,8 @@ module.exports = (0, _app.defineNuxtPlugin)({
|
|
|
67
68
|
});
|
|
68
69
|
const origam = (0, _origam.createOrigam)({
|
|
69
70
|
themes,
|
|
70
|
-
ssr: true
|
|
71
|
+
ssr: true,
|
|
72
|
+
...(0, _nuxtLocale.nuxtLocaleOptions)(config)
|
|
71
73
|
});
|
|
72
74
|
origam._defaultsRef.value = origam._activeDefaultsFor(resolvedTheme === _theme.ORIGAM_THEME_AUTO ? "" : resolvedTheme, resolvedMode);
|
|
73
75
|
nuxtApp.vueApp.use(origam);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createOrigam } from "../origam.js";
|
|
2
|
+
import { nuxtLocaleOptions } from "../utils/Commons/nuxt-locale.util.js";
|
|
2
3
|
import { isModePinned, themeToCss, themeToUnpinnedCss } from "../utils/Commons/apply-theme.util.js";
|
|
3
4
|
import { getSsrStyles } from "../utils/Commons/ssr-styles.util.js";
|
|
4
5
|
import { ORIGAM_MODE_ATTR, ORIGAM_MODE_DARK, ORIGAM_MODE_LIGHT, ORIGAM_THEME_ATTR, ORIGAM_THEME_AUTO } from "../consts/Commons/theme.const.js";
|
|
@@ -59,7 +60,7 @@ export default defineNuxtPlugin({
|
|
|
59
60
|
htmlAttrs,
|
|
60
61
|
style: ssrThemeCss ? [{ id: "origam-theme-ssr", key: "origam-theme-ssr", innerHTML: ssrThemeCss }] : []
|
|
61
62
|
});
|
|
62
|
-
const origam = createOrigam({ themes, ssr: true });
|
|
63
|
+
const origam = createOrigam({ themes, ssr: true, ...nuxtLocaleOptions(config) });
|
|
63
64
|
origam._defaultsRef.value = origam._activeDefaultsFor(
|
|
64
65
|
resolvedTheme === ORIGAM_THEME_AUTO ? "" : resolvedTheme,
|
|
65
66
|
resolvedMode
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IOrigamOptions } from '../../interfaces/Commons/commons.interface';
|
|
2
|
+
import type { IOrigamNuxtRuntimeConfig } from '../../interfaces/Commons/nuxt-module.interface';
|
|
3
|
+
/*********************************************************
|
|
4
|
+
* nuxtLocaleOptions
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* The `createOrigam()` options derived from the module's `locale` setting (#1181).
|
|
8
|
+
* Shared by `plugin.client.ts` and `plugin.server.ts` so both feed `createOrigam`
|
|
9
|
+
* the SAME locale — a difference would render different built-in strings on the
|
|
10
|
+
* server and during hydration.
|
|
11
|
+
* @description
|
|
12
|
+
* Returns `{}` when no locale is configured, so `createLocale()` keeps its own
|
|
13
|
+
* defaults (`en`, fallback `en`, built-in `en` / `fr` messages).
|
|
14
|
+
********************************************************/
|
|
15
|
+
export declare function nuxtLocaleOptions(config: Pick<IOrigamNuxtRuntimeConfig, 'locale'>): Pick<IOrigamOptions, 'locale'>;
|
package/dist/src/utils/index.cjs
CHANGED
|
@@ -190,6 +190,17 @@ Object.keys(_locale).forEach(function (key) {
|
|
|
190
190
|
}
|
|
191
191
|
});
|
|
192
192
|
});
|
|
193
|
+
var _nuxtLocale = require("./Commons/nuxt-locale.util.cjs");
|
|
194
|
+
Object.keys(_nuxtLocale).forEach(function (key) {
|
|
195
|
+
if (key === "default" || key === "__esModule") return;
|
|
196
|
+
if (key in exports && exports[key] === _nuxtLocale[key]) return;
|
|
197
|
+
Object.defineProperty(exports, key, {
|
|
198
|
+
enumerable: true,
|
|
199
|
+
get: function () {
|
|
200
|
+
return _nuxtLocale[key];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
193
204
|
var _nested = require("./Commons/nested.util.cjs");
|
|
194
205
|
Object.keys(_nested).forEach(function (key) {
|
|
195
206
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -15,6 +15,7 @@ export * from './Commons/getCurrentInstance.util';
|
|
|
15
15
|
export * from './Commons/ssr-styles.util';
|
|
16
16
|
export * from './Commons/layout.util';
|
|
17
17
|
export * from './Commons/locale.util';
|
|
18
|
+
export * from './Commons/nuxt-locale.util';
|
|
18
19
|
export * from './Commons/nested.util';
|
|
19
20
|
export * from './Commons/ripple.util';
|
|
20
21
|
export * from './Commons/rounded.util';
|
package/dist/src/utils/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./Commons/getCurrentInstance.util.js";
|
|
|
15
15
|
export * from "./Commons/ssr-styles.util.js";
|
|
16
16
|
export * from "./Commons/layout.util.js";
|
|
17
17
|
export * from "./Commons/locale.util.js";
|
|
18
|
+
export * from "./Commons/nuxt-locale.util.js";
|
|
18
19
|
export * from "./Commons/nested.util.js";
|
|
19
20
|
export * from "./Commons/ripple.util.js";
|
|
20
21
|
export * from "./Commons/rounded.util.js";
|