artalk 2.4.1 → 2.4.2

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 @@
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).jp=n()}(this,(function(){"use strict";var e,n,o;return e="jp",n={placeholder:"コメントを残す",noComment:"コメントなし",send:"送信",save:"保存",nick:"ニックネーム",email:"メール",link:"ウェブサイト",emoticon:"絵文字",preview:"プレビュー",image:"画像",uploadFail:"アップロードに失敗しました",commentFail:"コメントに失敗しました",restoredMsg:"コンテンツが復元されました",onlyAdminCanReply:"管理者のみが返信できます",uploadLoginMsg:"アップロードするには、名前とメールアドレスを入力してください",counter:"{count} コメント",sortLatest:"最新のもの",sortOldest:"最も古い",sortBest:"ベスト",sortAuthor:"著者",openComment:"コメントを開く",closeComment:"コメントを閉じる",listLoadFailMsg:"コメントの読み込みに失敗しました",listRetry:"クリックで再試行",loadMore:"もっと読み込む",admin:"管理者",reply:"返信",voteUp:"アップ",voteDown:"ダウン",voteFail:"投票に失敗しました",readMore:"続きを読む",actionConfirm:"確認",collapse:"折りたたむ",collapsed:"折りたたまれた",collapsedMsg:"このコメントは折りたたまれました",expand:"展開",approved:"承認されました",pending:"保留中",pendingMsg:"保留中、コメント投稿者にのみ表示されます",edit:"編集",editCancel:"編集をキャンセル",delete:"削除",deleteConfirm:"確認",pin:"ピン",unpin:"ピン外し",seconds:"秒前",minutes:"分前",hours:"時間前",days:"数日前",now:"たった今",adminCheck:"管理者パスワードを入力してください:",captchaCheck:"続けるにはCAPTCHAを入力してください:",confirm:"確認",cancel:"取消",msgCenter:"メッセージ",ctrlCenter:"コンソール",frontend:"フロントエンド",backend:"バックエンド",loading:"読み込み中",loadFail:"読み込みに失敗しました",editing:"編集中",editFail:"編集に失敗しました",deleting:"削除中",deleteFail:"削除に失敗しました",reqGot:"リクエストを取得しました",reqAborted:"リクエストがタイムアウトしたか、予期せず終了した"},o=["jp-JP"],window.ArtalkI18n||(window.ArtalkI18n={}),window.ArtalkI18n[e]=n,o&&o.forEach((e=>{window.ArtalkI18n[e]=n})),n}));
@@ -0,0 +1 @@
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self)["zh-TW"]=n()}(this,(function(){"use strict";var e,n,o;return e="zh-TW",n={placeholder:"鍵入內容...",noComment:"「此時無聲勝有聲」",send:"發送評論",save:"保存評論",nick:"昵稱",email:"郵箱",link:"網址",emoticon:"表情",preview:"預覽",image:"圖片",uploadFail:"上傳失敗",commentFail:"評論失敗",restoredMsg:"內容已自動恢復",onlyAdminCanReply:"僅管理員可評論",uploadLoginMsg:"填入你的名字郵箱才能上傳哦",counter:"{count} 條評論",sortLatest:"最新",sortOldest:"最早",sortBest:"最熱",sortAuthor:"作者",openComment:"打開評論",closeComment:"關閉評論",listLoadFailMsg:"無法獲取評論列表數據",listRetry:"點擊重新獲取",loadMore:"加載更多",admin:"管理員",reply:"回覆",voteUp:"贊同",voteDown:"反對",voteFail:"投票失敗",readMore:"閱讀更多",actionConfirm:"確認操作",collapse:"摺疊",collapsed:"已摺疊",collapsedMsg:"該評論已被系統或管理員摺疊",expand:"展開",approved:"已審",pending:"待審",pendingMsg:"審核中,僅本人可見。",edit:"編輯",editCancel:"取消編輯",delete:"刪除",deleteConfirm:"確認刪除",pin:"置頂",unpin:"取消置頂",seconds:"秒前",minutes:"分鐘前",hours:"小時前",days:"天前",now:"剛剛",adminCheck:"鍵入密碼來驗證管理員身份:",captchaCheck:"鍵入驗證碼繼續:",confirm:"確認",cancel:"取消",msgCenter:"通知中心",ctrlCenter:"控制中心",frontend:"前端",backend:"後端",loading:"加載中",loadFail:"加載失敗",editing:"修改中",editFail:"修改失敗",deleting:"刪除中",deleteFail:"刪除失敗",reqGot:"請求響應",reqAborted:"請求超時或意外終止"},window.ArtalkI18n||(window.ArtalkI18n={}),window.ArtalkI18n[e]=n,o&&o.forEach((e=>{window.ArtalkI18n[e]=n})),n}));
@@ -206,79 +206,73 @@ export declare const internal: {
206
206
  reqAborted: string;
207
207
  };
208
208
  };
209
- export declare const external: {
210
- 'jp-JP': {};
211
- 'zh-TW': {
212
- placeholder: string;
213
- noComment: string;
214
- send: string;
215
- save: string;
216
- nick: string;
217
- email: string;
218
- link: string;
219
- emoticon: string;
220
- preview: string;
221
- image: string;
222
- uploadFail: string;
223
- commentFail: string;
224
- restoredMsg: string;
225
- onlyAdminCanReply: string;
226
- uploadLoginMsg: string;
227
- counter: string;
228
- sortLatest: string;
229
- sortOldest: string;
230
- sortBest: string;
231
- sortAuthor: string;
232
- openComment: string;
233
- closeComment: string;
234
- listLoadFailMsg: string;
235
- listRetry: string;
236
- loadMore: string;
237
- admin: string;
238
- reply: string;
239
- voteUp: string;
240
- voteDown: string;
241
- voteFail: string;
242
- readMore: string;
243
- actionConfirm: string;
244
- collapse: string;
245
- collapsed: string;
246
- collapsedMsg: string;
247
- expand: string;
248
- approved: string;
249
- pending: string;
250
- pendingMsg: string;
251
- edit: string;
252
- editCancel: string;
253
- delete: string;
254
- deleteConfirm: string;
255
- pin: string;
256
- unpin: string;
257
- seconds: string;
258
- minutes: string;
259
- hours: string;
260
- days: string;
261
- now: string;
262
- adminCheck: string;
263
- captchaCheck: string;
264
- confirm: string;
265
- cancel: string;
266
- msgCenter: string;
267
- ctrlCenter: string;
268
- frontend: string;
269
- backend: string;
270
- loading: string;
271
- loadFail: string;
272
- editing: string;
273
- editFail: string;
274
- deleting: string;
275
- deleteFail: string;
276
- reqGot: string;
277
- reqAborted: string;
278
- };
279
- 'fr-FR': {};
280
- 'de-DE': {};
281
- 'bn-IN': {};
209
+ export declare function defineLocaleExternal(lang: string, locale: I18n, aliases?: string[]): {
210
+ placeholder: string;
211
+ noComment: string;
212
+ send: string;
213
+ save: string;
214
+ nick: string;
215
+ email: string;
216
+ link: string;
217
+ emoticon: string;
218
+ preview: string;
219
+ image: string;
220
+ uploadFail: string;
221
+ commentFail: string;
222
+ restoredMsg: string;
223
+ onlyAdminCanReply: string;
224
+ uploadLoginMsg: string;
225
+ counter: string;
226
+ sortLatest: string;
227
+ sortOldest: string;
228
+ sortBest: string;
229
+ sortAuthor: string;
230
+ openComment: string;
231
+ closeComment: string;
232
+ listLoadFailMsg: string;
233
+ listRetry: string;
234
+ loadMore: string;
235
+ admin: string;
236
+ reply: string;
237
+ voteUp: string;
238
+ voteDown: string;
239
+ voteFail: string;
240
+ readMore: string;
241
+ actionConfirm: string;
242
+ collapse: string;
243
+ collapsed: string;
244
+ collapsedMsg: string;
245
+ expand: string;
246
+ approved: string;
247
+ pending: string;
248
+ pendingMsg: string;
249
+ edit: string;
250
+ editCancel: string;
251
+ delete: string;
252
+ deleteConfirm: string;
253
+ pin: string;
254
+ unpin: string;
255
+ seconds: string;
256
+ minutes: string;
257
+ hours: string;
258
+ days: string;
259
+ now: string;
260
+ adminCheck: string;
261
+ captchaCheck: string;
262
+ confirm: string;
263
+ cancel: string;
264
+ msgCenter: string;
265
+ ctrlCenter: string;
266
+ frontend: string;
267
+ backend: string;
268
+ loading: string;
269
+ loadFail: string;
270
+ editing: string;
271
+ editFail: string;
272
+ deleting: string;
273
+ deleteFail: string;
274
+ reqGot: string;
275
+ reqAborted: string;
282
276
  };
283
277
  /**
284
278
  * get a locale object by language name
@@ -290,5 +284,5 @@ declare function getLocaleSet(lang: string): I18n;
290
284
  declare function getI18n(locale: I18n | string, key: keyof I18n, args?: {
291
285
  [key: string]: string;
292
286
  }): string;
293
- export { getLocaleSet, getI18n };
287
+ export { getLocaleSet };
294
288
  export default getI18n;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artalk",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "backendMinVersion": "2.2.0",
5
5
  "license": "LGPL-3.0",
6
6
  "description": "A Selfhosted Comment System",
@@ -34,8 +34,9 @@
34
34
  },
35
35
  "scripts": {
36
36
  "dev": "vite",
37
- "build": "pnpm lint && vite build && pnpm build:lite",
37
+ "build": "pnpm lint && vite build && pnpm build:lite && pnpm build:i18n",
38
38
  "build:lite": "vite build --config vite-lite.config.ts",
39
+ "build:i18n": "node scripts/build-i18n.mjs",
39
40
  "build:demo": "vite build --config vite-demo.config.ts",
40
41
  "serve": "vite preview",
41
42
  "deploy": "gh-pages -d deploy",
@@ -0,0 +1,46 @@
1
+ import fs from 'fs'
2
+ import path from 'path'
3
+ import { build } from 'vite'
4
+ import { fileURLToPath } from 'url'
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
7
+ const i18nPath = path.join(__dirname, '../src/i18n/')
8
+ const outDir = path.resolve(__dirname, '../dist/i18n')
9
+
10
+ // empty outDir before build
11
+ fs.rmSync(outDir, { recursive: true, force: true })
12
+
13
+ const libraries = []
14
+
15
+ fs.readdirSync(i18nPath).forEach(f => {
16
+ if (['index.ts'].includes(f)) return
17
+
18
+ const filename = path.join(i18nPath, f)
19
+ const lang = path.parse(filename).name
20
+ const content = fs.readFileSync(filename);
21
+
22
+ // only compile the external locale
23
+ if (!content.toString().includes('defineLocaleExternal')) return
24
+
25
+ libraries.push({
26
+ entry: filename,
27
+ name: lang,
28
+ fileName: (format) => ((format == "umd") ? `${lang}.js` : `${lang}.${format}.js`),
29
+ })
30
+ })
31
+
32
+ libraries.forEach(async (lib) => {
33
+ await build({
34
+ build: {
35
+ target: 'es2015',
36
+ outDir: outDir,
37
+ minify: 'terser',
38
+ emptyOutDir: false,
39
+ lib: {
40
+ ...lib,
41
+ formats: ['umd'],
42
+ },
43
+ },
44
+ configFile: false, // prevent load any vite config file
45
+ })
46
+ })
package/src/i18n/index.ts CHANGED
@@ -12,92 +12,13 @@ export const internal = {
12
12
  'zh-CN': zhCN,
13
13
  }
14
14
 
15
- export const external = {
16
- 'jp-JP': {},
17
- 'zh-TW': {
18
- /* Editor */
19
- placeholder: '鍵入內容...',
20
- noComment: '「此時無聲勝有聲」',
21
- send: '發送評論',
22
- save: '保存評論',
23
- nick: '昵稱',
24
- email: '郵箱',
25
- link: '網址',
26
- emoticon: '表情',
27
- preview: '預覽',
28
- image: '圖片',
29
- uploadFail: '上傳失敗',
30
- commentFail: '評論失敗',
31
- restoredMsg: '內容已自動恢復',
32
- onlyAdminCanReply: '僅管理員可評論',
33
- uploadLoginMsg: '填入你的名字郵箱才能上傳哦',
15
+ const GLOBAL_LOCALES_KEY = "ArtalkI18n";
34
16
 
35
- /* List */
36
- counter: '{count} 條評論',
37
- sortLatest: '最新',
38
- sortOldest: '最早',
39
- sortBest: '最熱',
40
- sortAuthor: '作者',
41
- openComment: '打開評論',
42
- closeComment: '關閉評論',
43
- listLoadFailMsg: '無法獲取評論列表數據',
44
- listRetry: '點擊重新獲取',
45
- loadMore: '加載更多',
46
-
47
- /* Comment */
48
- admin: '管理員',
49
- reply: '回覆',
50
- voteUp: '贊同',
51
- voteDown: '反對',
52
- voteFail: '投票失敗',
53
- readMore: '閱讀更多',
54
- actionConfirm: '確認操作',
55
- collapse: '摺疊',
56
- collapsed: '已摺疊',
57
- collapsedMsg: '該評論已被系統或管理員摺疊',
58
- expand: '展開',
59
- approved: '已審',
60
- pending: '待審',
61
- pendingMsg: '審核中,僅本人可見。',
62
- edit: '編輯',
63
- editCancel: '取消編輯',
64
- delete: '刪除',
65
- deleteConfirm: '確認刪除',
66
- pin: '置頂',
67
- unpin: '取消置頂',
68
-
69
- /* Time */
70
- seconds: '秒前',
71
- minutes: '分鐘前',
72
- hours: '小時前',
73
- days: '天前',
74
- now: '剛剛',
75
-
76
- /* Checker */
77
- adminCheck: '鍵入密碼來驗證管理員身份:',
78
- captchaCheck: '鍵入驗證碼繼續:',
79
- confirm: '確認',
80
- cancel: '取消',
81
-
82
- /* Sidebar */
83
- msgCenter: '通知中心',
84
- ctrlCenter: '控制中心',
85
-
86
- /* General */
87
- frontend: '前端',
88
- backend: '後端',
89
- loading: '加載中',
90
- loadFail: '加載失敗',
91
- editing: '修改中',
92
- editFail: '修改失敗',
93
- deleting: '刪除中',
94
- deleteFail: '刪除失敗',
95
- reqGot: '請求響應',
96
- reqAborted: '請求超時或意外終止',
97
- },
98
- 'fr-FR': {},
99
- 'de-DE': {},
100
- 'bn-IN': {},
17
+ export function defineLocaleExternal(lang: string, locale: I18n, aliases?: string[]) {
18
+ if (!window[GLOBAL_LOCALES_KEY]) window[GLOBAL_LOCALES_KEY] = {}
19
+ window[GLOBAL_LOCALES_KEY][lang] = locale
20
+ if (aliases) aliases.forEach(l => { window[GLOBAL_LOCALES_KEY][l] = locale })
21
+ return locale
101
22
  }
102
23
 
103
24
  /**
@@ -110,12 +31,19 @@ function getLocaleSet(lang: string): I18n {
110
31
  (_, p1: string, p2: string) => (p1.toLowerCase() + (p2 || '').toUpperCase())
111
32
  )
112
33
 
113
- // case not found
114
- if (!internal[lang]) {
115
- return internal.en // use `en` by default
34
+ // internal finding
35
+ if (internal[lang]) {
36
+ return internal[lang]
37
+ }
38
+
39
+ // external finding
40
+ if (window[GLOBAL_LOCALES_KEY] && window[GLOBAL_LOCALES_KEY][lang]) {
41
+ return window[GLOBAL_LOCALES_KEY][lang]
116
42
  }
117
43
 
118
- return internal[lang]
44
+ // case when not found:
45
+ // use `en` by default
46
+ return internal.en
119
47
  }
120
48
 
121
49
  /**
@@ -132,5 +60,5 @@ function getI18n(locale: I18n|string, key: keyof I18n, args: {[key: string]: str
132
60
  return str
133
61
  }
134
62
 
135
- export { getLocaleSet, getI18n }
63
+ export { getLocaleSet }
136
64
  export default getI18n
package/src/i18n/jp.ts ADDED
@@ -0,0 +1,83 @@
1
+ import { defineLocaleExternal } from '.'
2
+
3
+ export default defineLocaleExternal('jp', {
4
+ /* エディタ */
5
+ placeholder: 'コメントを残す',
6
+ noComment: 'コメントなし',
7
+ send: '送信',
8
+ save: '保存',
9
+ nick: 'ニックネーム',
10
+ email: 'メール',
11
+ link: 'ウェブサイト',
12
+ emoticon: '絵文字',
13
+ preview: 'プレビュー',
14
+ image: '画像',
15
+ uploadFail: 'アップロードに失敗しました',
16
+ commentFail: 'コメントに失敗しました',
17
+ restoredMsg: 'コンテンツが復元されました',
18
+ onlyAdminCanReply: '管理者のみが返信できます',
19
+ uploadLoginMsg: 'アップロードするには、名前とメールアドレスを入力してください',
20
+
21
+ /* リスト */
22
+ counter: '{count} コメント',
23
+ sortLatest: '最新のもの',
24
+ sortOldest: '最も古い',
25
+ sortBest: 'ベスト',
26
+ sortAuthor: '著者',
27
+ openComment: 'コメントを開く',
28
+ closeComment: 'コメントを閉じる',
29
+ listLoadFailMsg: 'コメントの読み込みに失敗しました',
30
+ listRetry: 'クリックで再試行',
31
+ loadMore: 'もっと読み込む',
32
+
33
+ /* コメント */
34
+ admin: '管理者',
35
+ reply: '返信',
36
+ voteUp: 'アップ',
37
+ voteDown: 'ダウン',
38
+ voteFail: '投票に失敗しました',
39
+ readMore: '続きを読む',
40
+ actionConfirm: '確認',
41
+ collapse: '折りたたむ',
42
+ collapsed: '折りたたまれた',
43
+ collapsedMsg: 'このコメントは折りたたまれました',
44
+ expand: '展開',
45
+ approved: '承認されました',
46
+ pending: '保留中',
47
+ pendingMsg: '保留中、コメント投稿者にのみ表示されます',
48
+ edit: '編集',
49
+ editCancel: '編集をキャンセル',
50
+ delete: '削除',
51
+ deleteConfirm: '確認',
52
+ pin: 'ピン',
53
+ unpin: 'ピン外し',
54
+
55
+ /* 時間 */
56
+ seconds: '秒前',
57
+ minutes: '分前',
58
+ hours: '時間前',
59
+ days: '数日前',
60
+ now: 'たった今',
61
+
62
+ /* チェッカー */
63
+ adminCheck: '管理者パスワードを入力してください:',
64
+ captchaCheck: '続けるにはCAPTCHAを入力してください:',
65
+ confirm: '確認',
66
+ cancel: '取消',
67
+
68
+ /* サイドバー */
69
+ msgCenter: 'メッセージ',
70
+ ctrlCenter: 'コンソール',
71
+
72
+ /* 一般 */
73
+ frontend: 'フロントエンド',
74
+ backend: 'バックエンド',
75
+ loading: '読み込み中',
76
+ loadFail: '読み込みに失敗しました',
77
+ editing: '編集中',
78
+ editFail: '編集に失敗しました',
79
+ deleting: '削除中',
80
+ deleteFail: '削除に失敗しました',
81
+ reqGot: 'リクエストを取得しました',
82
+ reqAborted: 'リクエストがタイムアウトしたか、予期せず終了した',
83
+ }, ['jp-JP'])
@@ -0,0 +1,83 @@
1
+ import { defineLocaleExternal } from '.'
2
+
3
+ export default defineLocaleExternal('zh-TW', {
4
+ /* Editor */
5
+ placeholder: '鍵入內容...',
6
+ noComment: '「此時無聲勝有聲」',
7
+ send: '發送評論',
8
+ save: '保存評論',
9
+ nick: '昵稱',
10
+ email: '郵箱',
11
+ link: '網址',
12
+ emoticon: '表情',
13
+ preview: '預覽',
14
+ image: '圖片',
15
+ uploadFail: '上傳失敗',
16
+ commentFail: '評論失敗',
17
+ restoredMsg: '內容已自動恢復',
18
+ onlyAdminCanReply: '僅管理員可評論',
19
+ uploadLoginMsg: '填入你的名字郵箱才能上傳哦',
20
+
21
+ /* List */
22
+ counter: '{count} 條評論',
23
+ sortLatest: '最新',
24
+ sortOldest: '最早',
25
+ sortBest: '最熱',
26
+ sortAuthor: '作者',
27
+ openComment: '打開評論',
28
+ closeComment: '關閉評論',
29
+ listLoadFailMsg: '無法獲取評論列表數據',
30
+ listRetry: '點擊重新獲取',
31
+ loadMore: '加載更多',
32
+
33
+ /* Comment */
34
+ admin: '管理員',
35
+ reply: '回覆',
36
+ voteUp: '贊同',
37
+ voteDown: '反對',
38
+ voteFail: '投票失敗',
39
+ readMore: '閱讀更多',
40
+ actionConfirm: '確認操作',
41
+ collapse: '摺疊',
42
+ collapsed: '已摺疊',
43
+ collapsedMsg: '該評論已被系統或管理員摺疊',
44
+ expand: '展開',
45
+ approved: '已審',
46
+ pending: '待審',
47
+ pendingMsg: '審核中,僅本人可見。',
48
+ edit: '編輯',
49
+ editCancel: '取消編輯',
50
+ delete: '刪除',
51
+ deleteConfirm: '確認刪除',
52
+ pin: '置頂',
53
+ unpin: '取消置頂',
54
+
55
+ /* Time */
56
+ seconds: '秒前',
57
+ minutes: '分鐘前',
58
+ hours: '小時前',
59
+ days: '天前',
60
+ now: '剛剛',
61
+
62
+ /* Checker */
63
+ adminCheck: '鍵入密碼來驗證管理員身份:',
64
+ captchaCheck: '鍵入驗證碼繼續:',
65
+ confirm: '確認',
66
+ cancel: '取消',
67
+
68
+ /* Sidebar */
69
+ msgCenter: '通知中心',
70
+ ctrlCenter: '控制中心',
71
+
72
+ /* General */
73
+ frontend: '前端',
74
+ backend: '後端',
75
+ loading: '加載中',
76
+ loadFail: '加載失敗',
77
+ editing: '修改中',
78
+ editFail: '修改失敗',
79
+ deleting: '刪除中',
80
+ deleteFail: '刪除失敗',
81
+ reqGot: '請求響應',
82
+ reqAborted: '請求超時或意外終止',
83
+ })
@@ -103,6 +103,23 @@
103
103
  tr:nth-child(even) {
104
104
  background-color: var(--at-color-bg-grey);
105
105
  }
106
+
107
+ ul {
108
+ list-style: disc;
109
+ }
110
+
111
+ ol {
112
+ list-style: decimal;
113
+ }
114
+
115
+ li + li {
116
+ margin-top: 8px;
117
+ }
118
+
119
+ li > ol,
120
+ li > ul {
121
+ margin: 8px 0 0;
122
+ }
106
123
  }
107
124
 
108
125
  .atk-hide {
@@ -1,5 +1,6 @@
1
1
  <link rel="stylesheet" href="../dist/Artalk.css">
2
2
  <script src="../dist/Artalk.js"></script>
3
+ <script src="../dist/i18n/zh-TW.js"></script>
3
4
 
4
5
  <div id="comments"></div>
5
6