diff --git a/react-NutUI/src/app.js b/react-NutUI/src/app.ts similarity index 95% rename from react-NutUI/src/app.js rename to react-NutUI/src/app.ts index 3aadcb0..df71a70 100644 --- a/react-NutUI/src/app.js +++ b/react-NutUI/src/app.ts @@ -1,6 +1,6 @@ import React, { useEffect } from 'react' import { useDidShow, useDidHide } from '@tarojs/taro' -// 全局样式 + import './app.{{ cssExt }}' function App(props) { @@ -12,7 +12,6 @@ function App(props) { // 对应 onHide useDidHide(() => {}) - return props.children } diff --git a/react-NutUI/src/locales/base.ts b/react-NutUI/src/locales/base.ts new file mode 100644 index 0000000..ec4334f --- /dev/null +++ b/react-NutUI/src/locales/base.ts @@ -0,0 +1,140 @@ +export interface BaseLang { + welcome: string; + button: string; + open: string; + save: string; + confirm: string; + cancel: string; + done: string; + noData: string; + placeholder: string; + select: string; + video: { + errorTip: string; + clickRetry: string; + }; + fixednav: { + activeText: string; + inactiveText: string; + }; + infiniteloading: { + pullRefreshText: string; + loadText: string; + loadMoreText: string; + }; + pagination: { + prev: string; + next: string; + }; + range: { + rangeText: string; + }; + calendaritem: { + weekdays: Array; + end: string; + start: string; + confirm: string; + title: string; + // eslint-disable-next-line @typescript-eslint/ban-types + monthTitle: Function; + today: string; + loadPreviousMonth: string; + noEarlierMonth: string; + }; + shortpassword: { + title: string; + description: string; + tips: string; + }; + uploader: { + ready: string; + readyUpload: string; + waitingUpload: string; + uploading: string; + success: string; + error: string; + deleteWord: string; + }; + countdown: { + day: string; + hour: string; + minute: string; + second: string; + }; + address: { + selectRegion: string; + deliveryTo: string; + chooseAnotherAddress: string; + }; + signature: { + reSign: string; + unsupported: string; + }; + ecard: { + chooseText: string; + otherValueText: string; + placeholder: string; + }; + timeselect: { + pickupTime: string; + }; + sku: { + buyNow: string; + buyNumber: string; + addToCard: string; + }; + skuheader: { + skuId: string; + }; + addresslist: { + addAddress: string; + }; + comment: { + complaintsText: string; + // eslint-disable-next-line @typescript-eslint/ban-types + additionalReview: Function; + // eslint-disable-next-line @typescript-eslint/ban-types + additionalImages: Function; + }; + searchbar: { + basePlaceholder: string; + text: string; + test: string; + title1: string; + title2: string; + title3: string; + title4: string; + title5: string; + title6: string; + }; + audio: { + back: string; + forward: string; + pause: string; + start: string; + mute: string; + tips: string; + }; + datepicker: { + year: string; + month: string; + day: string; + hour: string; + min: string; + seconds: string; + }; + pullToRefresh: { + pullingText: string; + canReleaseText: string; + refreshingText: string; + completeText: string; + }; + tour: { + prevStepText: string; + completeText: string; + nextStepText: string; + }; + watermark: { + errorCanvasTips: string; + }; +} diff --git a/react-NutUI/src/locales/en-US.ts b/react-NutUI/src/locales/en-US.ts new file mode 100644 index 0000000..faee615 --- /dev/null +++ b/react-NutUI/src/locales/en-US.ts @@ -0,0 +1,139 @@ +import { BaseLang } from './base'; + +const enUS: BaseLang = { + welcome: 'Welcome to use NutUI React.', + button: 'Use Chinese', + open: 'Click Me', + save: 'Save', + confirm: 'Confirm', + cancel: 'Cancel', + done: 'Done', + noData: 'No Data', + placeholder: 'Placeholder', + select: 'Select', + video: { + errorTip: 'Error Tip', + clickRetry: 'Click Retry', + }, + fixednav: { + activeText: 'Close Nav', + inactiveText: 'Open Nav', + }, + infiniteloading: { + pullRefreshText: 'Pull Refresh', + loadText: 'Loading', + loadMoreText: "Oops, here's the bottom", + }, + pagination: { + prev: 'Previous', + next: 'Next', + }, + range: { rangeText: 'is overflow' }, + calendaritem: { + weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + end: 'End', + start: 'Start', + confirm: 'Confirm', + title: 'Calendar', + monthTitle: (year: number, month: number) => + `${year}/${Number(month) < 10 ? `0${Number(month)}` : month}`, + today: 'Today', + loadPreviousMonth: 'Load Previous Month', + noEarlierMonth: 'No Earlier Month', + }, + shortpassword: { + title: 'Please input a password', + description: 'Verify', + tips: 'Forget password', + }, + uploader: { + ready: 'Ready', + readyUpload: 'Ready to upload', + waitingUpload: 'Waiting for upload', + uploading: 'Uploading...', + success: 'Upload successful', + error: 'Upload failed', + deleteWord: 'The user blocked the deletion!', + }, + countdown: { + day: ' Day ', + hour: ' Hour ', + minute: ' Minute ', + second: ' Second ', + }, + address: { + selectRegion: 'Choose Address', + deliveryTo: 'Delivery To', + chooseAnotherAddress: 'Choose Another Address', + }, + signature: { + reSign: 'Re Sign', + unsupported: `Sorry, the current browser doesn't support canvas, so we can't use this control!`, + }, + ecard: { + chooseText: 'Select', + otherValueText: 'Other Value', + placeholder: 'Placeholder', + }, + timeselect: { + pickupTime: 'Pickup Time', + }, + sku: { + buyNow: 'Buy Now', + buyNumber: 'Buy Number', + addToCard: 'Add to Card', + }, + skuheader: { + skuId: 'Sku Number', + }, + addresslist: { + addAddress: 'Add New Address', + }, + comment: { + complaintsText: 'I have a complaint', + additionalReview: (day: number) => `Review after ${day} days of purchase`, + additionalImages: (length: number) => `There are ${length} follow-up comments`, + }, + searchbar: { + basePlaceholder: 'Go to jd.com and buy good things', + text: 'text', + test: 'test', + title1: 'basic usage', + title2: 'search box shape and maximum length', + title3: 'background settings inside and outside the search box', + title4: 'search box text settings', + title5: 'custom icon settings', + title6: 'data change monitoring', + }, + audio: { + back: 'fastBack', + forward: 'forward', + pause: 'pause', + start: 'start', + mute: 'mute', + tips: 'The onplayend event will only be triggered when loop = false', + }, + datepicker: { + year: 'Year', + month: 'Month', + day: 'Day', + hour: 'Hour', + min: 'Minute', + seconds: 'Second', + }, + pullToRefresh: { + pullingText: 'Pulling', + canReleaseText: 'Release to refresh', + refreshingText: 'Loading...', + completeText: 'Refresh successful', + }, + tour: { + prevStepText: 'Previous', + completeText: 'Finish', + nextStepText: 'Next step', + }, + watermark: { + errorCanvasTips: 'Canvas is not supported in the current environment', + }, +}; +export default enUS; diff --git a/react-NutUI/src/locales/zh-CN.ts b/react-NutUI/src/locales/zh-CN.ts new file mode 100644 index 0000000..cffc09d --- /dev/null +++ b/react-NutUI/src/locales/zh-CN.ts @@ -0,0 +1,141 @@ +import { BaseLang } from './base'; + +const zhCN: BaseLang = { + welcome: '欢迎使用 NutUI React。', + button: '使用英文', + open: '点击打开', + save: '保存', + confirm: '确认', + cancel: '取消', + done: '完成', + noData: '暂无数据', + placeholder: '请输入内容', + select: '请选择', + video: { + errorTip: '视频加载失败', + clickRetry: '点击重试', + }, + fixednav: { + activeText: '收起导航', + inactiveText: '快速导航', + }, + infiniteloading: { + pullRefreshText: '松开刷新', + loadText: '加载中', + loadMoreText: '没有更多了', + }, + pagination: { + prev: '上一页', + next: '下一页', + }, + range: { + rangeText: '不在该区间内', + }, + calendaritem: { + weekdays: ['日', '一', '二', '三', '四', '五', '六'], + end: '结束', + start: '开始', + confirm: '确认', + title: '日历选择', + monthTitle: (year: number, month: number) => + `${year}年${Number(month) < 10 ? `0${Number(month)}` : month}月`, + today: '今天', + loadPreviousMonth: '加载上一个月', + noEarlierMonth: '没有更早月份', + }, + shortpassword: { + title: '请输入密码', + description: '您使用了虚拟资产,请进行验证', + tips: '忘记密码', + }, + uploader: { + ready: '准备完成', + readyUpload: '准备上传', + waitingUpload: '等待上传', + uploading: '上传中...', + success: '上传成功', + error: '上传失败', + deleteWord: '用户阻止了删除!', + }, + countdown: { + day: '天', + hour: '时', + minute: '分', + second: '秒', + }, + address: { + selectRegion: '请选择地址', + deliveryTo: '配送至', + chooseAnotherAddress: '选择其他地址', + }, + signature: { + reSign: '重签', + unsupported: '对不起,当前浏览器不支持Canvas,无法使用本控件!', + }, + ecard: { + chooseText: '请选择电子卡面值', + otherValueText: '其他面值', + placeholder: '请输入1-5000整数', + }, + timeselect: { + pickupTime: '取件时间', + }, + sku: { + buyNow: '立即购买', + buyNumber: '购买数量', + addToCard: '加入购物车', + }, + skuheader: { + skuId: '商品编号', + }, + addresslist: { + addAddress: '新建地址', + }, + comment: { + complaintsText: '我要投诉', + additionalReview: (day: number) => `购买${day}天后追评`, + additionalImages: (length: number) => `${length}张追评图片`, + }, + searchbar: { + basePlaceholder: '上京东,购好物', + text: '文本', + test: '测试', + title1: '基础用法', + title2: '搜索框形状及最大长度', + title3: '搜索框内外背景设置', + title4: '搜索框文本设置', + title5: '自定义图标设置', + title6: '数据改变监听', + }, + audio: { + back: '快退', + forward: '快进', + pause: '暂停', + start: '开始', + mute: '静音', + tips: 'onPlayEnd事件在loop=false时才会触发', + }, + datepicker: { + year: '年', + month: '月', + day: '日', + hour: '时', + min: '分', + seconds: '秒', + }, + pullToRefresh: { + pullingText: '下拉刷新', + canReleaseText: '松手刷新', + refreshingText: '刷新中', + completeText: '刷新成功', + }, + tour: { + prevStepText: '上一步', + completeText: '完成', + nextStepText: '下一步', + }, + watermark: { + errorCanvasTips: '当前环境不支持Canvas', + }, +}; +export default zhCN; diff --git a/react-NutUI/src/pages/index/index.css b/react-NutUI/src/pages/demo/index.css similarity index 100% rename from react-NutUI/src/pages/index/index.css rename to react-NutUI/src/pages/demo/index.css diff --git a/react-NutUI/src/pages/demo/index.tsx b/react-NutUI/src/pages/demo/index.tsx new file mode 100644 index 0000000..c5174ce --- /dev/null +++ b/react-NutUI/src/pages/demo/index.tsx @@ -0,0 +1,31 @@ +import React, { useState } from "react"; +import { View } from "@tarojs/components"; +import { Button, TextArea, Dialog } from "@nutui/nutui-react-taro"; +import './index.{{ cssExt }}' +function Demo({ locale, handleSwitchLocale }) { + const [visible, setVisible] = useState(false); + return ( + + {locale.welcome} + + + + setVisible(false)} + onCancel={() => setVisible(false)} + > + {locale.welcome} + +