update runtime
This commit is contained in:
parent
154e015fa5
commit
6d2ba85204
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,3 +13,5 @@ node_modules/
|
||||
.umi
|
||||
.umi-production
|
||||
/docs/dist
|
||||
dist
|
||||
/packages/runtime/dist
|
||||
|
@ -1,51 +0,0 @@
|
||||
version: '1.0'
|
||||
name: branch-pipeline
|
||||
displayName: BranchPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@nodejs
|
||||
name: build_nodejs
|
||||
displayName: Nodejs 构建
|
||||
# 支持8.16.2、10.17.0、12.16.1、14.16.0、15.12.0五个版本
|
||||
nodeVersion: 14.16.0
|
||||
# 构建命令:安装依赖 -> 清除上次打包产物残留 -> 执行构建 【请根据项目实际产出进行填写】
|
||||
commands:
|
||||
- npm install && rm -rf ./dist && npm run build
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
|
||||
path:
|
||||
- ./dist
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_nodejs
|
||||
- stage:
|
||||
name: release
|
||||
displayName: 发布
|
||||
steps:
|
||||
- step: publish@release_artifacts
|
||||
name: publish_release_artifacts
|
||||
displayName: '发布'
|
||||
# 上游上传制品任务的产出
|
||||
dependArtifact: output
|
||||
# 发布制品版本号
|
||||
version: '1.0.0.0'
|
||||
# 是否开启版本号自增,默认开启
|
||||
autoIncrement: true
|
||||
triggers:
|
||||
push:
|
||||
branches:
|
||||
exclude:
|
||||
- master
|
||||
include:
|
||||
- .*
|
@ -1,49 +0,0 @@
|
||||
version: '1.0'
|
||||
name: master-pipeline
|
||||
displayName: MasterPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@nodejs
|
||||
name: build_nodejs
|
||||
displayName: Nodejs 构建
|
||||
# 支持8.16.2、10.17.0、12.16.1、14.16.0、15.12.0五个版本
|
||||
nodeVersion: 14.16.0
|
||||
# 构建命令:安装依赖 -> 清除上次打包产物残留 -> 执行构建 【请根据项目实际产出进行填写】
|
||||
commands:
|
||||
- npm install && rm -rf ./dist && npm run build
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
|
||||
path:
|
||||
- ./dist
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_nodejs
|
||||
- stage:
|
||||
name: release
|
||||
displayName: 发布
|
||||
steps:
|
||||
- step: publish@release_artifacts
|
||||
name: publish_release_artifacts
|
||||
displayName: '发布'
|
||||
# 上游上传制品任务的产出
|
||||
dependArtifact: output
|
||||
# 发布制品版本号
|
||||
version: '1.0.0.0'
|
||||
# 是否开启版本号自增,默认开启
|
||||
autoIncrement: true
|
||||
triggers:
|
||||
push:
|
||||
branches:
|
||||
include:
|
||||
- master
|
@ -1,36 +0,0 @@
|
||||
version: '1.0'
|
||||
name: pr-pipeline
|
||||
displayName: PRPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@nodejs
|
||||
name: build_nodejs
|
||||
displayName: Nodejs 构建
|
||||
# 支持8.16.2、10.17.0、12.16.1、14.16.0、15.12.0五个版本
|
||||
nodeVersion: 14.16.0
|
||||
# 构建命令:安装依赖 -> 清除上次打包产物残留 -> 执行构建 【请根据项目实际产出进行填写】
|
||||
commands:
|
||||
- npm install && rm -rf ./dist && npm run build
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
|
||||
path:
|
||||
- ./dist
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_nodejs
|
||||
triggers:
|
||||
pr:
|
||||
branches:
|
||||
include:
|
||||
- master
|
@ -1,11 +1,11 @@
|
||||
# 版本信息
|
||||
| 包| 版本号| 最后更新|说明|
|
||||
| --- | :---:| --- |---|
|
||||
|**@voerkai18n/utils**|1.0.12|08/05|公共工具库
|
||||
|**@voerkai18n/runtime**|1.0.27|08/05|核心运行时
|
||||
|**@voerkai18n/formatters**|1.0.6|04/15|格式化器,提供对要翻译文本的转换功能
|
||||
|**@voerkai18n/react**|1.0.4|04/16|React支持,提供语言切换等功能
|
||||
|**@voerkai18n/cli**|1.0.32|08/05|命令行工具,用来初始化/提取/编译/自动翻译等工具链
|
||||
|**@voerkai18n/babel**|1.0.23|08/05|Babel插件,实现自动导入t函数和自动文本映射
|
||||
|**@voerkai18n/vite**|1.0.12|08/05|Vite插件,提供自动插入翻译函数和文本映射等功能
|
||||
|**@voerkai18n/vue**|1.0.5|04/15|Vue3插件,提供自动插件翻译函数和语言切换功能
|
||||
|**@voerkai18n/utils**|1.0.12|2022/08/05|公共工具库
|
||||
|**@voerkai18n/runtime**|1.0.28|2022/08/07|核心运行时
|
||||
|**@voerkai18n/formatters**|1.0.6|2022/04/15|格式化器,提供对要翻译文本的转换功能
|
||||
|**@voerkai18n/react**|1.0.4|2022/04/16|React支持,提供语言切换等功能
|
||||
|**@voerkai18n/cli**|1.0.33|2022/08/07|命令行工具,用来初始化/提取/编译/自动翻译等工具链
|
||||
|**@voerkai18n/babel**|1.0.23|2022/08/05|Babel插件,实现自动导入t函数和自动文本映射
|
||||
|**@voerkai18n/vite**|1.0.12|2022/08/05|Vite插件,提供自动插入翻译函数和文本映射等功能
|
||||
|**@voerkai18n/vue**|1.0.5|2022/04/15|Vue3插件,提供自动插件翻译函数和语言切换功能
|
@ -4,7 +4,6 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build:runtime": "pnpm build --filter \"@voerkai18n/runtime\"",
|
||||
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules node node_modules/jest/bin/jest.js ",
|
||||
"test:app": "cross-env NODE_OPTIONS=--experimental-vm-modules node node_modules/jest/bin/jest.js -- app",
|
||||
"list:package": "node ./packages/autopublish/index.js list",
|
||||
|
@ -1,7 +1,14 @@
|
||||
const i18nPlugin =require("@voerkai18n/babel")
|
||||
module.exports = {
|
||||
presets: [
|
||||
"@babel/preset-env"
|
||||
"@babel/preset-env",
|
||||
{
|
||||
corejs: {
|
||||
useBuiltIns: 'entry',
|
||||
version: "3.8",
|
||||
proposals: true
|
||||
}
|
||||
}
|
||||
],
|
||||
plugins: [
|
||||
[
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"3": "全世界迎接中华民族的伟大复兴!"
|
||||
"3": "全世界迎接中华民族的伟大复兴!!!"
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ import {reactive } from 'vue'
|
||||
// This starter template is using Vue 3 <script setup> SFCs
|
||||
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
|
||||
import China from './components/china.vue'
|
||||
import Formatters from './components/formatters.vue'
|
||||
|
||||
let messages = reactive({
|
||||
name: t('VoerkaI18n多语言解决方案 ')
|
||||
@ -39,15 +40,18 @@ export default {
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<img alt="Vue logo" src="./assets/logo.png" />
|
||||
<h1>{{ t("中华人民共和国")}} </h1>
|
||||
<h2>{{ t("迎接中华民族的伟大复兴")}} </h2>
|
||||
<China :title="t('中华人民共和国')" />
|
||||
<h5>默认语言:{{ i18n.defaultLanguage }}</h5>
|
||||
<h5>当前语言:{{ i18n.activeLanguage.value }}</h5>
|
||||
<button v-for="lng of i18n.languages" @click="i18n.activeLanguage = lng.name" style="padding:8px;margin:8px;cursor:pointer" :style="{'outline' : lng.name === i18n.activeLanguage.value ? '2px red solid' : ''}" >{{ lng.title }}</button>
|
||||
<button @click="i18n.activeLanguage = 'de'" style="padding:8px;margin:8px;cursor:pointer" :style="{'outline' : i18n.activeLanguage.value === 'de' ? '2px red solid' : ''}" >德语</button>
|
||||
<button @click="i18n.activeLanguage = 'jp'" style="padding:8px;margin:8px;cursor:pointer" :style="{'outline' : i18n.activeLanguage.value === 'jp' ? '2px red solid' : ''}" >日语</button>
|
||||
<div>
|
||||
<img alt="Vue logo" src="./assets/logo.png" />
|
||||
<h1>{{ t("中华人民共和国")}} </h1>
|
||||
<h2>{{ t("迎接中华民族的伟大复兴")}} </h2>
|
||||
<China :title="t('中华人民共和国')" />
|
||||
<Formatters/>
|
||||
<h5>默认语言:{{ i18n.defaultLanguage }}</h5>
|
||||
<h5>当前语言:{{ i18n.activeLanguage.value }}</h5>
|
||||
<button :key="lng.name" v-for="lng of i18n.languages" @click="i18n.activeLanguage = lng.name" style="padding:8px;margin:8px;cursor:pointer" :style="{'outline' : lng.name === i18n.activeLanguage.value ? '2px red solid' : ''}" >{{ lng.title }}</button>
|
||||
<button @click="i18n.activeLanguage = 'de'" style="padding:8px;margin:8px;cursor:pointer" :style="{'outline' : i18n.activeLanguage.value === 'de' ? '2px red solid' : ''}" >德语</button>
|
||||
<button @click="i18n.activeLanguage = 'jp'" style="padding:8px;margin:8px;cursor:pointer" :style="{'outline' : i18n.activeLanguage.value === 'jp' ? '2px red solid' : ''}" >日语</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
|
33
packages/apps/vueapp/src/components/formatters.vue
Normal file
33
packages/apps/vueapp/src/components/formatters.vue
Normal file
@ -0,0 +1,33 @@
|
||||
<script setup>
|
||||
defineProps({
|
||||
title: String
|
||||
})
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
date1: new Date(),
|
||||
date2: "2022/12/3 19:08:12",
|
||||
date3: 1659872118897,
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div style="padding:16px;border:1px red solid;line-height:120%;margin:0 auto;margin-bottom:16px;width:600px;">
|
||||
<p>{{ t("现在是{ value | date }",date1)}} </p>
|
||||
<p>{{ t("现在是{ value | date }",date2)}} </p>
|
||||
<p>{{ t("现在是{ value | date }",date3)}} </p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
@ -59,7 +59,7 @@ export default{
|
||||
$types:{
|
||||
|
||||
},
|
||||
cn:{
|
||||
zh:{
|
||||
$types:{
|
||||
// 所有类型的默认格式化器
|
||||
// "*":{
|
||||
|
@ -366,7 +366,8 @@ function generatePackageVersionDoc(){
|
||||
const lastPublish = package.lastPublish ? dayjs(package.lastPublish).format("YYYY/MM/DD") : "None"
|
||||
results.push(`|**${package.name}**|${package.version}|${lastPublish}|${package.description}`)
|
||||
})
|
||||
fs.writeFileSync(path.join(workspaceRoot,"docs/zh/guide/intro/versions.md"), results.join("\n"))
|
||||
|
||||
fs.writeFileSync(path.join(workspaceRoot,"docs/src/guide/intro/versions.md"), results.join("\n"))
|
||||
}
|
||||
|
||||
async function answerForSelectPackages(packages,options){
|
||||
|
@ -157,7 +157,7 @@ var scope = class i18nScope {
|
||||
}
|
||||
this.global = globalThis.VoerkaI18n;
|
||||
this._mergePatchedMessages();
|
||||
this._patch(this._messages,newLanguage);
|
||||
this._patch(this._messages,this.activeLanguage);
|
||||
// 正在加载语言包标识
|
||||
this._loading=false;
|
||||
// 在全局注册作用域
|
||||
@ -362,20 +362,28 @@ var formatters = {
|
||||
$types:{
|
||||
Date:(value)=>value.toLocaleString()
|
||||
},
|
||||
// 日期
|
||||
date: (value)=> value.toLocaleDateString(),
|
||||
shortdate: (value)=> `${value.getFullYear()}-${value.getMonth()+1}-${value.getDate()}`,
|
||||
|
||||
// 时间
|
||||
time:(value)=> value.toLocaleTimeString(),
|
||||
shorttime:(value)=> value.toLocaleTimeString(),
|
||||
date: (value)=> value.toLocaleDateString(),
|
||||
|
||||
dict, //字典格式化器
|
||||
},
|
||||
zh:{
|
||||
$types:{
|
||||
Date:(value)=> `${value.getFullYear()}年${value.getMonth()+1}月${value.getDate()}日 ${value.getHours()}点${value.getMinutes()}分${value.getSeconds()}秒`
|
||||
},
|
||||
shortime:(value)=> value.toLocaleTimeString(),
|
||||
time:(value)=>`${value.getHours()}点${value.getMinutes()}分${value.getSeconds()}秒`,
|
||||
// 日期
|
||||
date: (value)=> `${value.getFullYear()}年${value.getMonth()+1}月${value.getDate()}日`,
|
||||
shortdate: (value)=> `${value.getFullYear()}-${value.getMonth()+1}-${value.getDate()}`,
|
||||
currency:(value)=>`${value}元`,
|
||||
// 时间
|
||||
shortime:(value)=> value.toLocaleTimeString(),
|
||||
time:(value)=>`${value.getHours()}点${value.getMinutes()}分${value.getSeconds()}秒`,
|
||||
// 货币
|
||||
currency:(value)=>`¥${value}元`,
|
||||
},
|
||||
en:{
|
||||
currency:(value)=>{
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@voerkai18n/cli",
|
||||
"version": "1.0.32",
|
||||
"version": "1.0.33",
|
||||
"description": "命令行工具,用来初始化/提取/编译/自动翻译等工具链",
|
||||
"main": "index.js",
|
||||
"homepage": "https://gitee.com/zhangfisher/voerka-i18n",
|
||||
@ -50,5 +50,5 @@
|
||||
"devDependencies": {
|
||||
"@voerkai18n/autopublish": "workspace:^1.0.2"
|
||||
},
|
||||
"lastPublish": "2022-08-05T16:45:44+08:00"
|
||||
"lastPublish": "2022-08-07T19:16:38+08:00"
|
||||
}
|
@ -45,20 +45,28 @@ module.exports = {
|
||||
$types:{
|
||||
Date:(value)=>value.toLocaleString()
|
||||
},
|
||||
// 日期
|
||||
date: (value)=> value.toLocaleDateString(),
|
||||
shortdate: (value)=> `${value.getFullYear()}-${value.getMonth()+1}-${value.getDate()}`,
|
||||
|
||||
// 时间
|
||||
time:(value)=> value.toLocaleTimeString(),
|
||||
shorttime:(value)=> value.toLocaleTimeString(),
|
||||
date: (value)=> value.toLocaleDateString(),
|
||||
|
||||
dict, //字典格式化器
|
||||
},
|
||||
zh:{
|
||||
$types:{
|
||||
Date:(value)=> `${value.getFullYear()}年${value.getMonth()+1}月${value.getDate()}日 ${value.getHours()}点${value.getMinutes()}分${value.getSeconds()}秒`
|
||||
},
|
||||
shortime:(value)=> value.toLocaleTimeString(),
|
||||
time:(value)=>`${value.getHours()}点${value.getMinutes()}分${value.getSeconds()}秒`,
|
||||
// 日期
|
||||
date: (value)=> `${value.getFullYear()}年${value.getMonth()+1}月${value.getDate()}日`,
|
||||
shortdate: (value)=> `${value.getFullYear()}-${value.getMonth()+1}-${value.getDate()}`,
|
||||
currency:(value)=>`${value}元`,
|
||||
// 时间
|
||||
shortime:(value)=> value.toLocaleTimeString(),
|
||||
time:(value)=>`${value.getHours()}点${value.getMinutes()}分${value.getSeconds()}秒`,
|
||||
// 货币
|
||||
currency:(value)=>`¥${value}元`,
|
||||
},
|
||||
en:{
|
||||
currency:(value)=>{
|
||||
|
@ -427,6 +427,26 @@ function getPluraMessage(messages,value){
|
||||
return Array.isArray(messages) ? messages[0] : messages
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if(!String.prototype.replaceAll){
|
||||
// String.prototype.replaceAll = function(searchValue,replaceValue){
|
||||
// if (!searchValue) return this
|
||||
// if(typeof(searchValue)==="string"){
|
||||
// return this.replace(new RegExp(searchValue,"gm"),replaceValue);
|
||||
// }else if (searchValue instanceof RegExp) {
|
||||
// const { global: globalFlag } = searchValue;
|
||||
// if (!globalFlag) {
|
||||
// throw new TypeError(
|
||||
// '`String.prototype.replaceAll` ponyfill called with a non-global RegExp argument'
|
||||
// );
|
||||
// }
|
||||
// return this.replace(searchValue, replaceValue);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
function escape(str){
|
||||
return str.replaceAll(/\\(?![trnbvf'"]{1})/g,"\\\\")
|
||||
.replaceAll("\t","\\t")
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@voerkai18n/runtime",
|
||||
"version": "1.0.27",
|
||||
"version": "1.0.28",
|
||||
"description": "核心运行时",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "dist/index.esm.js",
|
||||
@ -35,5 +35,5 @@
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"@voerkai18n/autopublish": "workspace:^1.0.2"
|
||||
},
|
||||
"lastPublish": "2022-08-05T16:36:41+08:00"
|
||||
"lastPublish": "2022-08-07T19:16:27+08:00"
|
||||
}
|
@ -34,7 +34,7 @@ module.exports = class i18nScope {
|
||||
}
|
||||
this.global = globalThis.VoerkaI18n
|
||||
this._mergePatchedMessages()
|
||||
this._patch(this._messages,newLanguage)
|
||||
this._patch(this._messages,this.activeLanguage)
|
||||
// 正在加载语言包标识
|
||||
this._loading=false
|
||||
// 在全局注册作用域
|
||||
|
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@ -19,6 +19,7 @@ importers:
|
||||
inquirer: ^8.2.2
|
||||
jest: ^27.5.1
|
||||
logsets: ^1.0.8
|
||||
pnpm: ^7.8.0
|
||||
prettier: ^2.2.1
|
||||
rollup: ^2.70.1
|
||||
rollup-plugin-clear: ^2.0.7
|
||||
@ -42,6 +43,7 @@ importers:
|
||||
gulp: 4.0.2
|
||||
jest: 27.5.1
|
||||
logsets: 1.0.12
|
||||
pnpm: 7.9.0
|
||||
prettier: 2.7.1
|
||||
rollup: 2.77.2
|
||||
rollup-plugin-clear: 2.0.7
|
||||
@ -8858,6 +8860,12 @@ packages:
|
||||
find-up: 4.1.0
|
||||
dev: true
|
||||
|
||||
/pnpm/7.9.0:
|
||||
resolution: {integrity: sha512-xkIVw73yJm/h5M4VvFIS5Q+gQCRDrp3r92g58PtcCK86aZCa7EQ6q6ivdfTAz0KsAVgloA6Anub28n6wju5v3w==}
|
||||
engines: {node: '>=14.6'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/posix-character-classes/0.1.1:
|
||||
resolution: {integrity: sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
Loading…
x
Reference in New Issue
Block a user