提交 1a48f480 编写于 作者: fxy060608's avatar fxy060608

feat(mp): add vue-i18n

上级 bd96693e
......@@ -6540,6 +6540,7 @@ function initHooks(options, instance, publicThis) {
instance.__isVisible = true;
try {
invokeHook(publicThis, uniShared.ON_LOAD, instance.attrs.__pageQuery);
delete instance.attrs.__pageQuery;
} catch (e2) {
console.error(e2.message + uniShared.LINEFEED + e2.stack);
}
......
......@@ -13414,6 +13414,7 @@ function initHooks(options, instance2, publicThis) {
instance2.__isVisible = true;
try {
invokeHook(publicThis, ON_LOAD, instance2.attrs.__pageQuery);
delete instance2.attrs.__pageQuery;
} catch (e2) {
console.error(e2.message + LINEFEED + e2.stack);
}
......
The MIT License (MIT)
Copyright (c) 2020 kazuya kawaguchi
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# vue-i18n
Internationalization plugin for Vue.js
## Which dist file to use?
### From CDN or without a Bundler
- **`vue-i18n(.runtime).global(.prod).js`**:
- For direct use via `<script src="...">` in the browser. Exposes the `VueI18n` global
- Note that global builds are not [UMD](https://github.com/umdjs/umd) builds. They are built as [IIFEs](https://developer.mozilla.org/en-US/docs/Glossary/IIFE) and is only meant for direct use via `<script src="...">`
- In-browser locale messages compilation:
- **`vue-i18n.global.js`** is the "full" build that includes both the compiler and the runtime so it supports compiling locale messages on the fly
- **`vue-i18n.runtime.global.js`** contains only the runtime and requires locale messages to be pre-compiled during a build step
- Inlines internal the bellow packages - i.e. it’s a single file with no dependencies on other files. This means you **must** import everything from this file and this file only to ensure you are getting the same instance of code
- `@intlify/shared`
- `@intlify/message-resolver`
- `@intlify/message-compiler`
- `@intlify/core`
- Contains hard-coded prod/dev branches, and the prod build is pre-minified. Use the `*.prod.js` files for production
- **`vue-i18n(.runtime).esm-browser(.prod).js`**:
- For usage via native ES modules imports (in browser via `<script type="module">`)
- Shares the same runtime compilation, dependency inlining and hard-coded prod/dev behavior with the global build
### With a Bundler
- **`vue-i18n(.runtime).esm-bundler.js`**:
- For use with bundlers like `webpack`, `rollup` and `parcel`
- Leaves prod/dev branches with `process.env.NODE_ENV` guards (must be replaced by bundler)
- Does not ship minified builds (to be done together with the rest of the code after bundling)
- Imports dependencies (e.g. `@intlify/core-base`, `@intlify/message-compiler`)
- Imported dependencies are also `esm-bundler` builds and will in turn import their dependencies (e.g. `@intlify/message-compiler` imports `@intlify/shared`)
- This means you **can** install/import these deps individually without ending up with different instances of these dependencies, but you must make sure they all resolve to the same version
- In-browser locale messages compilation:
- **`vue-i18n.runtime.esm-bundler.js` (default)** is runtime only, and requires all locale messages to be pre-compiled. This is the default entry for bundlers (via `module` field in `package.json`) because when using a bundler templates are typically pre-compiled (e.g. in `*.json` files)
- **`vue-i18n.esm-bundler.js`**: includes the runtime compiler. Use this if you are using a bundler but still want locale messages compilation (e.g. templates via inline JavaScript strings)
### For Node.js (Server-Side)
- **`vue-i18n.cjs(.prod).js`**:
- For use in Node.js via `require()`
- If you bundle your app with webpack with `target: 'node'` and properly externalize `vue-i18n`, this is the build that will be loaded
- The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env.NODE_ENV`
## For Bundler feature flags
### Build Feature Flags
The `esm-bundler` builds now exposes global feature flags that can be overwritten at compile time:
- `__VUE_I18N_FULL_INSTALL__` (enable/disable, in addition to vue-i18n APIs, components and directives all fully support installation: `true`)
- `__VUE_I18N_LEGACY_API__` (enable/disable vue-i18n legacy style APIs support, default: `true`)
- `__VUE_I18N_PROD_DEVTOOLS__` (enable/disable vue-devtools support in production, default: `false`)
- `__INTLIFY_PROD_DEVTOOLS__` (enable/disable `@intlify/devtools` support in production, default: `false`)
> NOTE: `__INTLIFY_PROD_DEVTOOLS__` flag is experimental, and `@intlify/devtools` is WIP yet.
The build will work without configuring these flags, however it is **strongly recommended** to properly configure them in order to get proper tree shaking in the final bundle. To configure these flags:
- webpack: use [DefinePlugin](https://webpack.js.org/plugins/define-plugin/)
- Rollup: use [@rollup/plugin-replace](https://github.com/rollup/plugins/tree/master/packages/replace)
- Vite: configured by default, but can be overwritten using the [`define` option](https://github.com/vitejs/vite/blob/a4133c073e640b17276b2de6e91a6857bdf382e1/src/node/config.ts#L72-L76)
Note: the replacement value **must be boolean literals** and cannot be strings, otherwise the bundler/minifier will not be able to properly evaluate the conditions.
## Other Feature Flags
- `__FEATURE_ESM_BUNDLER_WARN__` (Suppress / Not suppress feature flags recommended warnings in build for `esm-bulder`)
## :copyright: License
[MIT](http://opensource.org/licenses/MIT)
此差异已折叠。
此差异已折叠。
'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/vue-i18n.cjs.prod.js')
} else {
module.exports = require('./dist/vue-i18n.cjs.js')
}
{
"name": "vue-i18n",
"version": "9.1.9",
"description": "Internationalization plugin for Vue.js",
"keywords": [
"i18n",
"internationalization",
"intlify",
"plugin",
"vue",
"vue.js"
],
"license": "MIT",
"author": {
"name": "kazuya kawaguchi",
"email": "kawakazu80@gmail.com"
},
"homepage": "https://github.com/intlify/vue-i18n-next/tree/master/packages/vue-i18n#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/intlify/vue-i18n-next.git",
"directory": "packages/vue-i18n"
},
"bugs": {
"url": "https://github.com/intlify/vue-i18n-next/issues"
},
"files": [
"index.js",
"dist",
"vetur"
],
"main": "index.js",
"module": "dist/vue-i18n.esm-bundler.js",
"unpkg": "dist/vue-i18n.global.js",
"jsdelivr": "dist/vue-i18n.global.js",
"types": "dist/vue-i18n.d.ts",
"dependencies": {
"@intlify/core-base": "9.1.9",
"@intlify/shared": "9.1.9",
"@intlify/vue-devtools": "9.1.9",
"@vue/devtools-api": "^6.0.0-beta.7"
},
"devDependencies": {
"@intlify/devtools-if": "9.1.9"
},
"peerDependencies": {
"vue": "^3.0.0"
},
"engines": {
"node": ">= 10"
},
"buildOptions": {
"name": "VueI18n",
"formats": [
"esm-bundler",
"esm-bundler-runtime",
"esm-browser",
"esm-browser-runtime",
"cjs",
"global",
"global-runtime"
]
},
"sideEffects": false,
"vetur": {
"tags": "vetur/tags.json",
"attributes": "vetur/attributes.json"
}
}
{
"i18n-t/keypath": {
"description": "[required]\nThe locale message key can be specified prop",
"type": "string"
},
"i18n-t/plural": {
"description": "[optional]\nThe Plural Choosing the message number prop",
"type": "number|string"
},
"i18n-t/locale": {
"description": "[optional]\nThe locale to be used for the component",
"type": "string"
},
"i18n-t/scope": {
"description": "[optional]\tThe scope to be used in the target component.\nYou can specify either `global` or `parent`",
"type": "string"
},
"i18n-t/tag": {
"description": "[optional]\nUsed to wrap the content that is distribute in the slot.\nIf omitted, the slot content is treated as Fragments",
"type": "string|object"
},
"i18n-d/value": {
"description": "[required]\nThe value specified for the target component",
"type": "number|date"
},
"i18n-d/format": {
"description": "[optional]\nThe format to use in the target component",
"type": "string|object"
},
"i18n-d/locale": {
"description": "[optional]\nThe locale to be used for the component",
"type": "string"
},
"i18n-d/scope": {
"description": "[optional]\tThe scope to be used in the target component.\nYou can specify either `global` or `parent`",
"type": "string"
},
"i18n-d/tag": {
"description": "[optional]\nUsed to wrap the content that is distribute in the slot.\nIf omitted, the slot content is treated as Fragments",
"type": "string|object"
},
"i18n-n/value": {
"description": "[required]\nThe value specified for the target component",
"type": "number"
},
"i18n-n/format": {
"description": "[optional]\nThe format to use in the target component",
"type": "string|object"
},
"i18n-n/locale": {
"description": "[optional]\nThe locale to be used for the component",
"type": "string"
},
"i18n-n/scope": {
"description": "[optional]\tThe scope to be used in the target component.\nYou can specify either `global` or `parent`",
"type": "string"
},
"i18n-n/tag": {
"description": "[optional]\nUsed to wrap the content that is distribute in the slot.\nIf omitted, the slot content is treated as Fragments",
"type": "string|object"
}
}
{
"i18n-t": {
"attributes": ["keypath", "locale", "tag", "plural", "scope"],
"description": "This is Translation component that can be used when HTML interpolation is needed.\n\nhttps://vue-i18n.intlify.dev/guide/advanced/component.html#basic-usage"
},
"i18n-d": {
"attributes": ["value", "format", "locale", "tag", "scope"],
"description": "This is Datetime Format component provides a way to use HTML interpolation in pair with number formatting.\n\nhttps://vue-i18n.intlify.dev/guide/essentials/datetime.html#custom-formatting"
},
"i18n-n": {
"attributes": ["value", "format", "locale", "tag", "scope"],
"description": "This is Number Format component provides a way to use HTML interpolation in pair with number formatting.\n\nhttps://vue-i18n.intlify.dev/guide/essentials/number.html#custom-formatting"
}
}
......@@ -22,6 +22,9 @@
"@dcloudio/uni-mp-compiler": "3.0.0-alpha-3021320211118002",
"@dcloudio/uni-mp-vue": "3.0.0-alpha-3021320211118002",
"@dcloudio/uni-shared": "3.0.0-alpha-3021320211118002",
"@intlify/core-base": "9.1.9",
"@intlify/shared": "9.1.9",
"@intlify/vue-devtools": "9.1.9",
"@vue/shared": "3.2.22",
"base64url": "^3.0.1",
"debug": "^4.3.2",
......
import path from 'path'
import { AliasOptions, ResolvedConfig } from 'vite'
import {
CopyOptions,
......@@ -99,6 +100,7 @@ export function uniMiniProgramPlugin(
alias: {
vue: resolveBuiltIn('@dcloudio/uni-mp-vue'),
'@vue/devtools-api': resolveBuiltIn('@dcloudio/uni-mp-vue'),
'vue-i18n': path.resolve(__dirname, '../../lib/vue-i18n'),
...alias,
},
},
......
......@@ -45,6 +45,7 @@ export function initHooks(
instance.__isVisible = true
try {
invokeHook(publicThis, ON_LOAD, instance.attrs.__pageQuery)
delete instance.attrs.__pageQuery
} catch (e: any) {
console.error(e.message + LINEFEED + e.stack)
}
......
......@@ -670,6 +670,9 @@ importers:
'@dcloudio/uni-mp-compiler': 3.0.0-alpha-3021320211118002
'@dcloudio/uni-mp-vue': 3.0.0-alpha-3021320211118002
'@dcloudio/uni-shared': 3.0.0-alpha-3021320211118002
'@intlify/core-base': 9.1.9
'@intlify/shared': 9.1.9
'@intlify/vue-devtools': 9.1.9
'@types/debug': ^4.1.7
'@vue/compiler-sfc': 3.2.22
'@vue/shared': 3.2.22
......@@ -681,6 +684,9 @@ importers:
'@dcloudio/uni-mp-compiler': link:../uni-mp-compiler
'@dcloudio/uni-mp-vue': link:../uni-mp-vue
'@dcloudio/uni-shared': link:../uni-shared
'@intlify/core-base': 9.1.9
'@intlify/shared': 9.1.9
'@intlify/vue-devtools': 9.1.9
'@vue/shared': 3.2.22
base64url: 3.0.1
debug: 4.3.2
......@@ -2030,6 +2036,62 @@ packages:
resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==}
dev: true
/@intlify/core-base/9.1.9:
resolution: {integrity: sha512-x5T0p/Ja0S8hs5xs+ImKyYckVkL4CzcEXykVYYV6rcbXxJTe2o58IquSqX9bdncVKbRZP7GlBU1EcRaQEEJ+vw==}
engines: {node: '>= 10'}
dependencies:
'@intlify/devtools-if': 9.1.9
'@intlify/message-compiler': 9.1.9
'@intlify/message-resolver': 9.1.9
'@intlify/runtime': 9.1.9
'@intlify/shared': 9.1.9
'@intlify/vue-devtools': 9.1.9
dev: false
/@intlify/devtools-if/9.1.9:
resolution: {integrity: sha512-oKSMKjttG3Ut/1UGEZjSdghuP3fwA15zpDPcjkf/1FjlOIm6uIBGMNS5jXzsZy593u+P/YcnrZD6cD3IVFz9vQ==}
engines: {node: '>= 10'}
dependencies:
'@intlify/shared': 9.1.9
dev: false
/@intlify/message-compiler/9.1.9:
resolution: {integrity: sha512-6YgCMF46Xd0IH2hMRLCssZI3gFG4aywidoWQ3QP4RGYQXQYYfFC54DxhSgfIPpVoPLQ+4AD29eoYmhiHZ+qLFQ==}
engines: {node: '>= 10'}
dependencies:
'@intlify/message-resolver': 9.1.9
'@intlify/shared': 9.1.9
source-map: 0.6.1
dev: false
/@intlify/message-resolver/9.1.9:
resolution: {integrity: sha512-Lx/DBpigeK0sz2BBbzv5mu9/dAlt98HxwbG7xLawC3O2xMF9MNWU5FtOziwYG6TDIjNq0O/3ZbOJAxwITIWXEA==}
engines: {node: '>= 10'}
dev: false
/@intlify/runtime/9.1.9:
resolution: {integrity: sha512-XgPw8+UlHCiie3fI41HPVa/VDJb3/aSH7bLhY1hJvlvNV713PFtb4p4Jo+rlE0gAoMsMCGcsiT982fImolSltg==}
engines: {node: '>= 10'}
dependencies:
'@intlify/message-compiler': 9.1.9
'@intlify/message-resolver': 9.1.9
'@intlify/shared': 9.1.9
dev: false
/@intlify/shared/9.1.9:
resolution: {integrity: sha512-xKGM1d0EAxdDFCWedcYXOm6V5Pfw/TMudd6/qCdEb4tv0hk9EKeg7lwQF1azE0dP2phvx0yXxrt7UQK+IZjNdw==}
engines: {node: '>= 10'}
dev: false
/@intlify/vue-devtools/9.1.9:
resolution: {integrity: sha512-YPehH9uL4vZcGXky4Ev5qQIITnHKIvsD2GKGXgqf+05osMUI6WSEQHaN9USRa318Rs8RyyPCiDfmA0hRu3k7og==}
engines: {node: '>= 10'}
dependencies:
'@intlify/message-resolver': 9.1.9
'@intlify/runtime': 9.1.9
'@intlify/shared': 9.1.9
dev: false
/@istanbuljs/load-nyc-config/1.1.0:
resolution: {integrity: sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==}
engines: {node: '>=8'}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册