diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2020-12-26 10:47:36 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2020-12-26 10:47:36 +0900 |
| commit | 5a8cc7851b4af9ae4a0d7efc5b66b224bbe9b4c8 (patch) | |
| tree | 18f6338f1d5935c401298515d4e400d5a2306301 /src/client/components/global | |
| parent | wip (diff) | |
| download | misskey-5a8cc7851b4af9ae4a0d7efc5b66b224bbe9b4c8.tar.gz misskey-5a8cc7851b4af9ae4a0d7efc5b66b224bbe9b4c8.tar.bz2 misskey-5a8cc7851b4af9ae4a0d7efc5b66b224bbe9b4c8.zip | |
wip
Diffstat (limited to 'src/client/components/global')
| -rw-r--r-- | src/client/components/global/a.vue | 10 | ||||
| -rw-r--r-- | src/client/components/global/error.vue | 4 | ||||
| -rw-r--r-- | src/client/components/global/i18n.ts | 32 | ||||
| -rw-r--r-- | src/client/components/global/time.vue | 6 |
4 files changed, 37 insertions, 15 deletions
diff --git a/src/client/components/global/a.vue b/src/client/components/global/a.vue index e936003018..671245fec7 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 e4c76faa31..b78973ff82 100644 --- a/src/client/components/global/error.vue +++ b/src/client/components/global/error.vue @@ -2,8 +2,8 @@ <transition :name="$store.state.animation ? 'zoom' : ''" appear> <div class="mjndxjcg"> <img src="https://xn--931a.moe/assets/error.jpg" class="_ghost"/> - <p><Fa :icon="faExclamationTriangle"/> {{ $t('somethingHappened') }}</p> - <MkButton @click="() => $emit('retry')" class="button">{{ $t('retry') }}</MkButton> + <p><Fa :icon="faExclamationTriangle"/> {{ $ts.somethingHappened }}</p> + <MkButton @click="() => $emit('retry')" class="button">{{ $ts.retry }}</MkButton> </div> </transition> </template> diff --git a/src/client/components/global/i18n.ts b/src/client/components/global/i18n.ts index 603c07ca97..b1142caf96 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 544746c24b..6a330a2307 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() { |