提交 5cd5de9d 编写于 作者: fxy060608's avatar fxy060608

feat(mp): custom vue-i18n compiler

上级 1a48f480
......@@ -21,6 +21,18 @@ var vue = require('vue');
*/
const VERSION = '9.1.9';
/**
* 目前暂不支持任何语法
* @param source
* @param _
* @returns
*/
function compileToFunction(source, _ = {}) {
return ((ctx) => {
return ctx.normalize([source]);
});
}
const warnMessages = {
[6 /* FALLBACK_TO_ROOT */]: `Fall back to {type} '{key}' with root locale.`,
[7 /* NOT_SUPPORTED_PRESERVE */]: `Not supported 'preserve'.`,
......@@ -1797,7 +1809,7 @@ function injectGlobalFields(app, composer) {
}
// register message compiler at vue-i18n
coreBase.registerMessageCompiler(coreBase.compileToFunction);
coreBase.registerMessageCompiler(compileToFunction);
// NOTE: experimental !!
{
const target = shared.getGlobalThis();
......
......@@ -21,6 +21,18 @@ var shared = require('@intlify/shared');
*/
const VERSION = '9.1.9';
/**
* 目前暂不支持任何语法
* @param source
* @param _
* @returns
*/
function compileToFunction(source, _ = {}) {
return ((ctx) => {
return ctx.normalize([source]);
});
}
function createI18nError(code, ...args) {
return coreBase.createCompileError(code, null, undefined);
}
......@@ -1687,7 +1699,7 @@ function injectGlobalFields(app, composer) {
}
// register message compiler at vue-i18n
coreBase.registerMessageCompiler(coreBase.compileToFunction);
coreBase.registerMessageCompiler(compileToFunction);
exports.DatetimeFormat = DatetimeFormat;
exports.NumberFormat = NumberFormat;
......
......@@ -4,11 +4,11 @@
* Released under the MIT License.
*/
import { getGlobalThis, format, makeSymbol, isPlainObject, isArray, hasOwn, isObject, isBoolean, isString, isRegExp, isFunction, assign, isNumber, warn, createEmitter, isEmptyObject } from '@intlify/shared';
import { createCompileError, handleFlatJson, createCoreContext, updateFallbackLocale, resolveValue, clearDateTimeFormat, clearNumberFormat, setAdditionalMeta, NOT_REOSLVED, isTranslateFallbackWarn, isTranslateMissingWarn, parseTranslateArgs, translate, MISSING_RESOLVE_VALUE, parseDateTimeArgs, datetime, parseNumberArgs, number, getLocaleChain, registerMessageCompiler, compileToFunction, setDevToolsHook } from '@intlify/core-base';
import { createCompileError, handleFlatJson, createCoreContext, updateFallbackLocale, resolveValue, clearDateTimeFormat, clearNumberFormat, setAdditionalMeta, NOT_REOSLVED, isTranslateFallbackWarn, isTranslateMissingWarn, parseTranslateArgs, translate, MISSING_RESOLVE_VALUE, parseDateTimeArgs, datetime, parseNumberArgs, number, getLocaleChain, registerMessageCompiler, setDevToolsHook } from '@intlify/core-base';
import { ref, getCurrentInstance, computed, watch, createVNode, Text, h, Fragment, inject, onMounted, onUnmounted, isRef } from 'vue';
import { setupDevtoolsPlugin } from '@vue/devtools-api';
import { VueDevToolsLabels, VueDevToolsPlaceholders, VueDevToolsTimelineColors } from '@intlify/vue-devtools';
console.log('custom vue-i18n......')
/**
* Vue I18n Version
*
......@@ -49,6 +49,18 @@ function initFeatureFlags() {
}
}
/**
* 目前暂不支持任何语法
* @param source
* @param _
* @returns
*/
function compileToFunction(source, _ = {}) {
return ((ctx) => {
return ctx.normalize([source]);
});
}
const warnMessages = {
[6 /* FALLBACK_TO_ROOT */]: `Fall back to {type} '{key}' with root locale.`,
[7 /* NOT_SUPPORTED_PRESERVE */]: `Not supported 'preserve'.`,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册