diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js new file mode 100644 index 0000000..cc7c82f --- /dev/null +++ b/frontend/src/lang/en.js @@ -0,0 +1,109 @@ +export default { + sidebar: { + home: 'Home', + stylegen: 'Style generator', + projectAddress: 'Project address' + }, + home: { + roomIdEmpty: "Room ID can't be empty", + roomIdInteger: 'Room ID must be positive integer', + + general: 'General', + roomId: 'Room ID', + showDanmaku: 'Show messages', + showGift: 'Show Super Chats', + mergeSimilarDanmaku: 'Merge similar messages', + minGiftPrice: 'Min price of Super Chats to show (CNY)', + maxSpeed: 'Max speed of messages (/second, 0 for unlimited)', + + block: 'Block', + giftDanmaku: 'System messages (gift effect)', + blockLevel: 'User level lower than', + informalUser: 'Informal users', + unverifiedUser: 'Unverified users', + blockKeywords: 'Block keywords', + onePerLine: 'One per line', + blockUsers: 'Block users', + blockMedalLevel: 'Medal level lower than', + + style: 'Style', + + roomUrl: 'Room URL', + copy: 'Copy', + saveConfig: 'Save config', + enterRoom: 'Enter room', + exportConfig: 'Export config', + importConfig: 'Import config', + + failedToSave: 'Failed to save: ', + successfullySaved: 'Successfully saved', + failedToParseConfig: 'Failed to parse config: ' + }, + stylegen: { + outlines: 'Outlines', + showOutlines: 'Show outlines', + outlineSize: 'Outline size', + outlineColor: 'Outline color', + + avatars: 'Avatars', + showAvatars: 'Show avatars', + avatarSize: 'Avatar size', + + userNames: 'User names', + font: 'Font', + fontSize: 'Font size', + lineHeight: 'Line height (0 for default)', + normalColor: 'Normal color', + ownerColor: 'Owner color', + moderatorColor: 'Moderator color', + memberColor: 'Member color', + showBadges: 'Show badges', + showColon: 'Show colon after name', + + messages: 'Messages', + color: 'Color', + onNewLine: 'On new line', + + time: 'Timestamps', + showTime: 'Show timestamps', + + backgrounds: 'Backgrounds', + bgColor: 'Background color', + useBarsInsteadOfBg: 'Use bars instead of backgrounds', + messageBgColor: 'Message background color', + ownerMessageBgColor: 'Owner background color', + moderatorMessageBgColor: 'Moderator background color', + memberMessageBgColor: 'Member background color', + + scAndNewMember: 'Super Chat / New member', + firstLineFont: 'First line font', + firstLineFontSize: 'First line font size', + firstLineLineHeight: 'First line line height (0 for default)', + firstLineColor: 'First line color', + secondLineFont: 'Second line font', + secondLineFontSize: 'Second line font size', + secondLineLineHeight: 'Second line line height (0 for default)', + secondLineColor: 'Second line color', + scContentLineFont: 'Super Chat content font', + scContentLineFontSize: 'Super Chat content font size', + scContentLineLineHeight: 'Super Chat content line height (0 for default)', + scContentLineColor: 'Super Chat content color', + showNewMemberBg: 'Show new member background', + showScTicker: 'Show Super Chat ticker', + showOtherThings: 'Show everything other than Super Chat ticker', + + animation: 'Animation', + animateIn: 'Animate in', + fadeInTime: 'Fade in time (miliseconds)', + animateOut: 'Animate out (remove old messages)', + animateOutWaitTime: 'Wait time (seconds)', + fadeOutTime: 'Fade out time (miliseconds)', + slide: 'Slide', + reverseSlide: 'Reverse slide', + playAnimation: 'Play animation', + + result: 'Result', + copy: 'Copy', + resetConfig: 'Reset config' + } +} diff --git a/frontend/src/lang/ja.js b/frontend/src/lang/ja.js new file mode 100644 index 0000000..f123fa3 --- /dev/null +++ b/frontend/src/lang/ja.js @@ -0,0 +1,109 @@ +export default { + sidebar: { + home: 'トップページ', + stylegen: 'スタイルジェネレータ', + projectAddress: 'プロジェクトアドレス' + }, + home: { + roomIdEmpty: 'ルームのIDを空白にすることはできません', + roomIdInteger: 'ルームは正の整数でなければなりません', + + general: '常規', + roomId: 'ルームID', + showDanmaku: 'コメントを表示する', + showGift: 'スーパーチャットと新メンバーを表示する', + mergeSimilarDanmaku: '同じコメントを合併する', + minGiftPrice: '最低表示スーパーチャット価格(CNY)', + maxSpeed: 'コメントの最大速度(バー/秒、0は無制限)', + + block: 'ブロック', + giftDanmaku: 'システムコメント(プレゼント効果)', + blockLevel: 'ユーザーレベルがx未満', + informalUser: '非公式ユーザー', + unverifiedUser: '認証されていないユーザー', + blockKeywords: 'キーワード', + onePerLine: '1行に1つずつ', + blockUsers: 'ユーザー', + blockMedalLevel: '勲章等級がx未満', + + style: 'スタイル', + + roomUrl: 'ルームのURL', + copy: 'コピー', + saveConfig: 'コンフィグを保存する', + enterRoom: 'ルームに入る', + exportConfig: 'コンフィグの導出', + importConfig: 'コンフィグの導入', + + failedToSave: '保存に失敗しました:', + successfullySaved: '保存に成功しました', + failedToParseConfig: 'コンフィグ解析に失敗しました' + }, + stylegen: { + outlines: 'アウトライン', + showOutlines: 'アウトラインを表示する', + outlineSize: 'アウトラインのサイズ', + outlineColor: 'アウトラインの色', + + avatars: 'アイコン', + showAvatars: 'アイコンを表示する', + avatarSize: 'アイコンのサイズ', + + userNames: 'ユーザー名', + font: 'フォント', + fontSize: 'フォントサイズ', + lineHeight: '行の高さ(0はデフォルト)', + normalColor: 'ノーマルの色', + ownerColor: 'オーナーの色', + moderatorColor: '管理者の色', + memberColor: 'メンバーの色', + showBadges: '勲章を見せる', + showColon: 'ユーザー名の後にコロンが表示されます', + + messages: 'コメント', + color: '色', + onNewLine: '新しい行に表示する', + + time: '時間', + showTime: '時間を表示する', + + backgrounds: '背景', + bgColor: '背景色', + useBarsInsteadOfBg: '背景に代わります', + messageBgColor: 'コメント背景色', + ownerMessageBgColor: 'オーナーコメント背景色', + moderatorMessageBgColor: '管理者コメント背景色', + memberMessageBgColor: 'メンバーコメント背景色', + + scAndNewMember: 'スーパーチャット、新メンバー', + firstLineFont: '1行目のフォント', + firstLineFontSize: '1行目のフォントサイズ', + firstLineLineHeight: '1行目の高さ(0はデフォルト)', + firstLineColor: '1行目の色', + secondLineFont: '2行目のフォント', + secondLineFontSize: '2行目のフォントサイズ', + secondLineLineHeight: '2行目の高さ(0はデフォルト)', + secondLineColor: '2行目の色', + scContentLineFont: 'スーパーチャットのコンテンツフォント', + scContentLineFontSize: 'スーパーチャットコンテンツフォントサイズ', + scContentLineLineHeight: 'スーパーチャットコンテンツライン高さ(0がデフォルト)', + scContentLineColor: 'スーパーチャットコンテンツライン色', + showNewMemberBg: '新メンバーの背景を表示する', + showScTicker: 'スーパーチャットチカーの表示', + showOtherThings: 'スーパーチャットチカー以外のコンテンツを表示します', + + animation: 'アニメーション', + animateIn: '入場アニメーション', + fadeInTime: 'フェードイン時間(ミリ秒)', + animateOut: '古いコメントを除去する', + animateOutWaitTime: '待ち時間(秒)', + fadeOutTime: 'フェードアウト時間(ミリ秒)', + slide: '滑る', + reverseSlide: '逆の滑る', + playAnimation: 'アニメーションを再生する', + + result: '結果', + copy: 'コピー', + resetConfig: 'デフォルトに戻す' + } +} diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js new file mode 100644 index 0000000..d3d5a33 --- /dev/null +++ b/frontend/src/lang/zh.js @@ -0,0 +1,109 @@ +export default { + sidebar: { + home: '首页', + stylegen: '样式生成器', + projectAddress: '项目地址' + }, + home: { + roomIdEmpty: '房间ID不能为空', + roomIdInteger: '房间ID必须为正整数', + + general: '常规', + roomId: '房间ID', + showDanmaku: '显示弹幕', + showGift: '显示礼物和新舰长', + mergeSimilarDanmaku: '合并相似弹幕', + minGiftPrice: '最低显示礼物价格(元)', + maxSpeed: '弹幕最大速度(条/秒,0为无限制)', + + block: '屏蔽', + giftDanmaku: '礼物弹幕', + blockLevel: '用户等级低于', + informalUser: '非正式会员', + unverifiedUser: '未绑定手机用户', + blockKeywords: '屏蔽关键词', + onePerLine: '一行一个', + blockUsers: '屏蔽用户', + blockMedalLevel: '当前直播间勋章等级低于', + + style: '样式', + + roomUrl: '房间URL', + copy: '复制', + saveConfig: '保存配置', + enterRoom: '进入房间', + exportConfig: '导出配置', + importConfig: '导入配置', + + failedToSave: '保存失败:', + successfullySaved: '保存成功', + failedToParseConfig: '配置解析失败:' + }, + stylegen: { + outlines: '描边', + showOutlines: '显示描边', + outlineSize: '描边尺寸', + outlineColor: '描边颜色', + + avatars: '头像', + showAvatars: '显示头像', + avatarSize: '头像尺寸', + + userNames: '用户名', + font: '字体', + fontSize: '字体尺寸', + lineHeight: '行高(0为默认)', + normalColor: '普通颜色', + ownerColor: '主播颜色', + moderatorColor: '房管颜色', + memberColor: '舰长颜色', + showBadges: '显示勋章', + showColon: '用户名后显示冒号', + + messages: '消息', + color: '颜色', + onNewLine: '在新行显示', + + time: '时间', + showTime: '显示时间', + + backgrounds: '背景', + bgColor: '背景色', + useBarsInsteadOfBg: '用条代替背景', + messageBgColor: '消息背景色', + ownerMessageBgColor: '主播消息背景色', + moderatorMessageBgColor: '房管消息背景色', + memberMessageBgColor: '舰长消息背景色', + + scAndNewMember: '礼物、舰长', + firstLineFont: '第一行字体', + firstLineFontSize: '第一行字体尺寸', + firstLineLineHeight: '第一行行高(0为默认)', + firstLineColor: '第一行颜色', + secondLineFont: '第二行字体', + secondLineFontSize: '第二行字体尺寸', + secondLineLineHeight: '第二行行高(0为默认)', + secondLineColor: '第二行颜色', + scContentLineFont: 'Super Chat内容字体', + scContentLineFontSize: 'Super Chat内容字体尺寸', + scContentLineLineHeight: 'Super Chat内容行高(0为默认)', + scContentLineColor: 'Super Chat内容颜色', + showNewMemberBg: '显示新舰长背景', + showScTicker: '显示Super Chat贴纸', + showOtherThings: '显示Super Chat贴纸之外的内容', + + animation: '动画', + animateIn: '进入动画', + fadeInTime: '淡入时间(毫秒)', + animateOut: '移除旧消息', + animateOutWaitTime: '等待时间(秒)', + fadeOutTime: '淡出时间(毫秒)', + slide: '滑动', + reverseSlide: '反向滑动', + playAnimation: '播放动画', + + result: '结果', + copy: '复制', + resetConfig: '恢复默认设置' + } +} diff --git a/frontend/src/layout/Sidebar.vue b/frontend/src/layout/Sidebar.vue index c5eefd0..de61bb0 100644 --- a/frontend/src/layout/Sidebar.vue +++ b/frontend/src/layout/Sidebar.vue @@ -8,23 +8,41 @@ :default-active="$route.path" > - 首页 + {{$t('sidebar.home')}} - 样式生成器 + {{$t('sidebar.stylegen')}} - 项目地址 + {{$t('sidebar.projectAddress')}} + + + {{name}} + diff --git a/frontend/src/main.js b/frontend/src/main.js index a7473ea..c4b86f9 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -2,6 +2,7 @@ import Vue from 'vue' import VueRouter from 'vue-router' import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' +import VueI18n from 'vue-i18n' import axios from 'axios' import App from './App.vue' @@ -11,6 +12,10 @@ import StyleGenerator from './views/StyleGenerator' import Room from './views/Room.vue' import NotFound from './views/NotFound.vue' +import zh from './lang/zh' +import ja from './lang/ja' +import en from './lang/en' + if (process.env.NODE_ENV === 'development') { // 开发时使用localhost:80 axios.defaults.baseURL = 'http://localhost' @@ -18,6 +23,7 @@ if (process.env.NODE_ENV === 'development') { Vue.use(VueRouter) Vue.use(ElementUI) +Vue.use(VueI18n) Vue.config.ignoredElements = [ /^yt-/ @@ -39,7 +45,27 @@ const router = new VueRouter({ ] }) +let locale = window.localStorage.lang +if (!locale) { + let lang = navigator.language + if (lang.startsWith('zh')) { + locale = 'zh' + } else if (lang.startsWith('ja')) { + locale = 'ja' + } else { + locale = 'en' + } +} +const i18n = new VueI18n({ + locale, + fallbackLocale: 'en', + messages: { + zh, ja, en + } +}) + new Vue({ render: h => h(App), - router + router, + i18n }).$mount('#app') diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index fa11db2..4dbe426 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -1,57 +1,57 @@ @@ -109,10 +109,10 @@ export default { window.localStorage.configId = (await config.createRemoteConfig(this.form)).id } } catch (e) { - this.$message.error('保存失败:' + e) + this.$message.error(this.$t('home.failedToSave') + e) return } - this.$message({message: '保存成功', type: 'success'}) + this.$message({message: this.$t('home.successfullySaved'), type: 'success'}) let resolved = this.$router.resolve({name: 'room', params: {roomId: this.form.roomId}, query: {config_id: window.localStorage.configId}}) @@ -141,7 +141,7 @@ export default { try { cfg = JSON.parse(reader.result) } catch (e) { - this.$message.error('配置解析失败:' + e) + this.$message.error(this.$t('home.failedToParseConfig') + e) return } cfg = mergeConfig(cfg, config.DEFAULT_CONFIG) diff --git a/frontend/src/views/StyleGenerator/index.vue b/frontend/src/views/StyleGenerator/index.vue index ea07a52..cde2846 100644 --- a/frontend/src/views/StyleGenerator/index.vue +++ b/frontend/src/views/StyleGenerator/index.vue @@ -2,188 +2,188 @@ -

描边

- +

{{$t('stylegen.outlines')}}

+ - + - + -

头像

- +

{{$t('stylegen.avatars')}}

+ - + -

用户名

- +

{{$t('stylegen.userNames')}}

+ - + - + - + - + - + - + - + - + -

消息

- +

{{$t('stylegen.messages')}}

+ - + - + - + - + -

时间

- +

{{$t('stylegen.time')}}

+ - + - + - + - + -

背景

- +

{{$t('stylegen.backgrounds')}}

+ - + - + - + - + - + -

礼物、舰长

- +

{{$t('stylegen.scAndNewMember')}}

+ - + - + - + - + - + - + - + - + - + - + - + - + - + - + -

动画

- +

{{$t('stylegen.animation')}}

+ - + - + - + - + - + - + - 播放动画 + {{$t('stylegen.playAnimation')}} -

结果

+

{{$t('stylegen.result')}}

- 复制 - 恢复默认设置 + {{$t('stylegen.copy')}} + {{$t('stylegen.resetConfig')}}