@tagplus/components 5.2.6 → 5.2.8
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/dist/tp.common.js +1 -1
- package/dist/tp.common.js.map +1 -1
- package/dist/tp.umd.js +1 -1
- package/dist/tp.umd.js.map +1 -1
- package/dist/tp.umd.min.js +1 -1
- package/dist/tp.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/locale/i18nCreator.js +11 -13
package/package.json
CHANGED
|
@@ -124,45 +124,43 @@ async function setupI18n (options = {}) {
|
|
|
124
124
|
* @param {Function} [options.i18nHelper.importLangFile] - A function for asynchronously importing custom language files.
|
|
125
125
|
* @param {Function} [options.i18nHelper.onLanguageSet] - A function to be called after setting the language.
|
|
126
126
|
* @param {Object} [options.i18nOptions] - Additional options to be passed to the createI18n function.
|
|
127
|
+
* @param {Function} [postInstall] - A function to be called after the plugin is installed.
|
|
127
128
|
*
|
|
128
129
|
* @returns {Object} - An object with an install function for Vue.js plugins.
|
|
129
130
|
*/
|
|
130
|
-
export default async (options = {}) => {
|
|
131
|
-
//
|
|
131
|
+
export default async (options = {}, postInstall = (app, options, i18nHelper) => {}) => {
|
|
132
|
+
// Validating the options
|
|
132
133
|
const keys = Object.keys(options).filter(key => !['i18nHelper', 'i18nOptions'].includes(key))
|
|
133
134
|
if (keys.length) {
|
|
134
135
|
throw new Error(`Invalid options: ${keys.join(', ')}, expected { i18nOptions, i18nHelper }`)
|
|
135
136
|
}
|
|
136
137
|
|
|
137
|
-
//
|
|
138
|
+
// Overriding the importLangFile function if provided in options
|
|
138
139
|
if (options.i18nHelper && typeof options.i18nHelper.importLangFile === 'function') {
|
|
139
140
|
i18nHelper.importLangFile = options.i18nHelper.importLangFile
|
|
140
141
|
}
|
|
141
142
|
|
|
142
|
-
//
|
|
143
|
+
// Overriding the onLanguageSet function if provided in options
|
|
143
144
|
if (options.i18nHelper && typeof options.i18nHelper.onLanguageSet === 'function') {
|
|
144
145
|
i18nHelper.onLanguageSet = options.i18nHelper.onLanguageSet
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
let i18nOptions = {}
|
|
148
|
-
//
|
|
149
|
+
// Using provided i18nOptions if available
|
|
149
150
|
if (options.i18nOptions && typeof options.i18nOptions === 'object') {
|
|
150
151
|
i18nOptions = options.i18nOptions
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
//
|
|
154
|
+
// Initializing the i18n instance with the provided options
|
|
154
155
|
i18n = await setupI18n(i18nOptions)
|
|
155
156
|
|
|
156
157
|
return {
|
|
157
158
|
install: (app, opts) => {
|
|
158
|
-
//
|
|
159
|
+
// Installing the original i18n instance
|
|
159
160
|
i18n.install(app, i18nOptions)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
* in the Vue.js app's global properties.
|
|
164
|
-
**/
|
|
165
|
-
app.config.globalProperties.$i18nHelper = i18nHelper
|
|
161
|
+
if (typeof postInstall === 'function') {
|
|
162
|
+
postInstall(app, options, i18nHelper)
|
|
163
|
+
}
|
|
166
164
|
}
|
|
167
165
|
}
|
|
168
166
|
}
|