diff --git a/examples/i18n/en.js b/examples/i18n/en.js
index 2a88d614..db414c03 100644
--- a/examples/i18n/en.js
+++ b/examples/i18n/en.js
@@ -40,6 +40,25 @@ export default {
},
verifyErrorPromptTitle: 'Notice'
},
+ laydate: {
+ month: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
+ weeks: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
+ time: ['Hour', 'Minute', 'Second'],
+ selectDate: 'Select Date',
+ selectTime: 'Select Time',
+ startTime: 'Start Time',
+ endTime: 'End Time',
+ tools: {
+ confirm: 'Confirm',
+ clear: 'Clear',
+ now: 'Now',
+ reset: 'Reset'
+ },
+ timeout: 'End time cannot be less than start Time
Please re-select',
+ invalidDate: 'Invalid date',
+ formatError: ['The date format error
Must be followed:
', '
It has been reset'],
+ preview: 'The selected result'
+ },
layer: {
confirm: 'OK',
cancel: 'Cancel',
diff --git a/examples/i18n/fr.js b/examples/i18n/fr.js
index 7b88dd1d..7d0a0f72 100644
--- a/examples/i18n/fr.js
+++ b/examples/i18n/fr.js
@@ -39,6 +39,26 @@ export default {
},
verifyErrorPromptTitle: 'Avertissement'
},
+ laydate: {
+ month: ['Janv', 'Févr', 'Mars', 'Avr', 'Mai', 'Juin', 'Juil', 'Août', 'Sept', 'Oct', 'Nov', 'Déc'],
+ weeks: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
+ time: ['Heure', 'Minute', 'Seconde'],
+ selectDate: 'Sélec. date',
+ selectTime: 'Sélec. heure',
+ startTime: 'Heure de début',
+ endTime: 'Heure de fin',
+ // Recommandé en version abrégée en raison de l’espace limité du composant
+ tools: {
+ confirm: 'OK',
+ clear: 'Eff.',
+ now: 'Ajd.',
+ reset: 'Réinit.'
+ },
+ timeout: 'L’heure de fin ne peut pas être antérieure à l’heure de début
Veuillez recommencer',
+ invalidDate: 'Date ou heure hors plage valide',
+ formatError: ['Format de date invalide
Le format attendu est :
', '
Il a été réinitialisé pour vous'],
+ preview: 'Résultat sélectionné actuel'
+ },
layer: {
confirm: 'Confirmer',
cancel: 'Annuler',
diff --git a/examples/i18n/zh-HK.js b/examples/i18n/zh-HK.js
index b88c4d72..1b3cc7ba 100644
--- a/examples/i18n/zh-HK.js
+++ b/examples/i18n/zh-HK.js
@@ -39,6 +39,25 @@ export default {
},
verifyErrorPromptTitle: '提示'
},
+ laydate: {
+ month: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
+ weeks: ['日', '一', '二', '三', '四', '五', '六'],
+ time: ['時', '分', '秒'],
+ selectDate: '選擇日期',
+ selectTime: '選擇時間',
+ startTime: '開始時間',
+ endTime: '結束時間',
+ tools: {
+ confirm: '確定',
+ clear: '清除',
+ now: '現在',
+ reset: '重設'
+ },
+ timeout: '結束時間不能早於開始時間
請重新選擇',
+ invalidDate: '不在有效日期或時間範圍內',
+ formatError: ['日期格式不合法
必須遵循以下格式:
', '
已為你重設'],
+ preview: '當前選中的結果'
+ },
layer: {
confirm: '確定',
cancel: '取消',
diff --git a/src/css/modules/laydate.css b/src/css/modules/laydate.css
index 065f8b79..1d7facca 100644
--- a/src/css/modules/laydate.css
+++ b/src/css/modules/laydate.css
@@ -46,6 +46,7 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;}
.layui-laydate-header i.laydate-prev-m{left: 45px;}
.layui-laydate-header i.laydate-next-y{right: 15px;}
.layui-laydate-header i.laydate-next-m{right: 45px;}
+.laydate-time-show .layui-laydate-header{padding-left: 10px; padding-right: 10px;}
.laydate-set-ym{width: 100%; text-align: center; box-sizing: border-box; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;}
.laydate-set-ym span{padding: 0 10px; cursor: pointer;}
.laydate-time-text{cursor: default !important;}
diff --git a/src/modules/i18n.js b/src/modules/i18n.js
index 662133d5..413dfb0b 100644
--- a/src/modules/i18n.js
+++ b/src/modules/i18n.js
@@ -52,6 +52,25 @@ layui.define('lay', function(exports) {
},
verifyErrorPromptTitle: '提示'
},
+ laydate: {
+ month: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'],
+ weeks: ['日', '一', '二', '三', '四', '五', '六'],
+ time: ['时', '分', '秒'],
+ selectDate: '选择日期',
+ selectTime: '选择时间',
+ startTime: '开始时间',
+ endTime: '结束时间',
+ tools: {
+ confirm: '确定',
+ clear: '清空',
+ now: '现在',
+ reset: '重置'
+ },
+ timeout: '结束时间不能早于开始时间
请重新选择',
+ invalidDate: '不在有效日期或时间范围内',
+ formatError: ['日期格式不合法
必须遵循下述格式:
', '
已为你重置'],
+ preview: '当前选中的结果'
+ },
layer: {
confirm: '确定',
cancel: '取消',
diff --git a/src/modules/laydate.js b/src/modules/laydate.js
index b54a64e6..8f9c77f5 100644
--- a/src/modules/laydate.js
+++ b/src/modules/laydate.js
@@ -179,34 +179,20 @@ layui.define(['lay', 'i18n'], function(exports) {
Class.prototype.lang = function() {
var that = this;
var options = that.config;
+ var locale = i18n.config.locale.replace(/^\s+|\s+$/g, '');
+ var messages = i18n.config.messages;
+ var message = messages[locale];
var text = {
- cn: {
- month: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'],
- weeks: ['日', '一', '二', '三', '四', '五', '六'],
- time: ['时', '分', '秒'],
- selectTime: '选择时间',
- startTime: '开始时间',
- endTime: '结束时间',
- selectDate: '选择日期',
- tools: {
- confirm: '确定',
- clear: '清空',
- now: '现在',
- reset: '重置'
- },
- timeout: '结束时间不能早于开始时间
请重新选择',
- invalidDate: '不在有效日期或时间范围内',
- formatError: ['日期格式不合法
必须遵循下述格式:
', '
已为你重置'],
- preview: '当前选中的结果'
- },
+ cn: messages['zh-CN'].laydate,
+ // 保留原版 en
en: {
month: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
weeks: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
- time: ['Hours', 'Minutes', 'Seconds'],
+ time: ['Hour', 'Minute', 'Second'],
+ selectDate: 'Select Date',
selectTime: 'Select Time',
startTime: 'Start Time',
endTime: 'End Time',
- selectDate: 'Select Date',
tools: {
confirm: 'Confirm',
clear: 'Clear',
@@ -220,10 +206,20 @@ layui.define(['lay', 'i18n'], function(exports) {
}
};
- // 临时代码
- var locale = i18n.config.locale;
- if (options.lang === 'cn' && locale !== 'zh-CN') {
- options.lang = 'en';
+ // 若 lang 选项未明确传入 en,则取 i18n locale
+ if (options.lang !== 'en') {
+ options.lang = locale === 'zh-CN' ? 'cn' : locale;
+ }
+
+ // 同步消息配置
+ if (message) {
+ // 若 locale 为英文系列,且外部未配置 laydate 消息,则读取上述内置 en 配置
+ if (/^en(?:-[a-z]{2,})?$/i.test(locale)) {
+ if (!message.laydate) {
+ message.laydate = text['en'];
+ }
+ }
+ text[locale] = message.laydate;
}
return text[options.lang] || text['cn'];