@bettertogether/community-engine-vue 0.2.3 → 0.2.5
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/package.json +2 -2
- package/src/components/BtHeader.vue +1 -0
- package/src/i18n/index.js +20 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"name": "@bettertogether/community-engine-vue",
|
|
5
5
|
"description": "The Better Together Community Engine is a universal community platform",
|
|
6
6
|
"author": "Better Together Community Co-op",
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"flatted": "^3.2.8",
|
|
79
79
|
"yauzl": "^3.2.1"
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|
package/src/i18n/index.js
CHANGED
|
@@ -82,18 +82,31 @@ export function createCevI18n(optionMessages = {}, locale = 'en') {
|
|
|
82
82
|
* @param {Object} options - Plugin options (may include options.messages for locale overrides)
|
|
83
83
|
*/
|
|
84
84
|
export function installI18n(app, options = {}) {
|
|
85
|
-
|
|
85
|
+
// In vue-i18n v9 with legacy:false, app.config.globalProperties.$i18n is a stripped
|
|
86
|
+
// proxy (only locale/t/d/etc) — it has no .global or .mergeLocaleMessage.
|
|
87
|
+
// The only reliable way to merge into the host's i18n is if the host passes the
|
|
88
|
+
// i18n instance explicitly via options.i18n.
|
|
89
|
+
const hostI18n = options.i18n
|
|
86
90
|
|
|
87
|
-
if (
|
|
88
|
-
// Merge CEV bt.* into the host app's existing i18n instance.
|
|
89
|
-
// $i18n is already the global composer (i18n.global), not the i18n instance itself.
|
|
90
|
-
const composer = existing.global ?? existing
|
|
91
|
+
if (hostI18n?.global?.mergeLocaleMessage) {
|
|
91
92
|
const merged = buildMessages(options.messages ?? {})
|
|
92
93
|
for (const [locale, msgs] of Object.entries(merged)) {
|
|
93
|
-
|
|
94
|
+
hostI18n.global.mergeLocaleMessage(locale, msgs)
|
|
94
95
|
}
|
|
95
96
|
if (options.locale) {
|
|
96
|
-
|
|
97
|
+
hostI18n.global.locale.value = options.locale
|
|
98
|
+
}
|
|
99
|
+
} else if (app.config.globalProperties.$i18n) {
|
|
100
|
+
// Legacy mode fallback: $i18n is the VueI18n instance which has .global
|
|
101
|
+
const composer = app.config.globalProperties.$i18n.global
|
|
102
|
+
if (composer?.mergeLocaleMessage) {
|
|
103
|
+
const merged = buildMessages(options.messages ?? {})
|
|
104
|
+
for (const [locale, msgs] of Object.entries(merged)) {
|
|
105
|
+
composer.mergeLocaleMessage(locale, msgs)
|
|
106
|
+
}
|
|
107
|
+
if (options.locale) {
|
|
108
|
+
composer.locale.value = options.locale
|
|
109
|
+
}
|
|
97
110
|
}
|
|
98
111
|
} else {
|
|
99
112
|
const i18n = createCevI18n(options.messages ?? {}, options.locale ?? 'en')
|