提交 41de67f3 编写于 作者: fxy060608's avatar fxy060608

wip(i18n): navigationBar, pullToRefresh

上级 e347bcd8
......@@ -149,6 +149,15 @@ declare namespace UniApp {
height?: number
range?: number
offset?: number
contentdown?: {
caption?: string
}
contentover?: {
caption?: string
}
contentrefresh?: {
caption?: string
}
}
interface PagesJsonPagePlatformStyle {
......
......@@ -1130,6 +1130,7 @@ var serviceContext = (function (vue) {
const NAVBAR_HEIGHT = 44;
const TABBAR_HEIGHT = 50;
const ON_REACH_BOTTOM_DISTANCE = 50;
const I18N_JSON_DELIMITERS = ['%', '%'];
const PRIMARY_COLOR = '#007aff';
const BACKGROUND_COLOR = '#f7f7f7'; // 背景色,如标题栏默认背景色
const SCHEME_RE = /^([a-z-]+:)?\/\//i;
......@@ -1461,8 +1462,8 @@ var serviceContext = (function (vue) {
this.messages[locale] = message;
}
}
f(message, values) {
return this.formater.interpolate(message, values).join('');
f(message, values, delimiters) {
return this.formater.interpolate(message, values, delimiters).join('');
}
t(key, locale, values) {
let message = this.message;
......@@ -1557,8 +1558,8 @@ var serviceContext = (function (vue) {
};
return {
i18n,
f(message, values) {
return i18n.f(message, values);
f(message, values, delimiters) {
return i18n.f(message, values, delimiters);
},
t(key, values) {
return t(key, values);
......@@ -1580,8 +1581,54 @@ var serviceContext = (function (vue) {
},
};
}
function isI18nStr(value, delimiters) {
return value.indexOf(delimiters[0]) > -1;
}
let i18n;
function getLocaleMessage() {
const locale = useI18n().getLocale();
const locales = __uniConfig.locales;
return (locales[locale] || locales[__uniConfig.fallbackLocale] || locales.en || {});
}
function formatI18n(message) {
if (isI18nStr(message, I18N_JSON_DELIMITERS)) {
return useI18n().f(message, getLocaleMessage(), I18N_JSON_DELIMITERS);
}
return message;
}
function resolveJsonObj(jsonObj, names) {
if (names.length === 1) {
if (jsonObj) {
const value = jsonObj[names[0]];
if (isString(value) && isI18nStr(value, I18N_JSON_DELIMITERS)) {
return jsonObj;
}
}
return;
}
const name = names.shift();
return resolveJsonObj(jsonObj && jsonObj[name], names);
}
function defineI18nProperties(obj, names) {
names.forEach((name) => defineI18nProperty(obj, name));
}
function defineI18nProperty(obj, names) {
const jsonObj = resolveJsonObj(obj, names);
if (!jsonObj) {
return;
}
const prop = names[names.length - 1];
let value = jsonObj[prop];
Object.defineProperty(jsonObj, prop, {
get() {
return formatI18n(value);
},
set(v) {
value = v;
},
});
}
function useI18n() {
if (!i18n) {
let locale;
......@@ -1787,6 +1834,28 @@ var serviceContext = (function (vue) {
}
});
const isEnableLocale = once(() => __uniConfig.locales && !!Object.keys(__uniConfig.locales).length);
function initNavigationBarI18n(navigationBar) {
if (isEnableLocale()) {
defineI18nProperties(navigationBar, [
['titleText'],
['searchInput', 'placeholder'],
]);
}
return navigationBar;
}
function initPullToRefreshI18n(pullToRefresh) {
if (isEnableLocale()) {
const CAPTION = 'caption';
defineI18nProperties(pullToRefresh, [
['contentdown', CAPTION],
['contentover', CAPTION],
['contentrefresh', CAPTION],
]);
}
return pullToRefresh;
}
const E = function () {
// Keep this empty so it's easier to inherit from
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
......@@ -2100,6 +2169,14 @@ var serviceContext = (function (vue) {
invokeViewMethodKeepAlive,
});
function initI18n() {
const localeKeys = Object.keys(__uniConfig.locales);
if (localeKeys.length) {
const i18n = useI18n();
localeKeys.forEach((locale) => i18n.add(locale, __uniConfig.locales[locale]));
}
}
function initOn() {
const { on } = UniServiceJSBridge;
on(ON_RESIZE, onResize);
......@@ -2139,8 +2216,11 @@ var serviceContext = (function (vue) {
}
function initService() {
initOn();
initSubscribe();
initI18n();
{
initOn();
initSubscribe();
}
}
function initAppVm(appVm) {
appVm.$vm = appVm;
......@@ -10292,9 +10372,9 @@ var serviceContext = (function (vue) {
if (!routeMeta.enablePullDownRefresh) {
return;
}
webviewStyle.pullToRefresh = normalizePullToRefreshRpx(extend({}, plus.os.name === 'Android'
webviewStyle.pullToRefresh = initPullToRefreshI18n(normalizePullToRefreshRpx(extend({}, plus.os.name === 'Android'
? defaultAndroidPullToRefresh
: defaultPullToRefresh, routeMeta.pullToRefresh));
: defaultPullToRefresh, routeMeta.pullToRefresh)));
}
const defaultAndroidPullToRefresh = { support: true, style: 'circle' };
const defaultPullToRefresh = {
......@@ -10346,7 +10426,7 @@ var serviceContext = (function (vue) {
value;
}
});
webviewStyle.titleNView = titleNView;
webviewStyle.titleNView = initNavigationBarI18n(titleNView);
}
function createTitleImageTags(titleImage) {
return [
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
import { normalizePullToRefreshRpx } from '@dcloudio/uni-core'
import {
initPullToRefreshI18n,
normalizePullToRefreshRpx,
} from '@dcloudio/uni-core'
import { extend } from '@vue/shared'
export function initPullToRefresh(
......@@ -8,15 +11,17 @@ export function initPullToRefresh(
if (!routeMeta.enablePullDownRefresh) {
return
}
webviewStyle.pullToRefresh = normalizePullToRefreshRpx(
extend(
{},
plus.os.name === 'Android'
? defaultAndroidPullToRefresh
: defaultPullToRefresh,
routeMeta.pullToRefresh
)
) as unknown as PlusWebviewWebviewPullToRefreshStyles
webviewStyle.pullToRefresh = initPullToRefreshI18n(
normalizePullToRefreshRpx(
extend(
{},
plus.os.name === 'Android'
? defaultAndroidPullToRefresh
: defaultPullToRefresh,
routeMeta.pullToRefresh
)
) as unknown as PlusWebviewWebviewPullToRefreshStyles
) as PlusWebviewWebviewPullToRefreshStyles
}
const defaultAndroidPullToRefresh = { support: true, style: 'circle' }
......
......@@ -4,7 +4,7 @@ import {
ON_NAVIGATION_BAR_BUTTON_TAP,
} from '@dcloudio/uni-shared'
import { isColor } from './utils'
import { invokeHook } from '@dcloudio/uni-core'
import { initNavigationBarI18n, invokeHook } from '@dcloudio/uni-core'
export function initTitleNView(
webviewStyle: PlusWebviewWebviewStyles,
routeMeta: UniApp.PageRouteMeta
......@@ -40,8 +40,7 @@ export function initTitleNView(
value as any
}
})
webviewStyle.titleNView = titleNView
webviewStyle.titleNView = initNavigationBarI18n(titleNView)
}
function createTitleImageTags(titleImage: string) {
......
import fs from 'fs'
import path from 'path'
import { parseJson } from '../../json'
export function getLocales(inputDir: string) {
const localesDir = path.resolve(inputDir, 'locale')
if (fs.existsSync(localesDir)) {
return fs.readdirSync(localesDir).reduce((res, filename) => {
if (path.extname(filename) === '.json') {
res[filename.replace('.json', '')] =
parseJson(fs.readFileSync(path.join(localesDir, filename), 'utf8')) ||
{}
}
return res
}, {} as Record<string, Record<string, string>>)
}
return {}
}
......@@ -4,6 +4,7 @@ import {
getNVueFlexDirection,
getNVueStyleCompiler,
} from '../manifest'
import { getLocales } from './locale'
interface AppUniConfig {
pages: string[]
......@@ -28,6 +29,9 @@ interface AppUniConfig {
downloadFile: number
}
tabBar?: UniApp.UniConfig['tabBar']
locale?: string
fallbackLocale?: string
locales?: Record<string, Record<string, string>>
}
export function normalizeAppUniConfig(
......@@ -56,6 +60,7 @@ export function normalizeAppUniConfig(
entryPagePath: pagesJson.pages[0].path,
networkTimeout: normalizeNetworkTimeout(manifestJson.networkTimeout),
tabBar: pagesJson.tabBar,
locales: getLocales(process.env.UNI_INPUT_DIR),
}
// TODO 待支持分包
return JSON.stringify(config)
......
......@@ -45,7 +45,7 @@ function initProjectFeature({ inputDir }: InitFeaturesOptions) {
i18nZhHans: true,
i18nZhHant: true,
}
const localesDir = path.resolve(inputDir, 'locales')
const localesDir = path.resolve(inputDir, 'locale')
if (fs.existsSync(localesDir)) {
if (
fs.readdirSync(localesDir).find((file) => path.extname(file) === '.json')
......
export * from './useI18n'
export * from './messages'
export * from './pageMeta'
import { once } from '@dcloudio/uni-shared'
import { defineI18nProperties } from './useI18n'
const isEnableLocale = once(
() => __uniConfig.locales && !!Object.keys(__uniConfig.locales).length
)
export function initNavigationBarI18n(
navigationBar: UniApp.PageNavigationBar | PlusWebviewWebviewTitleNViewStyles
) {
if (isEnableLocale()) {
defineI18nProperties(navigationBar, [
['titleText'],
['searchInput', 'placeholder'],
])
}
return navigationBar
}
export function initPullToRefreshI18n(
pullToRefresh:
| UniApp.PageRefreshOptions
| PlusWebviewWebviewPullToRefreshStyles
) {
if (isEnableLocale()) {
const CAPTION = 'caption'
defineI18nProperties(pullToRefresh, [
['contentdown', CAPTION],
['contentover', CAPTION],
['contentrefresh', CAPTION],
])
}
return pullToRefresh
}
import { isString } from '@vue/shared'
import { getEnvLocale, I18N_JSON_DELIMITERS } from '@dcloudio/uni-shared'
import { BuiltInLocale, initVueI18n, isI18nStr } from '@dcloudio/uni-i18n'
......@@ -16,12 +17,53 @@ function getLocaleMessage() {
}
export function formatI18n(message: string) {
if (__uniConfig.locales && isI18nStr(message, I18N_JSON_DELIMITERS)) {
return useI18n().f(message, getLocaleMessage())
if (isI18nStr(message, I18N_JSON_DELIMITERS)) {
return useI18n().f(message, getLocaleMessage(), I18N_JSON_DELIMITERS)
}
return message
}
function resolveJsonObj(
jsonObj: Record<string, any> | undefined,
names: string[]
): Record<string, any> | undefined {
if (names.length === 1) {
if (jsonObj) {
const value = jsonObj[names[0]]
if (isString(value) && isI18nStr(value, I18N_JSON_DELIMITERS)) {
return jsonObj
}
}
return
}
const name = names.shift()!
return resolveJsonObj(jsonObj && jsonObj[name], names)
}
export function defineI18nProperties(
obj: Record<string, any>,
names: string[][]
) {
names.forEach((name) => defineI18nProperty(obj, name))
}
export function defineI18nProperty(obj: Record<string, any>, names: string[]) {
const jsonObj = resolveJsonObj(obj, names)
if (!jsonObj) {
return
}
const prop = names[names.length - 1]
let value = jsonObj[prop]
Object.defineProperty(jsonObj, prop, {
get() {
return formatI18n(value)
},
set(v) {
value = v
},
})
}
export function useI18n() {
if (!i18n) {
let locale: BuiltInLocale
......
import { BuiltInLocale } from '@dcloudio/uni-i18n'
import { useI18n } from '../../i18n'
export function initI18n() {
const localeKeys = Object.keys(__uniConfig.locales)
if (localeKeys.length) {
const i18n = useI18n()
localeKeys.forEach((locale) =>
i18n.add(locale as BuiltInLocale, __uniConfig.locales[locale])
)
}
}
import { ComponentPublicInstance } from 'vue'
import { initI18n } from './i18n'
import { initOn } from './on'
import { initSubscribe } from './subscribe'
export function initService() {
if (__NODE_JS__) {
return
initI18n()
if (!__NODE_JS__) {
initOn()
initSubscribe()
}
initOn()
initSubscribe()
}
export function initAppVm(appVm: ComponentPublicInstance) {
......
......@@ -65,11 +65,6 @@ ${defineLayoutComponentsCode}
${definePagesCode}
${uniRoutesCode}
${config.command === 'serve' ? hmrCode : ''}
const localeKeys = Object.keys(__uniConfig.locales)
if (localeKeys.length) {
const i18n = useI18n()
localeKeys.forEach(locale=>i18n.add(locale,__uniConfig.locales[locale]))
}
export {}
`
}
......
......@@ -2,9 +2,9 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports[Symbol.toStringTag] = "Module";
var vue = require("vue");
var shared = require("@vue/shared");
var uniShared = require("@dcloudio/uni-shared");
var uniI18n = require("@dcloudio/uni-i18n");
var shared = require("@vue/shared");
var vueRouter = require("vue-router");
let i18n;
function getLocaleMessage() {
......@@ -13,11 +13,43 @@ function getLocaleMessage() {
return locales[locale] || locales[__uniConfig.fallbackLocale] || locales.en || {};
}
function formatI18n(message) {
if (__uniConfig.locales && uniI18n.isI18nStr(message, uniShared.I18N_JSON_DELIMITERS)) {
return useI18n().f(message, getLocaleMessage());
if (uniI18n.isI18nStr(message, uniShared.I18N_JSON_DELIMITERS)) {
return useI18n().f(message, getLocaleMessage(), uniShared.I18N_JSON_DELIMITERS);
}
return message;
}
function resolveJsonObj(jsonObj, names) {
if (names.length === 1) {
if (jsonObj) {
const value = jsonObj[names[0]];
if (shared.isString(value) && uniI18n.isI18nStr(value, uniShared.I18N_JSON_DELIMITERS)) {
return jsonObj;
}
}
return;
}
const name = names.shift();
return resolveJsonObj(jsonObj && jsonObj[name], names);
}
function defineI18nProperties(obj, names) {
names.forEach((name) => defineI18nProperty(obj, name));
}
function defineI18nProperty(obj, names) {
const jsonObj = resolveJsonObj(obj, names);
if (!jsonObj) {
return;
}
const prop = names[names.length - 1];
let value = jsonObj[prop];
Object.defineProperty(jsonObj, prop, {
get() {
return formatI18n(value);
},
set(v2) {
value = v2;
}
});
}
function useI18n() {
if (!i18n) {
let locale;
......@@ -101,6 +133,27 @@ const initI18nVideoMsgsOnce = /* @__PURE__ */ uniShared.once(() => {
useI18n().add(uniI18n.LOCALE_ZH_HANT, normalizeMessages(name, keys, ["\u5F48\u5E55", "\u97F3\u91CF"]), false);
}
});
const isEnableLocale = uniShared.once(() => __uniConfig.locales && !!Object.keys(__uniConfig.locales).length);
function initNavigationBarI18n(navigationBar) {
if (isEnableLocale()) {
defineI18nProperties(navigationBar, [
["titleText"],
["searchInput", "placeholder"]
]);
}
return navigationBar;
}
function initPullToRefreshI18n(pullToRefresh) {
if (isEnableLocale()) {
const CAPTION = "caption";
defineI18nProperties(pullToRefresh, [
["contentdown", CAPTION],
["contentover", CAPTION],
["contentrefresh", CAPTION]
]);
}
return pullToRefresh;
}
const E = function() {
};
E.prototype = {
......@@ -402,6 +455,16 @@ const ServiceJSBridge = /* @__PURE__ */ shared.extend(initBridge("view"), {
invokeViewMethod,
invokeViewMethodKeepAlive
});
function initI18n() {
const localeKeys = Object.keys(__uniConfig.locales);
if (localeKeys.length) {
const i18n2 = useI18n();
localeKeys.forEach((locale) => i18n2.add(locale, __uniConfig.locales[locale]));
}
}
function initService() {
initI18n();
}
function initAppVm(appVm2) {
appVm2.$vm = appVm2;
appVm2.$mpType = "app";
......@@ -6615,6 +6678,7 @@ function normalizePageMeta(pageMeta) {
pullToRefresh.offset += uniShared.NAVBAR_HEIGHT + 0;
}
pageMeta.pullToRefresh = pullToRefresh;
__UNI_FEATURE_I18N_LOCALE__ && initPullToRefreshI18n(pullToRefresh);
}
}
if (__UNI_FEATURE_NAVIGATIONBAR__) {
......@@ -6625,6 +6689,7 @@ function normalizePageMeta(pageMeta) {
navigationBar.titleSize = titleSize || "16px";
navigationBar.titleColor = titleColor || "#ffffff";
navigationBar.backgroundColor = backgroundColor || "#F7F7F7";
__UNI_FEATURE_I18N_LOCALE__ && initNavigationBarI18n(navigationBar);
}
return pageMeta;
}
......@@ -6777,6 +6842,7 @@ function initApp(vm) {
appVm = vm;
initAppVm(appVm);
appVm.globalData = appVm.$options.globalData || {};
initService();
}
function wrapperComponentSetup(comp, { init, setup, before }) {
before && before(comp);
......@@ -10343,11 +10409,6 @@ function createPageHeadTitleTextTsx({
titleText,
titleImage
}) {
if (__UNI_FEATURE_I18N_LOCALE__) {
if (!titleImage && titleText) {
titleText = formatI18n(titleText);
}
}
return vue.createVNode("div", {
"class": "uni-page-head-bd"
}, [vue.createVNode("div", {
......
import { withModifiers, createVNode, getCurrentInstance, defineComponent, ref, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, injectHook, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, onBeforeActivate, onBeforeDeactivate, openBlock, createBlock, renderList, onDeactivated, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent, createElementBlock, createElementVNode, normalizeStyle, renderSlot } from "vue";
import { isString, extend, stringifyStyle, parseStringStyle, isPlainObject, isFunction, isArray, hasOwn, isObject, capitalize, toRawType, makeMap as makeMap$1, isPromise, hyphenate, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
import { I18N_JSON_DELIMITERS, once, passive, initCustomDataset, invokeArrayFns, resolveOwnerVm, resolveOwnerEl, ON_WXS_INVOKE_CALL_METHOD, normalizeTarget, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, ON_ERROR, callOptions, ON_LAUNCH, PRIMARY_COLOR, removeLeadingSlash, getLen, debounce, UniLifecycleHooks, NAVBAR_HEIGHT, parseQuery, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, updateElementStyle, ON_BACK_PRESS, parseUrl, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
import { initVueI18n, isI18nStr, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT } from "@dcloudio/uni-i18n";
import { extend, isString, stringifyStyle, parseStringStyle, isPlainObject, isFunction, isArray, hasOwn, isObject, capitalize, toRawType, makeMap as makeMap$1, isPromise, hyphenate, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
import { useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView } from "vue-router";
let i18n;
function getLocaleMessage() {
......@@ -10,11 +10,43 @@ function getLocaleMessage() {
return locales[locale] || locales[__uniConfig.fallbackLocale] || locales.en || {};
}
function formatI18n(message) {
if (__uniConfig.locales && isI18nStr(message, I18N_JSON_DELIMITERS)) {
return useI18n().f(message, getLocaleMessage());
if (isI18nStr(message, I18N_JSON_DELIMITERS)) {
return useI18n().f(message, getLocaleMessage(), I18N_JSON_DELIMITERS);
}
return message;
}
function resolveJsonObj(jsonObj, names) {
if (names.length === 1) {
if (jsonObj) {
const value = jsonObj[names[0]];
if (isString(value) && isI18nStr(value, I18N_JSON_DELIMITERS)) {
return jsonObj;
}
}
return;
}
const name = names.shift();
return resolveJsonObj(jsonObj && jsonObj[name], names);
}
function defineI18nProperties(obj, names) {
names.forEach((name) => defineI18nProperty(obj, name));
}
function defineI18nProperty(obj, names) {
const jsonObj = resolveJsonObj(obj, names);
if (!jsonObj) {
return;
}
const prop = names[names.length - 1];
let value = jsonObj[prop];
Object.defineProperty(jsonObj, prop, {
get() {
return formatI18n(value);
},
set(v2) {
value = v2;
}
});
}
function useI18n() {
if (!i18n) {
let locale;
......@@ -194,6 +226,27 @@ const initI18nVideoMsgsOnce = /* @__PURE__ */ once(() => {
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, keys, ["\u5F48\u5E55", "\u97F3\u91CF"]), false);
}
});
const isEnableLocale = once(() => __uniConfig.locales && !!Object.keys(__uniConfig.locales).length);
function initNavigationBarI18n(navigationBar) {
if (isEnableLocale()) {
defineI18nProperties(navigationBar, [
["titleText"],
["searchInput", "placeholder"]
]);
}
return navigationBar;
}
function initPullToRefreshI18n(pullToRefresh) {
if (isEnableLocale()) {
const CAPTION = "caption";
defineI18nProperties(pullToRefresh, [
["contentdown", CAPTION],
["contentover", CAPTION],
["contentrefresh", CAPTION]
]);
}
return pullToRefresh;
}
const E = function() {
};
E.prototype = {
......@@ -1239,6 +1292,13 @@ const ServiceJSBridge = /* @__PURE__ */ extend(initBridge("view"), {
invokeViewMethod,
invokeViewMethodKeepAlive
});
function initI18n() {
const localeKeys = Object.keys(__uniConfig.locales);
if (localeKeys.length) {
const i18n2 = useI18n();
localeKeys.forEach((locale) => i18n2.add(locale, __uniConfig.locales[locale]));
}
}
function initOn() {
const { on: on2 } = UniServiceJSBridge;
on2(ON_RESIZE, onResize$1);
......@@ -1276,8 +1336,11 @@ function createPageEvent(name) {
};
}
function initService() {
initOn();
initSubscribe();
initI18n();
{
initOn();
initSubscribe();
}
}
function initAppVm(appVm2) {
appVm2.$vm = appVm2;
......@@ -13297,6 +13360,7 @@ function normalizePageMeta(pageMeta) {
pullToRefresh.offset += NAVBAR_HEIGHT + out.top;
}
pageMeta.pullToRefresh = pullToRefresh;
__UNI_FEATURE_I18N_LOCALE__ && initPullToRefreshI18n(pullToRefresh);
}
}
if (__UNI_FEATURE_NAVIGATIONBAR__) {
......@@ -13307,6 +13371,7 @@ function normalizePageMeta(pageMeta) {
navigationBar.titleSize = titleSize || "16px";
navigationBar.titleColor = titleColor || "#ffffff";
navigationBar.backgroundColor = backgroundColor || "#F7F7F7";
__UNI_FEATURE_I18N_LOCALE__ && initNavigationBarI18n(navigationBar);
}
if (__UNI_FEATURE_PAGES__ && history.state) {
const type = history.state.__type__;
......@@ -20688,11 +20753,6 @@ function createPageHeadTitleTextTsx({
titleText,
titleImage
}) {
if (__UNI_FEATURE_I18N_LOCALE__) {
if (!titleImage && titleText) {
titleText = formatI18n(titleText);
}
}
return createVNode("div", {
"class": "uni-page-head-bd"
}, [createVNode("div", {
......
......@@ -9,7 +9,6 @@ import {
ICON_PATH_SEARCH,
ICON_PATH_BACK,
ICON_PATH_CLOSE,
formatI18n,
} from '@dcloudio/uni-core'
import { usePageMeta } from '../../setup/provide'
import {
......@@ -158,11 +157,6 @@ function createPageHeadTitleTextTsx({
titleText,
titleImage,
}: UniApp.PageNavigationBar) {
if (__UNI_FEATURE_I18N_LOCALE__) {
if (!titleImage && titleText) {
titleText = formatI18n(titleText)
}
}
return (
<div class="uni-page-head-bd">
<div
......
......@@ -4,6 +4,9 @@ import { useRoute } from 'vue-router'
import { NAVBAR_HEIGHT, parseQuery } from '@dcloudio/uni-shared'
import {
defineI18nProperties,
initNavigationBarI18n,
initPullToRefreshI18n,
initRouteMeta,
normalizePullToRefreshRpx,
PolySymbol,
......@@ -87,6 +90,8 @@ function normalizePageMeta(pageMeta: UniApp.PageRouteMeta) {
NAVBAR_HEIGHT + (__NODE_JS__ ? 0 : safeAreaInsets.top)
}
pageMeta.pullToRefresh = pullToRefresh
__UNI_FEATURE_I18N_LOCALE__ && initPullToRefreshI18n(pullToRefresh)
}
}
if (__UNI_FEATURE_NAVIGATIONBAR__) {
......@@ -97,6 +102,7 @@ function normalizePageMeta(pageMeta: UniApp.PageRouteMeta) {
navigationBar.titleSize = titleSize || '16px'
navigationBar.titleColor = titleColor || '#ffffff'
navigationBar.backgroundColor = backgroundColor || '#F7F7F7'
__UNI_FEATURE_I18N_LOCALE__ && initNavigationBarI18n(navigationBar)
}
if (!__NODE_JS__ && __UNI_FEATURE_PAGES__ && history.state) {
// 首页执行了redirectTo
......@@ -109,5 +115,6 @@ function normalizePageMeta(pageMeta: UniApp.PageRouteMeta) {
pageMeta.isQuit = true
}
}
return pageMeta
}
......@@ -201,8 +201,8 @@ class I18n {
this.messages[locale] = message;
}
}
f(message, values) {
return this.formater.interpolate(message, values).join('');
f(message, values, delimiters) {
return this.formater.interpolate(message, values, delimiters).join('');
}
t(key, locale, values) {
let message = this.message;
......@@ -297,8 +297,8 @@ function initVueI18n(locale = LOCALE_EN, messages = {}, fallbackLocale = LOCALE_
};
return {
i18n,
f(message, values) {
return i18n.f(message, values);
f(message, values, delimiters) {
return i18n.f(message, values, delimiters);
},
t(key, values) {
return t(key, values);
......
......@@ -32,7 +32,7 @@ export declare class I18n {
getLocale(): BuiltInLocale;
watchLocale(fn: LocaleWatcher): () => void;
add(locale: BuiltInLocale, message: Record<string, string>, override?: boolean): void;
f(message: string, values?: Record<string, unknown> | Array<unknown>): string;
f(message: string, values?: Record<string, unknown> | Array<unknown>, delimiters?: [string, string]): string;
t(key: string, values?: Record<string, unknown> | Array<unknown> | BuiltInLocale): string;
t(key: string, locale?: BuiltInLocale, values?: Record<string, unknown> | Array<unknown>): string;
}
......@@ -47,7 +47,7 @@ export declare interface I18nOptions {
export declare function initVueI18n(locale?: BuiltInLocale, messages?: LocaleMessages, fallbackLocale?: BuiltInLocale, watcher?: (locale: BuiltInLocale) => void): {
i18n: I18n;
f(message: string, values?: Record<string, unknown> | unknown[] | undefined): string;
f(message: string, values?: Record<string, unknown> | unknown[] | undefined, delimiters?: [string, string] | undefined): string;
t(key: string, values?: Record<string, unknown> | unknown[] | undefined): string;
add(locale: BuiltInLocale, message: Record<string, string>, override?: boolean): void;
watch(fn: LocaleWatcher): () => void;
......
......@@ -197,8 +197,8 @@ class I18n {
this.messages[locale] = message;
}
}
f(message, values) {
return this.formater.interpolate(message, values).join('');
f(message, values, delimiters) {
return this.formater.interpolate(message, values, delimiters).join('');
}
t(key, locale, values) {
let message = this.message;
......@@ -293,8 +293,8 @@ function initVueI18n(locale = LOCALE_EN, messages = {}, fallbackLocale = LOCALE_
};
return {
i18n,
f(message, values) {
return i18n.f(message, values);
f(message, values, delimiters) {
return i18n.f(message, values, delimiters);
},
t(key, values) {
return t(key, values);
......
......@@ -150,8 +150,12 @@ export class I18n {
this.messages[locale] = message
}
}
f(message: string, values?: Record<string, unknown> | Array<unknown>) {
return this.formater.interpolate(message, values).join('')
f(
message: string,
values?: Record<string, unknown> | Array<unknown>,
delimiters?: [string, string]
) {
return this.formater.interpolate(message, values, delimiters).join('')
}
t(
key: string,
......
......@@ -100,8 +100,12 @@ export function initVueI18n(
}
return {
i18n,
f(message: string, values?: Record<string, unknown> | Array<unknown>) {
return i18n.f(message, values)
f(
message: string,
values?: Record<string, unknown> | Array<unknown>,
delimiters?: [string, string]
) {
return i18n.f(message, values, delimiters)
},
t(key: string, values?: Record<string, unknown> | Array<unknown>) {
return t(key, values)
......
......@@ -24,6 +24,7 @@ const priority = {
'uni-app-vite': 30,
'vite-plugin-uni': 20,
'uni-cloud': 10,
'uni-automator': 10,
'size-check': 1,
}
......
......@@ -1885,6 +1885,18 @@
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.13.2.tgz#3b0efb6d3903bd49edb073696f60e90df08efb26"
integrity sha512-WrHvO8PDL8wd8T2+zBGKrMwVL5IyzR3ryWUsl0PXgEV0QHup4mTLi0QcATefGI6Gx9Anu7vthPyyyLpY0EpiQg==
"@napi-rs/triples@^1.0.3":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@napi-rs/triples/-/triples-1.0.3.tgz#76d6d0c3f4d16013c61e45dfca5ff1e6c31ae53c"
integrity sha512-jDJTpta+P4p1NZTFVLHJ/TLFVYVcOqv6l8xwOeBKNPMgY/zDYH/YH7SJbvrr/h1RcS9GzbPcLKGzpuK9cV56UA==
"@node-rs/helper@^1.0.0":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@node-rs/helper/-/helper-1.2.1.tgz#e079b05f21ff4329d82c4e1f71c0290e4ecdc70c"
integrity sha512-R5wEmm8nbuQU0YGGmYVjEc0OHtYsuXdpRG+Ut/3wZ9XAvQWyThN08bTh2cBJgoZxHQUPtvRfeQuxcAgLuiBISg==
dependencies:
"@napi-rs/triples" "^1.0.3"
"@nodelib/fs.scandir@2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
......@@ -2205,6 +2217,86 @@
dependencies:
"@sinonjs/commons" "^1.7.0"
"@swc/core-android-arm64@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-android-arm64/-/core-android-arm64-1.2.83.tgz#51bb5e30a52a88c38376695f31c952e0dd6bdeaa"
integrity sha512-pODboMBvwplgfPU7/LVAJdIlt/9lttd8cMUwxSykMo/lFaP5J5SyiBauL1UzFEe6eGpN4WPhlF3H+tTz1uWBwg==
"@swc/core-darwin-arm64@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.83.tgz#3dd634504cc0eb3115f67d67d0688495be4c2189"
integrity sha512-/RadmNG6w8ouXsqEFMgjUZL1pxiodkAMTLuKxzKgGb8C+cJYYzrMrJAhuRaVF56/tbI0f7HjGtVYPIUyj7PO/Q==
"@swc/core-darwin-x64@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.2.83.tgz#4cdad62fea2a4f9b8481f06999529d9a3d8b2632"
integrity sha512-SuMQOzMPv79EqHbvkL29KuAfvxADpEgzVndg/w3rjfT2xHHRBZSbcpTWZ2mXYZeddM3+JG2OrHH55RixUH+r9Q==
"@swc/core-freebsd-x64@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.83.tgz#c317c21bca82c93f8074cb88baab6fa4055e36dd"
integrity sha512-2s7L71s3OgrXbjujPY37OuA0FuTtoevTz8Ce40HkvfcOArTi92gN6WZu55ZtUIwFq3U/hH0oE0Po86JOO/ArVg==
"@swc/core-linux-arm-gnueabihf@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.83.tgz#ab6c7c4eb9cca4b99429d5d5714b2ac32e564c1e"
integrity sha512-RwONngFb7BG+6o9Hi+EuE7dT0d/PtlZyV9DdeAP++uuem9I6vyuXmI3IqtpeRU731wW4gLvlRKLp/EV63sjoSA==
"@swc/core-linux-arm64-gnu@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.83.tgz#2ac6562c980167fdaba660ccfdefb54c55758483"
integrity sha512-BM4cbI4X74eul6ix0PBsJ7sSkIbcHX9P6J3fAoT6CmYeS4gADGB4n1ktw5GYkXhaiVRVK9KVUXEqpfxBTpCXXQ==
"@swc/core-linux-arm64-musl@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.83.tgz#07425dfa5a2b6a768ee0111fbe8ac961dee179cd"
integrity sha512-XDuxnA/rRMLOAAOCjyPlDdzFUrWuD3Xp+m5dHQi80VqpfLGxYeVZebUYfpEtWGI1K4UPQLx+gTk2ssVG5avWKA==
"@swc/core-linux-x64-gnu@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.83.tgz#195143b154a89bfa0a48f2166134b0ad971d71d3"
integrity sha512-FaA5O2V0I8X6UuBua7a4ufGh/r9I00aXvoMcb2yrxyzyApgh2VvLfCj3DaiQIYR44QV7dQm/RII1KsJnX6XpDw==
"@swc/core-linux-x64-musl@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.83.tgz#172a419ef654977b4207c1ff62bbfaef2551b753"
integrity sha512-BYNqN7cmN+TazrUrhGrY9IYbT2+l4UqFEZX/M5iWfFzpvHmGeeacvD4qxC1iAh99dqGHn7rsPM3QVK9lyDlLSw==
"@swc/core-win32-arm64-msvc@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.83.tgz#3204479e427d0af86215046ca339c351f62c0f29"
integrity sha512-tMzWXwcwTsBQ0eVXrwai+Q/aiBZR1sDWpYDD1KINRIYWxTASJ0PLySbLyZdEFfxxPvqOY1gslnWLjPwa1frTkg==
"@swc/core-win32-ia32-msvc@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.83.tgz#02873c0566339a495b97e902b878bca25bfe4f9d"
integrity sha512-ft1kSw8b09Lmyg7xXn7n99GYMr7CCFzWXB8800kjOb+9jsIN73Sn86I3TVldAeIdJZbeuTYU8J7cxhcJcnmmOA==
"@swc/core-win32-x64-msvc@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.83.tgz#6337aa847701f451d7689c9acb5839df4f34c22f"
integrity sha512-HraOOGDp0dI4+yQ7DxW44FBGSa7CDKG+oviiu2ieXyFjnMqyI3AS5jD27O7g7WKQ1RvKky8M6PxFMz9w3P8HJQ==
"@swc/core@^1.2.83":
version "1.2.83"
resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.2.83.tgz#6895b0a0c58e3aeff444f01f8a35787b377fb1b5"
integrity sha512-Ao5XziabPGXBcwyDF8NRZcp7ySZBsjrV1aDyVe2Rdb44VaJ8Q0jN7QjYlc4zOikcwgi1BF05YgvMykMfB0qKMA==
dependencies:
"@node-rs/helper" "^1.0.0"
optionalDependencies:
"@swc/core-android-arm64" "^1.2.83"
"@swc/core-darwin-arm64" "^1.2.83"
"@swc/core-darwin-x64" "^1.2.83"
"@swc/core-freebsd-x64" "^1.2.83"
"@swc/core-linux-arm-gnueabihf" "^1.2.83"
"@swc/core-linux-arm64-gnu" "^1.2.83"
"@swc/core-linux-arm64-musl" "^1.2.83"
"@swc/core-linux-x64-gnu" "^1.2.83"
"@swc/core-linux-x64-musl" "^1.2.83"
"@swc/core-win32-arm64-msvc" "^1.2.83"
"@swc/core-win32-ia32-msvc" "^1.2.83"
"@swc/core-win32-x64-msvc" "^1.2.83"
"@tootallnate/once@1":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
......@@ -2557,6 +2649,13 @@
terser "^5.3.8"
webpack "^5.1.0"
"@types/uglify-js@^3.13.1":
version "3.13.1"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.13.1.tgz#5e889e9e81e94245c75b6450600e1c5ea2878aea"
integrity sha512-O3MmRAk6ZuAKa9CHgg0Pr0+lUOqoMLpc9AS4R8ano2auvsg7IE8syF3Xh/NPr26TWklxYcqoEEFdzLLs1fV9PQ==
dependencies:
source-map "^0.6.1"
"@types/webpack-sources@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@types/webpack-sources/-/webpack-sources-2.1.1.tgz#6af17e3a3ded71eec2b98008d7c12f498a0a4506"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册