diff --git a/src/client/components/abuse-report-window.vue b/src/client/components/abuse-report-window.vue index c550e1e85..98578ee44 100644 --- a/src/client/components/abuse-report-window.vue +++ b/src/client/components/abuse-report-window.vue @@ -2,7 +2,7 @@ diff --git a/src/client/components/channel-preview.vue b/src/client/components/channel-preview.vue index 241fbe4f6..e222ad7ae 100644 --- a/src/client/components/channel-preview.vue +++ b/src/client/components/channel-preview.vue @@ -6,7 +6,7 @@
- + @@ -14,7 +14,7 @@
- + @@ -27,7 +27,7 @@
- {{ $t('updatedAt') }}: + {{ $ts.updatedAt }}:
diff --git a/src/client/components/cw-button.vue b/src/client/components/cw-button.vue index d052c410d..d2336085a 100644 --- a/src/client/components/cw-button.vue +++ b/src/client/components/cw-button.vue @@ -1,6 +1,6 @@ @@ -27,7 +27,7 @@ export default defineComponent({ return concat([ this.note.text ? [this.$t('_cw.chars', { count: length(this.note.text) })] : [], this.note.files && this.note.files.length !== 0 ? [this.$t('_cw.files', { count: this.note.files.length }) ] : [], - this.note.poll != null ? [this.$t('poll')] : [] + this.note.poll != null ? [this.$ts.poll] : [] ] as string[][]).join(' / '); } }, diff --git a/src/client/components/dialog.vue b/src/client/components/dialog.vue index f8d700202..a34f7f794 100644 --- a/src/client/components/dialog.vue +++ b/src/client/components/dialog.vue @@ -26,8 +26,8 @@
- {{ (showCancelButton || input || select) ? $t('ok') : $t('gotIt') }} - {{ $t('cancel') }} + {{ (showCancelButton || input || select) ? $ts.ok : $ts.gotIt }} + {{ $ts.cancel }}
{{ action.text }} diff --git a/src/client/components/drive-select-dialog.vue b/src/client/components/drive-select-dialog.vue index 5221bdbb6..f9a402545 100644 --- a/src/client/components/drive-select-dialog.vue +++ b/src/client/components/drive-select-dialog.vue @@ -10,7 +10,7 @@ @closed="$emit('closed')" > diff --git a/src/client/components/drive-window.vue b/src/client/components/drive-window.vue index 0806fc180..43f07ebe7 100644 --- a/src/client/components/drive-window.vue +++ b/src/client/components/drive-window.vue @@ -6,7 +6,7 @@ @closed="$emit('closed')" > diff --git a/src/client/components/drive.file.vue b/src/client/components/drive.file.vue index 81e314a72..ddee81261 100644 --- a/src/client/components/drive.file.vue +++ b/src/client/components/drive.file.vue @@ -10,15 +10,15 @@ >
-

{{ $t('avatar') }}

+

{{ $ts.avatar }}

-

{{ $t('banner') }}

+

{{ $ts.banner }}

-

{{ $t('nsfw') }}

+

{{ $ts.nsfw }}

@@ -82,26 +82,26 @@ export default defineComponent({ methods: { getMenu() { return [{ - text: this.$t('rename'), + text: this.$ts.rename, icon: faICursor, action: this.rename }, { - text: this.file.isSensitive ? this.$t('unmarkAsSensitive') : this.$t('markAsSensitive'), + text: this.file.isSensitive ? this.$ts.unmarkAsSensitive : this.$ts.markAsSensitive, icon: this.file.isSensitive ? faEye : faEyeSlash, action: this.toggleSensitive }, null, { - text: this.$t('copyUrl'), + text: this.$ts.copyUrl, icon: faLink, action: this.copyUrl }, { type: 'a', href: this.file.url, target: '_blank', - text: this.$t('download'), + text: this.$ts.download, icon: faDownload, download: this.file.name }, null, { - text: this.$t('delete'), + text: this.$ts.delete, icon: faTrashAlt, danger: true, action: this.deleteFile @@ -137,9 +137,9 @@ export default defineComponent({ rename() { os.dialog({ - title: this.$t('renameFile'), + title: this.$ts.renameFile, input: { - placeholder: this.$t('inputNewFileName'), + placeholder: this.$ts.inputNewFileName, default: this.file.name, allowEmpty: false } diff --git a/src/client/components/drive.folder.vue b/src/client/components/drive.folder.vue index 79ae789f7..745b6018d 100644 --- a/src/client/components/drive.folder.vue +++ b/src/client/components/drive.folder.vue @@ -20,7 +20,7 @@ {{ folder.name }}

- {{ $t('uploadFolder') }} + {{ $ts.uploadFolder }}

@@ -155,14 +155,14 @@ export default defineComponent({ switch (err) { case 'detected-circular-definition': os.dialog({ - title: this.$t('unableToProcess'), - text: this.$t('circularReferenceFolder') + title: this.$ts.unableToProcess, + text: this.$ts.circularReferenceFolder }); break; default: os.dialog({ type: 'error', - text: this.$t('somethingHappened') + text: this.$ts.somethingHappened }); } }); @@ -195,9 +195,9 @@ export default defineComponent({ rename() { os.dialog({ - title: this.$t('renameFolder'), + title: this.$ts.renameFolder, input: { - placeholder: this.$t('inputNewFolderName'), + placeholder: this.$ts.inputNewFolderName, default: this.folder.name } }).then(({ canceled, result: name }) => { @@ -221,14 +221,14 @@ export default defineComponent({ case 'b0fc8a17-963c-405d-bfbc-859a487295e1': os.dialog({ type: 'error', - title: this.$t('unableToDelete'), - text: this.$t('hasChildFilesOrFolders') + title: this.$ts.unableToDelete, + text: this.$ts.hasChildFilesOrFolders }); break; default: os.dialog({ type: 'error', - text: this.$t('unableToDelete') + text: this.$ts.unableToDelete }); } }); @@ -240,7 +240,7 @@ export default defineComponent({ onContextmenu(e) { os.contextMenu([{ - text: this.$t('openInWindow'), + text: this.$ts.openInWindow, icon: faWindowRestore, action: () => { os.popup(import('./drive-window.vue'), { @@ -249,11 +249,11 @@ export default defineComponent({ }, 'closed'); } }, null, { - text: this.$t('rename'), + text: this.$ts.rename, icon: faICursor, action: this.rename }, null, { - text: this.$t('delete'), + text: this.$ts.delete, icon: faTrashAlt, danger: true, action: this.deleteFolder diff --git a/src/client/components/drive.nav-folder.vue b/src/client/components/drive.nav-folder.vue index 16ebc433f..881330529 100644 --- a/src/client/components/drive.nav-folder.vue +++ b/src/client/components/drive.nav-folder.vue @@ -8,7 +8,7 @@ @drop.stop="onDrop" > - {{ folder == null ? $t('drive') : folder.name }} + {{ folder == null ? $ts.drive : folder.name }}
diff --git a/src/client/components/drive.vue b/src/client/components/drive.vue index a743249b9..64e4d51e2 100644 --- a/src/client/components/drive.vue +++ b/src/client/components/drive.vue @@ -24,18 +24,18 @@
- {{ $t('loadMore') }} + {{ $ts.loadMore }}
- {{ $t('loadMore') }} + {{ $ts.loadMore }}

{{ $t('empty-draghover') }}

-

{{ $t('emptyDrive') }}
{{ $t('empty-drive-description') }}

-

{{ $t('emptyFolder') }}

+

{{ $ts.emptyDrive }}
{{ $t('empty-drive-description') }}

+

{{ $ts.emptyFolder }}

@@ -277,14 +277,14 @@ export default defineComponent({ switch (err) { case 'detected-circular-definition': os.dialog({ - title: this.$t('unableToProcess'), - text: this.$t('circularReferenceFolder') + title: this.$ts.unableToProcess, + text: this.$ts.circularReferenceFolder }); break; default: os.dialog({ type: 'error', - text: this.$t('somethingHappened') + text: this.$ts.somethingHappened }); } }); @@ -298,9 +298,9 @@ export default defineComponent({ urlUpload() { os.dialog({ - title: this.$t('uploadFromUrl'), + title: this.$ts.uploadFromUrl, input: { - placeholder: this.$t('uploadFromUrlDescription') + placeholder: this.$ts.uploadFromUrlDescription } }).then(({ canceled, result: url }) => { if (canceled) return; @@ -310,17 +310,17 @@ export default defineComponent({ }); os.dialog({ - title: this.$t('uploadFromUrlRequested'), - text: this.$t('uploadFromUrlMayTakeTime') + title: this.$ts.uploadFromUrlRequested, + text: this.$ts.uploadFromUrlMayTakeTime }); }); }, createFolder() { os.dialog({ - title: this.$t('createFolder'), + title: this.$ts.createFolder, input: { - placeholder: this.$t('folderName') + placeholder: this.$ts.folderName } }).then(({ canceled, result: name }) => { if (canceled) return; @@ -335,9 +335,9 @@ export default defineComponent({ renameFolder(folder) { os.dialog({ - title: this.$t('renameFolder'), + title: this.$ts.renameFolder, input: { - placeholder: this.$t('inputNewFolderName'), + placeholder: this.$ts.inputNewFolderName, default: folder.name } }).then(({ canceled, result: name }) => { @@ -363,14 +363,14 @@ export default defineComponent({ case 'b0fc8a17-963c-405d-bfbc-859a487295e1': os.dialog({ type: 'error', - title: this.$t('unableToDelete'), - text: this.$t('hasChildFilesOrFolders') + title: this.$ts.unableToDelete, + text: this.$ts.hasChildFilesOrFolders }); break; default: os.dialog({ type: 'error', - text: this.$t('unableToDelete') + text: this.$ts.unableToDelete }); } }); @@ -602,29 +602,29 @@ export default defineComponent({ getMenu() { return [{ - text: this.$t('addFile'), + text: this.$ts.addFile, type: 'label' }, { - text: this.$t('upload'), + text: this.$ts.upload, icon: faUpload, action: () => { this.selectLocalFile(); } }, { - text: this.$t('fromUrl'), + text: this.$ts.fromUrl, icon: faLink, action: () => { this.urlUpload(); } }, null, { - text: this.folder ? this.folder.name : this.$t('drive'), + text: this.folder ? this.folder.name : this.$ts.drive, type: 'label' }, this.folder ? { - text: this.$t('renameFolder'), + text: this.$ts.renameFolder, icon: faICursor, action: () => { this.renameFolder(this.folder); } } : undefined, this.folder ? { - text: this.$t('deleteFolder'), + text: this.$ts.deleteFolder, icon: faTrashAlt, action: () => { this.deleteFolder(this.folder); } } : undefined, { - text: this.$t('createFolder'), + text: this.$ts.createFolder, icon: faFolderPlus, action: () => { this.createFolder(); } }]; diff --git a/src/client/components/emoji-picker.vue b/src/client/components/emoji-picker.vue index a9fa35708..996dc7067 100644 --- a/src/client/components/emoji-picker.vue +++ b/src/client/components/emoji-picker.vue @@ -1,7 +1,7 @@ diff --git a/src/client/components/form-dialog.vue b/src/client/components/form-dialog.vue index add6b230d..7620abcd7 100644 --- a/src/client/components/form-dialog.vue +++ b/src/client/components/form-dialog.vue @@ -15,15 +15,15 @@ diff --git a/src/client/components/form/pagination.vue b/src/client/components/form/pagination.vue index 7dcaedf9b..df65d9684 100644 --- a/src/client/components/form/pagination.vue +++ b/src/client/components/form/pagination.vue @@ -6,7 +6,7 @@ - + diff --git a/src/client/components/form/textarea.vue b/src/client/components/form/textarea.vue index d84b48197..711cd5012 100644 --- a/src/client/components/form/textarea.vue +++ b/src/client/components/form/textarea.vue @@ -14,7 +14,7 @@ @blur="focused = false" > - +
diff --git a/src/client/components/global/a.vue b/src/client/components/global/a.vue index e93600301..671245fec 100644 --- a/src/client/components/global/a.vue +++ b/src/client/components/global/a.vue @@ -58,31 +58,31 @@ export default defineComponent({ text: this.to, }, { icon: faWindowMaximize, - text: this.$t('openInWindow'), + text: this.$ts.openInWindow, action: () => { os.pageWindow(this.to); } }, this.sideViewHook ? { icon: faColumns, - text: this.$t('openInSideView'), + text: this.$ts.openInSideView, action: () => { this.sideViewHook(this.to); } } : undefined, { icon: faExpandAlt, - text: this.$t('showInPage'), + text: this.$ts.showInPage, action: () => { this.$router.push(this.to); } }, null, { icon: faExternalLinkAlt, - text: this.$t('openInNewTab'), + text: this.$ts.openInNewTab, action: () => { window.open(this.to, '_blank'); } }, { icon: faLink, - text: this.$t('copyLink'), + text: this.$ts.copyLink, action: () => { copyToClipboard(`${url}${this.to}`); } diff --git a/src/client/components/global/error.vue b/src/client/components/global/error.vue index e4c76faa3..b78973ff8 100644 --- a/src/client/components/global/error.vue +++ b/src/client/components/global/error.vue @@ -2,8 +2,8 @@
-

{{ $t('somethingHappened') }}

- {{ $t('retry') }} +

{{ $ts.somethingHappened }}

+ {{ $ts.retry }}
diff --git a/src/client/components/global/i18n.ts b/src/client/components/global/i18n.ts index 603c07ca9..b1142caf9 100644 --- a/src/client/components/global/i18n.ts +++ b/src/client/components/global/i18n.ts @@ -1,15 +1,37 @@ -import { h, Fragment, defineComponent } from 'vue'; -import type { SetupContext, VNodeChild, RenderFunction } from 'vue'; +import { h, defineComponent } from 'vue'; export default defineComponent({ props: { src: { type: String, - required: true + required: true, + }, + tag: { + type: String, + required: false, + default: 'span', }, }, render() { - // TODO - return h('span', this.src); + let str = this.src; + const parsed = [] as (string | { arg: string; })[]; + while (true) { + const nextBracketOpen = str.indexOf('{'); + const nextBracketClose = str.indexOf('}'); + + if (nextBracketOpen === -1) { + parsed.push(str); + break; + } else { + if (nextBracketOpen > 0) parsed.push(str.substr(0, nextBracketOpen)); + parsed.push({ + arg: str.substring(nextBracketOpen + 1, nextBracketClose) + }); + } + + str = str.substr(nextBracketClose + 1); + } + + return h(this.tag, parsed.map(x => typeof x === 'string' ? x : this.$slots[x.arg]())); } }); diff --git a/src/client/components/global/time.vue b/src/client/components/global/time.vue index 544746c24..6a330a230 100644 --- a/src/client/components/global/time.vue +++ b/src/client/components/global/time.vue @@ -44,9 +44,9 @@ export default defineComponent({ ago >= 3600 ? this.$t('_ago.hoursAgo', { n: (~~(ago / 3600)).toString() }) : ago >= 60 ? this.$t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }) : ago >= 10 ? this.$t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() }) : - ago >= -1 ? this.$t('_ago.justNow') : - ago < -1 ? this.$t('_ago.future') : - this.$t('_ago.unknown')); + ago >= -1 ? this.$ts._ago.justNow : + ago < -1 ? this.$ts._ago.future : + this.$ts._ago.unknown); } }, created() { diff --git a/src/client/components/google.vue b/src/client/components/google.vue index a63a1476a..fe692a925 100644 --- a/src/client/components/google.vue +++ b/src/client/components/google.vue @@ -1,7 +1,7 @@ diff --git a/src/client/components/instance-stats.vue b/src/client/components/instance-stats.vue index 652cedceb..e9b496180 100644 --- a/src/client/components/instance-stats.vue +++ b/src/client/components/instance-stats.vue @@ -3,80 +3,80 @@
- {{ $t('users') }} - {{ $t('local') }} + {{ $ts.users }} + {{ $ts.local }}
-
{{ $t('total') }}
+
{{ $ts.total }}
{{ number(info.originalUsersCount) }}
-
{{ $t('dayOverDayChanges') }}
+
{{ $ts.dayOverDayChanges }}
{{ number(usersLocalDoD) }}
-
{{ $t('weekOverWeekChanges') }}
+
{{ $ts.weekOverWeekChanges }}
{{ number(usersLocalWoW) }}
- {{ $t('users') }} - {{ $t('remote') }} + {{ $ts.users }} + {{ $ts.remote }}
-
{{ $t('total') }}
+
{{ $ts.total }}
{{ number((info.usersCount - info.originalUsersCount)) }}
-
{{ $t('dayOverDayChanges') }}
+
{{ $ts.dayOverDayChanges }}
{{ number(usersRemoteDoD) }}
-
{{ $t('weekOverWeekChanges') }}
+
{{ $ts.weekOverWeekChanges }}
{{ number(usersRemoteWoW) }}
- {{ $t('notes') }} - {{ $t('local') }} + {{ $ts.notes }} + {{ $ts.local }}
-
{{ $t('total') }}
+
{{ $ts.total }}
{{ number(info.originalNotesCount) }}
-
{{ $t('dayOverDayChanges') }}
+
{{ $ts.dayOverDayChanges }}
{{ number(notesLocalDoD) }}
-
{{ $t('weekOverWeekChanges') }}
+
{{ $ts.weekOverWeekChanges }}
{{ number(notesLocalWoW) }}
- {{ $t('notes') }} - {{ $t('remote') }} + {{ $ts.notes }} + {{ $ts.remote }}
-
{{ $t('total') }}
+
{{ $ts.total }}
{{ number((info.notesCount - info.originalNotesCount)) }}
-
{{ $t('dayOverDayChanges') }}
+
{{ $ts.dayOverDayChanges }}
{{ number(notesRemoteDoD) }}
-
{{ $t('weekOverWeekChanges') }}
+
{{ $ts.weekOverWeekChanges }}
{{ number(notesRemoteWoW) }}
@@ -84,35 +84,35 @@
-
{{ $t('statistics') }}
+
{{ $ts.statistics }}
- - - + + + - - - - + + + + - - - - - + + + + + - - - - - + + + + + - - + +
diff --git a/src/client/components/launch-pad.vue b/src/client/components/launch-pad.vue index 24af78247..f732b675e 100644 --- a/src/client/components/launch-pad.vue +++ b/src/client/components/launch-pad.vue @@ -18,7 +18,7 @@
-
{{ $t('help') }}
+
{{ $ts.help }}
@@ -26,7 +26,7 @@ -
{{ $t('aboutMisskey') }}
+
{{ $ts.aboutMisskey }}
diff --git a/src/client/components/media-banner.vue b/src/client/components/media-banner.vue index d90d1186e..a2e1776d0 100644 --- a/src/client/components/media-banner.vue +++ b/src/client/components/media-banner.vue @@ -2,8 +2,8 @@
- {{ $t('sensitive') }} - {{ $t('clickToShow') }} + {{ $ts.sensitive }} + {{ $ts.clickToShow }}
diff --git a/src/client/components/media-video.vue b/src/client/components/media-video.vue index 78b011157..378894720 100644 --- a/src/client/components/media-video.vue +++ b/src/client/components/media-video.vue @@ -1,8 +1,8 @@