(date-picker): i18n support

This commit is contained in:
就眠儀式 2022-10-22 22:36:33 +08:00
parent 261853cf00
commit 464b1045da
7 changed files with 84 additions and 31 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@layui/layui-vue",
"version": "1.7.0-dev.19",
"version": "1.7.0-dev.20",
"author": "就眠儀式",
"license": "MIT",
"description": "a component library for Vue 3 base on layui-vue",
@ -36,13 +36,13 @@
"@layui/icons-vue": "^1.0.9",
"@layui/layer-vue": "^1.4.6",
"@vueuse/core": "^9.2.0",
"@umijs/ssr-darkreader": "^4.9.45",
"@ctrl/tinycolor": "^3.4.1",
"async-validator": "^4.1.1",
"cropperjs": "^1.5.12",
"@umijs/ssr-darkreader": "^4.9.45",
"dayjs": "^1.11.0",
"evtd": "^0.2.3",
"vue-i18n": "^9.1.10",
"@ctrl/tinycolor": "^3.4.1"
"vue-i18n": "^9.1.10"
},
"files": [
"lib",

View File

@ -17,8 +17,7 @@
>{{ datePicker.currentYear.value }} {{ t("datePicker.year") }}</span
>
<span @click="datePicker.showPanel.value = 'month'"
>{{ datePicker.currentMonth.value + 1 }}
{{ t("datePicker.month") }}</span
> {{ MONTH_NAME[datePicker.currentMonth.value] }} </span
>
</div>
<i
@ -55,7 +54,7 @@ export default {
};
</script>
<script lang="ts" setup>
import { inject, ref, watch } from "vue";
import { computed, inject, ref, watch } from "vue";
import { provideType } from "../interface";
import { setDateList } from "../day";
import PanelFoot from "./PanelFoot.vue";
@ -74,6 +73,21 @@ const Day = ref(props.modelValue);
const datePicker: provideType = inject("datePicker") as provideType;
const dateList = ref<any>([]);
const MONTH_NAME = computed(() => [
t('datePicker.january'),
t('datePicker.february'),
t('datePicker.march'),
t('datePicker.april'),
t('datePicker.may'),
t('datePicker.june'),
t('datePicker.july'),
t('datePicker.august'),
t('datePicker.september'),
t('datePicker.october'),
t('datePicker.november'),
t('datePicker.december'),
]);
// ,
watch(
[datePicker.currentYear, datePicker.currentMonth],

View File

@ -5,7 +5,7 @@
<div class="laydate-set-ym">
<span @click="datePicker.showPanel.value = 'month'">{{
typeof Month !== "string"
? Month + 1 + t("datePicker.month")
? MONTH_NAME[Month]
: t("datePicker.selectMonth")
}}</span>
</div>
@ -41,7 +41,7 @@ export default {
<script lang="ts" setup>
import dayjs from "dayjs";
import { useI18n } from "../../../language";
import { inject, ref, watch } from "vue";
import { computed, inject, ref, watch } from "vue";
import { provideType } from "../interface";
import PanelFoot from "./PanelFoot.vue";
@ -57,32 +57,33 @@ const datePicker: provideType = inject("datePicker") as provideType;
const Month = ref(props.modelValue);
const { t } = useI18n();
const MONTH_NAME = [
"1月",
"2月",
"3月",
"4月",
"5月",
"6月",
"7月",
"8月",
"9月",
"10月",
"11月",
"12月",
];
const MONTH_NAME = computed(() => [
t('datePicker.january'),
t('datePicker.february'),
t('datePicker.march'),
t('datePicker.april'),
t('datePicker.may'),
t('datePicker.june'),
t('datePicker.july'),
t('datePicker.august'),
t('datePicker.september'),
t('datePicker.october'),
t('datePicker.november'),
t('datePicker.december'),
]);
//
const handleMonthClick = (item: any) => {
Month.value = MONTH_NAME.indexOf(item);
Month.value = MONTH_NAME.value.indexOf(item);
if (!datePicker.range) {
if (datePicker.type === "yearmonth") {
datePicker.currentDay.value = dayjs(datePicker.currentDay.value)
.month(MONTH_NAME.indexOf(item))
.month(MONTH_NAME.value.indexOf(item))
.valueOf();
}
if (datePicker.type === "date" || datePicker.type === "datetime") {
emits("update:modelValue", MONTH_NAME.indexOf(item));
emits("update:modelValue", MONTH_NAME.value.indexOf(item));
datePicker.showPanel.value = datePicker.type;
}
}

View File

@ -45,7 +45,8 @@ export default {
};
</script>
<script lang="ts" setup>
import { computed, inject, ref, Ref } from "vue";
import { useI18n } from "../../../../language";
import { computed, inject } from "vue";
import { provideType } from "../../interface";
export interface DateContentProps {
@ -63,8 +64,21 @@ const props = withDefaults(defineProps<DateContentProps>(), {
startDate: -1,
endDate: -1,
});
const WEEK_NAME = ["日", "一", "二", "三", "四", "五", "六"];
const { t } = useI18n();
const WEEK_NAME = computed(() => [
t('datePicker.sunday'),
t('datePicker.monday'),
t('datePicker.tuesday'),
t('datePicker.wednesday'),
t('datePicker.thursday'),
t('datePicker.friday'),
t('datePicker.saturday')
]);
const datePicker: provideType = inject("datePicker") as provideType;
const emits = defineEmits([
"update:modelValue",
"update:startDate",

View File

@ -9,10 +9,10 @@ export default {
confirm: "confirm",
page: "page",
item: "item",
total: "Total",
total: "total",
},
datePicker: {
year: "year",
year: "",
month: "month",
sunday: "SU",
monday: "MO",
@ -21,6 +21,18 @@ export default {
thursday: "TH",
friday: "FR",
saturday: "SA",
january: "January",
february: "February",
march: "March",
april: "April",
may: "May",
june: "June",
july: "July",
august: "August",
september: "September",
october: "October",
november: "November",
december: "December",
selectDate: "select date",
selectTime: "select time",
selectYear: "select year",

View File

@ -21,6 +21,18 @@ export default {
thursday: "四",
friday: "五",
saturday: "六",
january: "1月",
february: "2月",
march: "3月",
april: "4月",
may: "5月",
june: "6月",
july: "7月",
august: "8月",
september: "9月",
october: "10月",
november: "11月",
december: "12月",
selectDate: "选择日期",
selectTime: "选择时间",
selectYear: "选择年份",

View File

@ -24,7 +24,7 @@ layui - vue谐音类 UI) 是 一 套 Vue 3.0 的 桌 面 端 组 件 库 ,
:::
<lay-timeline>
<lay-timeline-item title="2022layui-vue 里程碑版本 1.0.0 发布" simple></lay-timeline-item>
<lay-timeline-item title="2021layui-vue 里程碑版本 1.0.0 发布" simple></lay-timeline-item>
<lay-timeline-item title="2017年layui 里程碑版本 2.0 发布" simple></lay-timeline-item>
<lay-timeline-item title="2016年layui 首个版本发布" simple></lay-timeline-item>
<lay-timeline-item title="2015年layui 孵化" simple></lay-timeline-item>