提交 765ad390 编写于 作者: Q qiang

fix: Languange -> Locale

上级 d18939e7
......@@ -70,7 +70,7 @@ declare namespace UniApp {
}
onReady: (fn: Function) => void
serviceReady: boolean
language: string
locale: string
}
interface UniRoute {
......
......@@ -14,7 +14,7 @@ export * from './service/ui/createSelectorQuery'
export * from './service/ui/createAnimation'
export * from './service/ui/tabBar'
export * from './service/ui/window'
export * from './service/ui/language'
export * from './service/ui/locale'
export * from './service/keyboard/getSelectedTextRange'
......
......@@ -2,16 +2,16 @@ import { defineSyncApi } from '../../helpers/api'
import { useI18n } from '@dcloudio/uni-core'
import { BuiltInLocale } from '@dcloudio/uni-i18n'
export const getLanguage = defineSyncApi<typeof uni.getLanguage>(
'getLanguage',
export const getLocale = defineSyncApi<typeof uni.getLocale>(
'getLocale',
() => {
const i18n = useI18n()
return i18n.getLocale()
}
)
export const setLanguage = defineSyncApi<typeof uni.setLanguage>(
'setLanguage',
export const setLocale = defineSyncApi<typeof uni.setLocale>(
'setLocale',
(locale) => {
const i18n = useI18n()
return i18n.setLocale(locale as BuiltInLocale)
......
......@@ -1555,18 +1555,18 @@ var serviceContext = (function (vue) {
let i18n;
function useI18n() {
if (!i18n) {
let language;
let locale;
{
if (typeof getApp === 'function') {
language = weex.requireModule('plus').getLanguage();
locale = weex.requireModule('plus').getLanguage();
}
else {
language = plus.webview.currentWebview().getStyle().language;
locale = plus.webview.currentWebview().getStyle().locale;
}
}
const SET_LOCALE_API = 'i18n.setLocale';
{
i18n = initVueI18n(language, undefined, undefined, typeof getApp === 'function'
i18n = initVueI18n(locale, undefined, undefined, typeof getApp === 'function'
? (locale) => {
const pages = getCurrentPages();
pages.forEach((page) => {
......@@ -4129,11 +4129,11 @@ var serviceContext = (function (vue) {
// window.removeEventListener('resize', onResize)
});
const getLanguage = defineSyncApi('getLanguage', () => {
const getLocale = defineSyncApi('getLocale', () => {
const i18n = useI18n();
return i18n.getLocale();
});
const setLanguage = defineSyncApi('setLanguage', (locale) => {
const setLocale = defineSyncApi('setLocale', (locale) => {
const i18n = useI18n();
return i18n.setLocale(locale);
});
......@@ -10338,7 +10338,7 @@ var serviceContext = (function (vue) {
// android 需要使用
webviewStyle.isTab = isTabBar;
}
webviewStyle.language = weex.requireModule('plus').getLanguage();
webviewStyle.locale = weex.requireModule('plus').getLanguage();
if ((process.env.NODE_ENV !== 'production')) {
console.log(formatLog('updateWebview', webviewStyle));
}
......@@ -12130,8 +12130,8 @@ var serviceContext = (function (vue) {
canvasPutImageData: canvasPutImageData,
canvasToTempFilePath: canvasToTempFilePath,
getSelectedTextRange: getSelectedTextRange,
getLanguage: getLanguage,
setLanguage: setLanguage,
getLocale: getLocale,
setLocale: setLocale,
$on: $on,
$off: $off,
$once: $once,
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -96,8 +96,8 @@ export {
canvasPutImageData,
canvasToTempFilePath,
getSelectedTextRange,
getLanguage,
setLanguage,
getLocale,
setLocale,
$on,
$off,
$once,
......
......@@ -17,7 +17,7 @@ export function initWebviewStyle(
// android 需要使用
webviewStyle.isTab = isTabBar
}
webviewStyle.language = weex.requireModule('plus').getLanguage()
webviewStyle.locale = weex.requireModule('plus').getLanguage()
if (__DEV__) {
console.log(formatLog('updateWebview', webviewStyle))
}
......
......@@ -12,7 +12,7 @@ export function parseWebviewStyle(
uniPageUrl?: InitUniPageUrl
debugRefresh?: DebugRefresh
isTab?: boolean
language?: string
locale?: string
} {
const webviewStyle: PlusWebviewWebviewStyles = {
bounce: 'vertical',
......
......@@ -15,7 +15,7 @@ export function initRecursiveMerge(
name: userManifestJson.versionName,
code: userManifestJson.versionCode,
},
language: userManifestJson.language,
language: userManifestJson.locale,
},
{ plus: userManifestJson['app-plus'] }
)
......
......@@ -4,33 +4,33 @@ import { BuiltInLocale, initVueI18n } from '@dcloudio/uni-i18n'
let i18n: ReturnType<typeof initVueI18n>
interface webviewStyleWithLanguage extends PlusWebviewWebviewStyles {
language: string
locale: string
}
export function useI18n() {
if (!i18n) {
let language: BuiltInLocale
let locale: BuiltInLocale
if (__PLATFORM__ === 'h5') {
if (__NODE_JS__) {
language = getEnvLocale() as BuiltInLocale
locale = getEnvLocale() as BuiltInLocale
} else {
language = (__uniConfig.language || navigator.language) as BuiltInLocale
locale = (__uniConfig.locale || navigator.language) as BuiltInLocale
}
} else if (__PLATFORM__ === 'app') {
if (typeof getApp === 'function') {
language = weex.requireModule('plus').getLanguage() as BuiltInLocale
locale = weex.requireModule('plus').getLanguage() as BuiltInLocale
} else {
language = (
locale = (
plus.webview.currentWebview().getStyle() as webviewStyleWithLanguage
).language as BuiltInLocale
).locale as BuiltInLocale
}
} else {
language = uni.getSystemInfoSync().language as BuiltInLocale
locale = uni.getSystemInfoSync().language as BuiltInLocale
}
const SET_LOCALE_API = 'i18n.setLocale'
if (__PLATFORM__ === 'app') {
i18n = initVueI18n(
language,
locale,
undefined,
undefined,
typeof getApp === 'function'
......@@ -48,7 +48,7 @@ export function useI18n() {
: undefined
)
} else {
i18n = initVueI18n(language)
i18n = initVueI18n(locale)
}
if (__PLATFORM__ === 'app' && typeof getApp !== 'function') {
UniViewJSBridge.subscribe(SET_LOCALE_API, i18n.setLocale)
......
......@@ -32,8 +32,8 @@
"downloadFile",
"getFileInfo",
"getImageInfo",
"getLanguage",
"getLeftWindowStyle",
"getLocale",
"getLocation",
"getNetworkType",
"getProvider",
......@@ -103,8 +103,8 @@
"scanCode",
"sendSocketMessage",
"setKeepScreenOn",
"setLanguage",
"setLeftWindowStyle",
"setLocale",
"setNavigationBarColor",
"setNavigationBarTitle",
"setRightWindowStyle",
......
......@@ -49,8 +49,8 @@ export function uniManifestJsonPlugin(): Plugin {
sdkConfigs.maps.qqmap.key) ||
defaultQQMapKey
let language: string | null | undefined = manifest.language
language = language && language.toUpperCase() !== 'AUTO' ? language : ''
let locale: string | null | undefined = manifest.locale
locale = locale && locale.toUpperCase() !== 'AUTO' ? locale : ''
const flexDirection =
(manifest['app'] &&
......@@ -70,7 +70,7 @@ export function uniManifestJsonPlugin(): Plugin {
export const async = ${JSON.stringify(async)}
export const qqMapKey = '${qqMapKey}'
export const sdkConfigs = ${JSON.stringify(sdkConfigs)}
export const language = '${language}'
export const locale = '${locale}'
`,
map: { mappings: '' },
}
......
......@@ -55,7 +55,7 @@ function generatePagesJsonCode(
return `
import { defineAsyncComponent, resolveComponent, createVNode, withCtx, openBlock, createBlock } from 'vue'
import { PageComponent, AsyncLoadingComponent, AsyncErrorComponent, setupWindow } from '@dcloudio/uni-h5'
import { appid, debug, networkTimeout, router, async, sdkConfigs, qqMapKey, nvue, language } from '${manifestJsonPath}'
import { appid, debug, networkTimeout, router, async, sdkConfigs, qqMapKey, nvue, locale } from '${manifestJsonPath}'
${importLayoutComponentsCode}
const extend = Object.assign
${cssCode}
......@@ -259,7 +259,7 @@ delete ${globalName}['____'+appid+'____']
sdkConfigs,
qqMapKey,
nvue,
language,
locale,
router
})
`
......
......@@ -9,14 +9,14 @@ var vueRouter = require("vue-router");
let i18n;
function useI18n() {
if (!i18n) {
let language;
let locale;
{
{
language = uniShared.getEnvLocale();
locale = uniShared.getEnvLocale();
}
}
{
i18n = uniI18n.initVueI18n(language);
i18n = uniI18n.initVueI18n(locale);
}
}
return i18n;
......
......@@ -6,14 +6,14 @@ import { useRoute, createRouter, createWebHistory, createWebHashHistory, useRout
let i18n;
function useI18n() {
if (!i18n) {
let language;
let locale;
{
{
language = __uniConfig.language || navigator.language;
locale = __uniConfig.locale || navigator.language;
}
}
{
i18n = initVueI18n(language);
i18n = initVueI18n(locale);
}
}
return i18n;
......@@ -4242,11 +4242,11 @@ const onWindowResize = /* @__PURE__ */ defineOnApi(API_ON_WINDOW_RESIZE, () => {
});
const offWindowResize = /* @__PURE__ */ defineOffApi(API_OFF_WINDOW_RESIZE, () => {
});
const getLanguage = /* @__PURE__ */ defineSyncApi("getLanguage", () => {
const getLocale = /* @__PURE__ */ defineSyncApi("getLocale", () => {
const i18n2 = useI18n();
return i18n2.getLocale();
});
const setLanguage = /* @__PURE__ */ defineSyncApi("setLanguage", (locale) => {
const setLocale = /* @__PURE__ */ defineSyncApi("setLocale", (locale) => {
const i18n2 = useI18n();
return i18n2.setLocale(locale);
});
......@@ -19081,8 +19081,8 @@ var api = {
canvasPutImageData,
canvasToTempFilePath,
getSelectedTextRange: getSelectedTextRange$1,
getLanguage,
setLanguage,
getLocale,
setLocale,
$on,
$off,
$once,
......@@ -20302,10 +20302,10 @@ function usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef
}
function _l10nColumn(array, normalize) {
const {
getLocale
getLocale: getLocale2
} = useI18n();
if (props2.mode === mode.DATE) {
const locale = getLocale();
const locale = getLocale2();
if (!locale.startsWith("zh")) {
switch (props2.fields) {
case fields.YEAR:
......@@ -20327,10 +20327,10 @@ function usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef
}
function _l10nItem(item, index2) {
const {
getLocale
getLocale: getLocale2
} = useI18n();
if (props2.mode === mode.DATE) {
const locale = getLocale();
const locale = getLocale2();
if (locale.startsWith("zh")) {
const array = ["\u5E74", "\u6708", "\u65E5"];
return item + array[index2];
......@@ -21237,4 +21237,4 @@ var index = /* @__PURE__ */ defineSystemComponent({
return openBlock(), createBlock("div", clazz, [loadingVNode]);
}
});
export { $emit, $off, $on, $once, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, index$s as Button, index$q as Canvas, index$o as Checkbox, index$p as CheckboxGroup, index$4 as CoverImage, index$5 as CoverView, index$n as Editor, index$u as Form, index$m as Icon, index$l as Image, Input, index$t as Label, LayoutComponent, Map$1 as Map, MovableArea, MovableView, index$k as Navigator, index$2 as PageComponent, index$3 as Picker, PickerView, PickerViewColumn, index$j as Progress, index$h as Radio, index$i as RadioGroup, ResizeSensor, index$g as RichText, ScrollView, index$f as Slider, Swiper, SwiperItem, index$e as Switch, index$d as Text, index$c as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$8 as Video, index$b as View, index$7 as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getFileInfo, getImageInfo, getLanguage, getLeftWindowStyle, getLocation, getNetworkType, getProvider, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onAppLaunch, onCompassChange, onGyroscopeChange, onMemoryWarning, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$9 as plugin, preloadPage, previewImage, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setKeepScreenOn, setLanguage, setLeftWindowStyle, setNavigationBarColor, setNavigationBarTitle, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useTabBar, vibrateLong, vibrateShort };
export { $emit, $off, $on, $once, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, index$s as Button, index$q as Canvas, index$o as Checkbox, index$p as CheckboxGroup, index$4 as CoverImage, index$5 as CoverView, index$n as Editor, index$u as Form, index$m as Icon, index$l as Image, Input, index$t as Label, LayoutComponent, Map$1 as Map, MovableArea, MovableView, index$k as Navigator, index$2 as PageComponent, index$3 as Picker, PickerView, PickerViewColumn, index$j as Progress, index$h as Radio, index$i as RadioGroup, ResizeSensor, index$g as RichText, ScrollView, index$f as Slider, Swiper, SwiperItem, index$e as Switch, index$d as Text, index$c as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$8 as Video, index$b as View, index$7 as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getFileInfo, getImageInfo, getLeftWindowStyle, getLocale, getLocation, getNetworkType, getProvider, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onAppLaunch, onCompassChange, onGyroscopeChange, onMemoryWarning, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$9 as plugin, preloadPage, previewImage, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setKeepScreenOn, setLeftWindowStyle, setLocale, setNavigationBarColor, setNavigationBarTitle, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useTabBar, vibrateLong, vibrateShort };
......@@ -85,8 +85,8 @@ export {
canvasPutImageData,
canvasToTempFilePath,
getSelectedTextRange,
getLanguage,
setLanguage,
getLocale,
setLocale,
$on,
$off,
$once,
......
......@@ -922,10 +922,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@dcloudio/types@^2.5.1":
version "2.5.1"
resolved "https://registry.yarnpkg.com/@dcloudio/types/-/types-2.5.1.tgz#1aacead4158e2d7448e2585db1a68af28fccac1a"
integrity sha512-tw+ELDxWJFG2/GoVlQuUuA8YATtXMmCP7AzRvb1syrdf1rVgrzCGJr3GVlGE8qLEl/lhhRKuufgcOp3h9VSEzA==
"@dcloudio/types@^2.5.2":
version "2.5.2"
resolved "https://registry.yarnpkg.com/@dcloudio/types/-/types-2.5.2.tgz#2ef74a05da3fa24a387a08019830297a8f7c2a0f"
integrity sha512-6H4ANNQan9hz/X6jfsssOZBf5SKFHyXZA4BLdMPMgRDvJhtYCiAMX0mJ/wVh8qrCpJAB+pCOgrDrAeEbfeb4xw==
"@eslint/eslintrc@^0.4.3":
version "0.4.3"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册