Skip to content

Commit 1f27bda

Browse files
committed
adds japanese localization support
1 parent d20403d commit 1f27bda

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

src/components/Voting/Form.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<script setup lang="ts">
2-
import { nextTick, onMounted, onUnmounted, ref, toRefs, watch } from 'vue'
2+
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
33
import {
44
onPostCreated,
55
onUpdate,
66
} from '@devprotocol/clubs-plugin-posts/plugin-helper'
77
import type { Poll } from '../../types.ts'
8+
import { Strings } from '../i18n'
9+
import { i18nFactory } from '@devprotocol/clubs-core'
10+
11+
const i18nBase = i18nFactory(Strings)
12+
let i18n = i18nBase(['en'])
813
914
type Choice = {
1015
id: number
@@ -87,6 +92,7 @@ const togglePollState = () => {
8792
}
8893
8994
onMounted(() => {
95+
i18n = i18nBase(navigator.languages)
9096
window.addEventListener(POLL_EVENT, togglePollState)
9197
})
9298
@@ -169,7 +175,7 @@ watch(isPollOpen, (isOpen) => {
169175
</div>
170176
<div class="py-4 px-4 border-t border-gray-400">
171177
<p class="mb-2 text-gray-400 font-bold">
172-
Immediate Result Publication Settings
178+
{{ i18n('ImmediateResultPublicationSettings') }}
173179
</p>
174180
<label class="relative inline-flex items-center cursor-pointer">
175181
<input v-model="publication" type="checkbox" class="sr-only peer" />
@@ -263,7 +269,7 @@ watch(isPollOpen, (isOpen) => {
263269
class="py-4 w-full border text-red-500"
264270
@click="handleClickRemovePoll"
265271
>
266-
Remove poll
272+
{{ i18n('RemovePoll') }}
267273
</button>
268274
</div>
269275
</div>

src/components/Voting/Unpublished.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
<script setup lang="ts"></script>
1+
<script setup lang="ts">
2+
import { onMounted } from 'vue'
3+
import { Strings } from '../i18n'
4+
import { i18nFactory } from '@devprotocol/clubs-core'
5+
6+
const i18nBase = i18nFactory(Strings)
7+
let i18n = i18nBase(['en'])
8+
9+
onMounted(() => {
10+
i18n = i18nBase(navigator.languages)
11+
})
12+
</script>
213
<template>
314
<div class="flex flex-col justify-center items-center p-4">
415
<div class="px-8 py-4 border border-gray-400 text-center">
516
<p class="text-xl text-gray-600 font-bold mb-2">
6-
Poll Results are Unpublished
17+
{{ i18n('Unpublished') }}
718
</p>
819
<p class="text text-gray-600">
9-
At the moment, the poll results are set to unpublished.<br />Please wait
10-
until the voting period has ended.
20+
{{ i18n('UnpublishedDetail') }}<br />{{ i18n('PleaseWait') }}
1121
</p>
1222
</div>
1323
</div>

src/components/i18n/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { ClubsI18nParts } from '@devprotocol/clubs-core'
2+
3+
export const Strings = {
4+
RemovePoll: {
5+
en: 'Remove poll',
6+
ja: '',
7+
},
8+
ImmediateResultPublicationSettings: {
9+
en: 'Immediate Result Publication Settings',
10+
ja: '',
11+
},
12+
Unpublished: {
13+
en: 'Poll Results are Unpublished',
14+
ja: '',
15+
},
16+
UnpublishedDetail: {
17+
en: 'At the moment, the poll results are set to unpublished.',
18+
ja: '',
19+
},
20+
PleaseWait: {
21+
en: 'Please wait until the voting period has ended.',
22+
ja: '',
23+
},
24+
} satisfies ClubsI18nParts

0 commit comments

Comments
 (0)