@campus-admin/locale 1.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,165 @@
1
+ /** 框架内置词条(中文)。键必须与 en-US 成对,后续由检查脚本保证。 */
2
+ export declare const zhCN: {
3
+ campus: {
4
+ notify: {
5
+ success: string;
6
+ info: string;
7
+ warning: string;
8
+ error: string;
9
+ };
10
+ common: {
11
+ ok: string;
12
+ cancel: string;
13
+ confirm: string;
14
+ tip: string;
15
+ loading: string;
16
+ };
17
+ login: {
18
+ title: string;
19
+ username: string;
20
+ password: string;
21
+ submit: string;
22
+ failed: string;
23
+ required: string;
24
+ };
25
+ auth: {
26
+ tabAccount: string;
27
+ tabWechat: string;
28
+ tabRegister: string;
29
+ tabForgot: string;
30
+ backLogin: string;
31
+ accountPlaceholder: string;
32
+ passwordPlaceholder: string;
33
+ captcha: string;
34
+ captchaPlaceholder: string;
35
+ captchaRefresh: string;
36
+ captchaFailed: string;
37
+ captchaRequired: string;
38
+ wechatHint: string;
39
+ wechatNote: string;
40
+ qrcodeAlt: string;
41
+ helpTitle: string;
42
+ help1: string;
43
+ help2: string;
44
+ help3: string;
45
+ help4: string;
46
+ findPassword: string;
47
+ forgotLink: string;
48
+ registerLink: string;
49
+ phone: string;
50
+ phonePlaceholder: string;
51
+ phoneInvalid: string;
52
+ account: string;
53
+ accountRequired: string;
54
+ smsCode: string;
55
+ smsPlaceholder: string;
56
+ getCode: string;
57
+ resend: string;
58
+ smsSent: string;
59
+ smsNeedPhone: string;
60
+ smsNeedAccount: string;
61
+ registerPassword: string;
62
+ registerPasswordPlaceholder: string;
63
+ newPasswordPlaceholder: string;
64
+ confirmPlaceholder: string;
65
+ passwordPolicy: string;
66
+ sessionExpired: string;
67
+ passwordMismatch: string;
68
+ agreePrefix: string;
69
+ agreeRequired: string;
70
+ registerOk: string;
71
+ resetOk: string;
72
+ previewNote: string;
73
+ unavailableTitle: string;
74
+ unavailableDesc: string;
75
+ };
76
+ header: {
77
+ language: string;
78
+ theme: string;
79
+ logout: string;
80
+ myAccount: string;
81
+ search: string;
82
+ shortcuts: string;
83
+ fullscreen: string;
84
+ exitFullscreen: string;
85
+ notifications: string;
86
+ assistant: string;
87
+ appearance: string;
88
+ settings: string;
89
+ account: string;
90
+ };
91
+ settings: {
92
+ title: string;
93
+ themeMode: string;
94
+ themeColor: string;
95
+ themeColorCustom: string;
96
+ themeColorReset: string;
97
+ boxStyle: string;
98
+ boxBorder: string;
99
+ boxShadow: string;
100
+ close: string;
101
+ };
102
+ mode: {
103
+ light: string;
104
+ dark: string;
105
+ auto: string;
106
+ };
107
+ side: {
108
+ home: string;
109
+ collapse: string;
110
+ expand: string;
111
+ hideText: string;
112
+ showText: string;
113
+ openMenu: string;
114
+ closeMenu: string;
115
+ };
116
+ breadcrumb: {
117
+ current: string;
118
+ };
119
+ tabs: {
120
+ refresh: string;
121
+ close: string;
122
+ closeLeft: string;
123
+ closeRight: string;
124
+ closeOthers: string;
125
+ closeAll: string;
126
+ fullscreen: string;
127
+ exitFullscreen: string;
128
+ };
129
+ table: {
130
+ search: string;
131
+ reset: string;
132
+ empty: string;
133
+ loadFailed: string;
134
+ retry: string;
135
+ total: string;
136
+ refresh: string;
137
+ };
138
+ form: {
139
+ required: string;
140
+ submit: string;
141
+ reset: string;
142
+ };
143
+ chart: {
144
+ compact: string;
145
+ empty: string;
146
+ loading: string;
147
+ total: string;
148
+ category: string;
149
+ value: string;
150
+ percent: string;
151
+ summaryLine: string;
152
+ summaryBar: string;
153
+ summarySeries: string;
154
+ summaryPie: string;
155
+ summaryPieItem: string;
156
+ summarySpark: string;
157
+ summaryGauge: string;
158
+ };
159
+ error: {
160
+ forbidden: string;
161
+ notFound: string;
162
+ backHome: string;
163
+ };
164
+ };
165
+ };
package/package.json CHANGED
@@ -1,58 +1,31 @@
1
1
  {
2
2
  "name": "@campus-admin/locale",
3
- "version": "1.0.0",
4
- "description": "面向智慧校园后台的国际化运行时:词条、取词切换与日期数字格式化",
3
+ "version": "2.0.1",
4
+ "description": "框架内置中英文词条",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "author": "UnionSchool",
8
- "homepage": "https://campus.zhongxiaotong.com",
9
7
  "repository": {
10
8
  "type": "git",
11
9
  "url": "git+https://github.com/UnionSchool/campus-admin.git",
12
10
  "directory": "packages/locale"
13
11
  },
14
- "keywords": [
15
- "vue",
16
- "vue3",
17
- "i18n",
18
- "locale",
19
- "campus",
20
- "admin"
21
- ],
22
- "sideEffects": false,
23
12
  "files": [
24
- "LICENSE",
25
13
  "dist",
14
+ "LICENSE",
26
15
  "README.md"
27
16
  ],
28
- "main": "./dist/index.umd.cjs",
29
- "module": "./dist/index.js",
30
- "types": "./dist/index.d.ts",
31
17
  "exports": {
32
18
  ".": {
33
19
  "types": "./dist/index.d.ts",
34
- "import": "./dist/index.js",
35
- "require": "./dist/index.umd.cjs",
36
- "source": "./src/index.ts"
20
+ "import": "./dist/index.js"
37
21
  }
38
22
  },
23
+ "sideEffects": [
24
+ "**/*.css",
25
+ "./dist/index.js"
26
+ ],
39
27
  "publishConfig": {
40
28
  "access": "public",
41
- "provenance": true
42
- },
43
- "engines": {
44
- "node": ">=20.19.0"
45
- },
46
- "peerDependencies": {
47
- "vue": "^3.5.42"
48
- },
49
- "devDependencies": {
50
- "typescript": "^5.9.3",
51
- "vite": "^8.3.0",
52
- "vue": "^3.5.42"
53
- },
54
- "scripts": {
55
- "typecheck": "tsc --noEmit -p tsconfig.json",
56
- "build": "node ../../scripts/clean.mjs dist:packages/locale && tsc --declaration --emitDeclarationOnly -p tsconfig.build.json && vite build"
29
+ "provenance": false
57
30
  }
58
- }
31
+ }
package/dist/format.d.ts DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * 与语言相关的格式化。
3
- *
4
- * 统一走浏览器内置的 Intl,不再自己拼“年 / 月 / 日”,也不引第三方日期库:
5
- * 同一份代码在 zh-CN 下输出「2026年9月」,在 en-US 下输出「September 2026」。
6
- *
7
- * 传入无法识别的语言标记时回退到运行环境默认语言,不抛异常。
8
- */
9
- /** 2026-09-07 是周一,用它推出七个星期标签 */
10
- declare const BASE_MONDAY: Date;
11
- /**
12
- * 星期标签,按周一到周日返回七个值。
13
- * style 为 short 时是「周一 / Mon」,narrow 时是「一 / M」。
14
- */
15
- export declare function weekdayLabels(locale: string, style?: 'short' | 'narrow'): string[];
16
- /** 年月:2026年9月 / September 2026 */
17
- export declare function formatMonth(date: Date, locale: string): string;
18
- /** 月日:9月11日 / September 11 */
19
- export declare function formatDay(date: Date, locale: string): string;
20
- /** 数字与货币:统一走 Intl.NumberFormat,保证千分位与货币符号跟随语言 */
21
- export declare function formatNumber(value: number, locale: string, options?: Intl.NumberFormatOptions): string;
22
- export { BASE_MONDAY };
@@ -1 +0,0 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue")):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.CampusLocale={},e.Vue))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n={ca:{common:{loading:`加载中…`,close:`关闭`,clear:`清空`,remove:`移除`,confirm:`确定`,cancel:`取消`,processing:`处理中…`,back:`返回`,expand:`展开`,collapse:`收起`},table:{empty:`暂无数据`},pagination:{label:`分页导航`,total:`共 {total} 条`,prev:`上一页`,next:`下一页`},toast:{close:`关闭消息`},empty:{title:`暂无数据`},copyright:{line:`© {year} {name}`,poweredBy:`Powered By 众校通 ®`,poweredByPartner:`Powered By {partner} | 众校通 ®`},slogan:{default:`为教育多做一点`},select:{placeholder:`请选择`,empty:`暂无选项`},breadcrumb:{label:`面包屑导航`},searchForm:{search:`查询`,reset:`重置`,searching:`查询中…`},classTree:{searchPlaceholder:`搜索年级或班级`,searchLabel:`搜索班级`,empty:`没有匹配的年级或班级`},sideMenu:{label:`导航菜单`},studentPicker:{placeholder:`搜索姓名、学号或班级`,searchLabel:`搜索学生`,selected:`已选 {count}`,studentNo:`学号 {no}`,emptyTitle:`没有匹配的学生`,emptyDescription:`换个关键词试试`},attendance:{normal:`正常`,late:`迟到`,leave:`请假`,absent:`缺勤`,early:`早退`,unknown:`未打卡`},timetable:{tabsLabel:`课表类型`,personal:`个人课表`,class:`班级课表`,prevWeek:`上一周`,nextWeek:`下一周`,thisWeek:`本周`,week:`第 {week} 周`,personalSubtitle:`林老师 · 语文`,classSubtitle:`班级教学安排`,term:`2026–2027 学年 · 第一学期`,classLabel:`选择班级`,weekCount:`本周 {count} 节课`,caption:`{range} 教学课表`,periodHeader:`时段 / 节次`,hint:`点击课程查看详情`,detail:`{date} {time},授课教师:林老师。请提前准备教学资料。`},agenda:{title:`日程安排`,backToToday:`回到今天`,count:`{count} 项日程`,prevWeek:`日程上一周`,nextWeek:`日程下一周`,dayLabel:`{date}日程`,detail:`详情`,emptyTitle:`当天暂无日程`,emptyDescription:`可以查看其他日期的安排`,emptySearchTitle:`未找到相关日程`,emptySearchDescription:`试试其他关键词`,footer:`所有日程均为本地演示数据`,doneState:`此日程已完成。`,todoState:`请按时参加并准备相关材料。`,describe:`{date} {time},地点:{location}。{state}`}}},r={ca:{common:{loading:`Loading…`,close:`Close`,clear:`Clear`,remove:`Remove`,confirm:`OK`,cancel:`Cancel`,processing:`Processing…`,back:`Back`,expand:`Expand`,collapse:`Collapse`},table:{empty:`No data`},pagination:{label:`Pagination`,total:`{total} items`,prev:`Previous page`,next:`Next page`},toast:{close:`Close message`},empty:{title:`No data`},copyright:{line:`© {year} {name}`,poweredBy:`Powered By 众校通 ®`,poweredByPartner:`Powered By {partner} | 众校通 ®`},slogan:{default:`Do a little more for education`},select:{placeholder:`Please select`,empty:`No options`},breadcrumb:{label:`Breadcrumb`},searchForm:{search:`Search`,reset:`Reset`,searching:`Searching…`},classTree:{searchPlaceholder:`Search grade or class`,searchLabel:`Search class`,empty:`No matching grade or class`},sideMenu:{label:`Navigation`},studentPicker:{placeholder:`Search name, student no. or class`,searchLabel:`Search students`,selected:`{count} selected`,studentNo:`No. {no}`,emptyTitle:`No matching students`,emptyDescription:`Try another keyword`},attendance:{normal:`Present`,late:`Late`,leave:`On leave`,absent:`Absent`,early:`Left early`,unknown:`Not checked in`},timetable:{tabsLabel:`Timetable type`,personal:`My timetable`,class:`Class timetable`,prevWeek:`Previous week`,nextWeek:`Next week`,thisWeek:`This week`,week:`Week {week}`,personalSubtitle:`Ms. Lin · Chinese`,classSubtitle:`Class teaching plan`,term:`2026–2027 · First semester`,classLabel:`Select class`,weekCount:`{count} lessons this week`,caption:`{range} timetable`,periodHeader:`Period`,hint:`Click a lesson for details`,detail:`{date} {time}. Teacher: Ms. Lin. Please prepare your materials in advance.`},agenda:{title:`Schedule`,backToToday:`Back to today`,count:`{count} items`,prevWeek:`Previous week`,nextWeek:`Next week`,dayLabel:`Schedule for {date}`,detail:`Details`,emptyTitle:`No schedule for this day`,emptyDescription:`Pick another date to see its schedule`,emptySearchTitle:`No matching schedule`,emptySearchDescription:`Try another keyword`,footer:`All schedules are local demo data`,doneState:`This item is done.`,todoState:`Please attend on time and prepare the relevant materials.`,describe:`{date} {time}, location: {location}. {state}`}}},i=new Date(2026,8,7),a=new Map;function o(e,t){let n=`${e}|${JSON.stringify(t)}`,r=a.get(n);if(r)return r;let i;try{i=new Intl.DateTimeFormat(e,t)}catch{i=new Intl.DateTimeFormat(void 0,t)}return a.set(n,i),i}function s(e,t=`short`){let n=o(e,{weekday:t});return Array.from({length:7},(e,t)=>n.format(new Date(2026,8,7+t)))}function c(e,t){return o(t,{year:`numeric`,month:`long`}).format(e)}function l(e,t){return o(t,{month:`long`,day:`numeric`}).format(e)}function u(e,t,n){try{return new Intl.NumberFormat(t,n).format(e)}catch{return new Intl.NumberFormat(void 0,n).format(e)}}var d=`zh-CN`,f=[`zh-CN`,`en-US`],p={"zh-CN":n,"en-US":r},m=Symbol(`ca-locale`);function h(e){let t={};return Object.entries(e).forEach(([e,n])=>{t[e]=typeof n==`string`?n:h(n)}),t}function g(e,t){let n=h(e);return Object.entries(t).forEach(([e,t])=>{let r=n[e];n[e]=typeof t==`string`||typeof r!=`object`?t:g(r,t)}),n}function _(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`)return;n=n[e]}return typeof n==`string`?n:void 0}function v(e){return _(p[`zh-CN`]??{},e)}function y(e,t){return t?e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e):e}function b(e,t,n,r){let i=[t,t.split(`-`)[0],n,n.split(`-`)[0]];for(let t of i){if(!t)continue;let n=_(e[t]??{},r);if(n!==void 0)return n}}function x(e={}){let n=(0,t.ref)(e.locale??`zh-CN`),r=(0,t.ref)(e.fallbackLocale??`zh-CN`),i=(0,t.ref)(S(p,e.messages));return{locale:n,fallbackLocale:r,t:(e,t)=>{let a=b(i.value,n.value,r.value,e);return a===void 0?e:y(a,t)},te(e){return b(i.value,n.value,r.value,e)!==void 0},setLocale(e){n.value=e},mergeMessages(e,t){i.value={...i.value,[e]:g(i.value[e]??{},t)}},getMessages(e){return h(i.value[e]??{})}}}function S(e,t){let n={};return Object.keys(e).forEach(t=>{n[t]=h(e[t])}),Object.entries(t??{}).forEach(([e,t])=>{n[e]=g(n[e]??{},t)}),n}var C=x();function w(e,t){e.provide(m,t),C=t}function T(){return C}function E(e){C.setLocale(e)}function D(){return C.locale.value}function O(){return C.locale}function k(){return(0,t.inject)(m,C)}function A(e){(0,t.provide)(m,e)}e.AVAILABLE_LOCALES=f,e.BASE_MONDAY=i,e.CA_LOCALE_KEY=m,e.DEFAULT_LOCALE=d,e.caMessages=p,e.createLocale=x,e.defaultMessage=v,e.formatDay=l,e.formatMonth=c,e.formatNumber=u,e.getCurrentLocale=T,e.getLocale=D,e.installLocale=w,e.lookupMessage=_,e.provideLocale=A,e.setLocale=E,e.useLocale=k,e.useLocaleRef=O,e.weekdayLabels=s});
@@ -1,9 +0,0 @@
1
- /**
2
- * 组件库内置词条(英文)。
3
- *
4
- * 与 zh-CN 的键一一对应,缺任何一条都会在英文界面下回退成中文或显示 key 本身。
5
- * 新增组件文案时两份语言包必须同时补,缺失由 packages/ui 的类型检查兜底。
6
- */
7
- import type { LocaleMessages } from '../types';
8
- declare const enUS: LocaleMessages;
9
- export default enUS;
@@ -1,13 +0,0 @@
1
- /**
2
- * 组件库内置词条(简体中文,默认语言)。
3
- *
4
- * 约定:
5
- * 1. 所有键都挂在 ca 命名空间下,ca 由组件库保留;业务要改写组件文案时
6
- * 只覆盖 ca 下的叶子键,不要覆盖父级路径(父级覆盖会让整棵子树静默失效);
7
- * 2. 结构就是 vue-i18n 的 messages,业务可以直接 mergeLocaleMessage('zh-CN', caMessagesZhCN);
8
- * 3. 只放“组件自身的界面文案”。班级名、科目、节次、日程条目这类业务数据
9
- * 不在这里,真实项目由接口下发(见各组件 data.ts 的说明)。
10
- */
11
- import type { LocaleMessages } from '../types';
12
- declare const zhCN: LocaleMessages;
13
- export default zhCN;
package/dist/types.d.ts DELETED
@@ -1,54 +0,0 @@
1
- /**
2
- * 国际化类型契约。
3
- *
4
- * 结构与 vue-i18n 的 messages 保持一致(嵌套对象、{name} 插值),
5
- * 因此内置词条可以直接交给业务侧 mergeLocaleMessage,不需要转换格式。
6
- */
7
- import type { Ref } from 'vue';
8
- /** 词条树:键为语义名,值为字符串或下一层节点 */
9
- export interface LocaleMessages {
10
- [key: string]: string | LocaleMessages;
11
- }
12
- /** 词条集合:按语言标记分组,例如 { 'zh-CN': {...}, 'en-US': {...} } */
13
- export type LocaleMessageMap = Record<string, LocaleMessages>;
14
- /**
15
- * 取词函数。
16
- * 签名与 vue-i18n 的 t() 对齐:第二个参数是插值变量;
17
- * 找不到词条时原样返回 key,便于在页面上直接看出漏翻。
18
- */
19
- export type TranslateFn = (key: string, params?: Record<string, string | number>) => string;
20
- export interface CaLocaleOptions {
21
- /** 当前语言,默认 zh-CN */
22
- locale?: string;
23
- /** 兜底语言,当前语言缺词条时使用,默认 zh-CN */
24
- fallbackLocale?: string;
25
- /** 业务词条,按语言分组追加到内置词条之上(深合并) */
26
- messages?: LocaleMessageMap;
27
- }
28
- /** 语言实例:组件与业务都通过它取词 */
29
- export interface CaLocale {
30
- /** 当前语言,可写,写入即切换 */
31
- locale: Ref<string>;
32
- /** 兜底语言 */
33
- fallbackLocale: Ref<string>;
34
- /** 取词 */
35
- t: TranslateFn;
36
- /**
37
- * 词条是否存在,签名与 vue-i18n 的 te() 一致。
38
- * 用于「有词条就用词条,没有就用后端下发的默认文案」这类场景。
39
- */
40
- te: (key: string) => boolean;
41
- /** 切换语言 */
42
- setLocale: (locale: string) => void;
43
- /** 追加词条(深合并,同路径覆盖),用于登录后下发业务词条 */
44
- mergeMessages: (locale: string, messages: LocaleMessages) => void;
45
- /** 读取某语言的原始词条,便于业务侧合并进 vue-i18n */
46
- getMessages: (locale: string) => LocaleMessages;
47
- }
48
- /**
49
- * 组件库在应用配置里的国际化字段。
50
- * 业务这样交给框架(见 examples/admin):
51
- * createCampusAdmin({ config: { locale: { locale: 'zh-CN', messages: {...} } } })
52
- */
53
- export interface CaLocaleConfig extends CaLocaleOptions {
54
- }