diff --git a/src/pages/user/registerClass.vue b/src/pages/user/registerClass.vue index 64374f43..83405c35 100644 --- a/src/pages/user/registerClass.vue +++ b/src/pages/user/registerClass.vue @@ -80,6 +80,7 @@ export default Vue.extend({ .registerClass({ schoolName: this.schoolName, className: this.className, + locale: this.$i18n.locale, }) .then(() => { this.loading = false diff --git a/src/store/modules/classData.ts b/src/store/modules/classData.ts index af4a5a75..56c87243 100644 --- a/src/store/modules/classData.ts +++ b/src/store/modules/classData.ts @@ -81,9 +81,22 @@ const VuexModule = createModule({ target: 'nuxt', }) -const generateUniqueId = (): string => { - const c = - 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん' +const generateUniqueId = (locale: string): string => { + let c: string = '' + switch (locale) { + case 'ja': + c = + 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん' + break + case 'en': + c = 'abcdefghijklmnopqrstuvwxyz' + break + case 'zh-tw': + c = + 'ㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄧㄨㄩㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦ' + break + } + const cl = c.length const result = c[Math.floor(Math.random() * cl)] + @@ -237,9 +250,11 @@ export class ClassDataStore extends VuexModule implements classData.ClassData { public async registerClass({ className, schoolName, + locale, }: { className: string schoolName: string + locale: string }) { if (!vxm.user.isAuthenticated) { throw new Error('ユーザーが正しくログインされていません') @@ -247,7 +262,7 @@ export class ClassDataStore extends VuexModule implements classData.ClassData { let classId, classObject do { - classId = generateUniqueId() + classId = generateUniqueId(locale) try { const result = (await API.graphql({ query: getClassSimple,