@bettertogether/community-engine-vue 0.2.2 → 0.2.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/i18n/index.js +20 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "private": false,
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
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",
package/src/i18n/index.js CHANGED
@@ -82,16 +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
- const existing = app.config.globalProperties.$i18n
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 (existing) {
88
- // Merge CEV bt.* into the host app's existing i18n instance
91
+ if (hostI18n?.global?.mergeLocaleMessage) {
89
92
  const merged = buildMessages(options.messages ?? {})
90
93
  for (const [locale, msgs] of Object.entries(merged)) {
91
- existing.global.mergeLocaleMessage(locale, msgs)
94
+ hostI18n.global.mergeLocaleMessage(locale, msgs)
92
95
  }
93
96
  if (options.locale) {
94
- existing.global.locale.value = options.locale
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
+ }
95
110
  }
96
111
  } else {
97
112
  const i18n = createCevI18n(options.messages ?? {}, options.locale ?? 'en')