Skip to content

Commit 2752ad3

Browse files
author
gzg1023
committed
Fix Modify the title when changing language & Modify the lang tag of html
1 parent 60320ad commit 2752ad3

File tree

8 files changed

+19
-8
lines changed

8 files changed

+19
-8
lines changed

src/components/LangSelect/index.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<script lang="ts">
5555
import { Component, Vue } from 'vue-property-decorator'
5656
import { AppModule } from '@/store/modules/app'
57-
57+
import settings from '../../settings'
5858
@Component({
5959
name: 'Login'
6060
})
@@ -66,8 +66,11 @@ export default class extends Vue {
6666
private handleSetLanguage(lang: string) {
6767
this.$i18n.locale = lang
6868
AppModule.SetLanguage(lang)
69+
document.documentElement.lang = lang
70+
const title = this.$route.meta.title ? `${this.$t(`route.${this.$route.meta.title}`)} - ${settings.title}` : `${settings.title}`
71+
document.title = title
6972
this.$message({
70-
message: 'Switch Language Success',
73+
message: this.$t('components.changeLanguageTips').toString(),
7174
type: 'success'
7275
})
7376
}

src/lang/en.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export default {
105105
stickyTips: 'when the page is scrolled to the preset position will be sticky on the top.',
106106
backToTopTips1: 'When the page is scrolled to the specified position, the Back to Top button appears in the lower right corner',
107107
backToTopTips2: 'You can customize the style of the button, show / hide, height of appearance, height of the return. If you need a text prompt, you can use element-ui el-tooltip elements externally',
108-
imageUploadTips: 'Since I was using only the vue@1 version, and it is not compatible with mockjs at the moment, I modified it myself, and if you are going to use it, it is better to use official version.'
108+
imageUploadTips: 'Since I was using only the vue@1 version, and it is not compatible with mockjs at the moment, I modified it myself, and if you are going to use it, it is better to use official version.',
109+
changeLanguageTips: 'Switch Language Success'
109110
},
110111
table: {
111112
dynamicTips1: 'Fixed header, sorted by header order',

src/lang/es.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export default {
105105
stickyTips: 'when the page is scrolled to the preset position will be sticky on the top.',
106106
backToTopTips1: 'When the page is scrolled to the specified position, the Back to Top button appears in the lower right corner',
107107
backToTopTips2: 'You can customize the style of the button, show / hide, height of appearance, height of the return. If you need a text prompt, you can use element-ui el-tooltip elements externally',
108-
imageUploadTips: 'Since I was using only the vue@1 version, and it is not compatible with mockjs at the moment, I modified it myself, and if you are going to use it, it is better to use official version.'
108+
imageUploadTips: 'Since I was using only the vue@1 version, and it is not compatible with mockjs at the moment, I modified it myself, and if you are going to use it, it is better to use official version.',
109+
changeLanguageTips: 'Cambiar de idioma correctamente'
109110
},
110111
table: {
111112
dynamicTips1: 'Fixed header, sorted by header order',

src/lang/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ const messages = {
4949
export const getLocale = () => {
5050
const cookieLanguage = getLanguage()
5151
if (cookieLanguage) {
52+
document.documentElement.lang = cookieLanguage
5253
return cookieLanguage
5354
}
5455

5556
const language = navigator.language.toLowerCase()
5657
const locales = Object.keys(messages)
5758
for (const locale of locales) {
5859
if (language.indexOf(locale) > -1) {
60+
document.documentElement.lang = locale
5961
return locale
6062
}
6163
}

src/lang/it.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export default {
105105
tinymceTips: 'Il testo ricco è una funzionalità fondamentale della gestione backend, ma allo stesso tempo è un posto molto scosceso. Nel processo di selezionare un Rich Text editor o fatto molte ricerche. I Rich Text editor comuni sul mercato sono molto usati, per questo alla fine ho scelto Tinymce. Vedi la più dettagliata comparazione e introduzione al Rich text editor.',
106106
backToTopTips1: 'Quando la pagina viene spostata alla posizione specificata, il bottone "Torna Su" compare nell\'angolo in basso a destra',
107107
backToTopTips2: 'Puoi personalizzare lo stile dei bottoni, mostra / nascondi, altezza di apparizione, altezza del ritorno a capo. Se hai bisogno di un prompt di testo, puoi utilizzare gli elementi element-ui el-tooltip esternamente',
108-
imageUploadTips: 'Da quando usavo la verione 1 di Vue che non è compatibile con mockjs, la ho modificata io stesst, e se la userai, è meglio utilizzare versioni ufficiali.'
108+
imageUploadTips: 'Da quando usavo la verione 1 di Vue che non è compatibile con mockjs, la ho modificata io stesst, e se la userai, è meglio utilizzare versioni ufficiali.',
109+
changeLanguageTips: 'Cambio lingua riuscito'
109110
},
110111
table: {
111112
dynamicTips1: 'Intestazione Fissa, ordinato dall\'ordine delle intestazioni',

src/lang/ja.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export default {
105105
stickyTips: 'ページの指定位置へスクロールした場合、表示されます。',
106106
backToTopTips1: 'トップへスクロールが表示されます。',
107107
backToTopTips2: 'ボタンのスタイルはカスタマイズできます。例えば、show/hide、height、position。 またはElementのel-tooltipを使って、ツールチップを実装できます。',
108-
imageUploadTips: 'mockjsは使えないため、カスタマイズしています。公式の最新バージョンを使ってください。'
108+
imageUploadTips: 'mockjsは使えないため、カスタマイズしています。公式の最新バージョンを使ってください。',
109+
changeLanguageTips: '言語切り替えの成功'
109110
},
110111
table: {
111112
dynamicTips1: '先頭は固定、最後に追加',

src/lang/ko.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export default {
105105
stickyTips: '페이지의 지정된 위치에 스크롤하면 나타납니다.',
106106
backToTopTips1: '페이지가 지정된 위치로 스크롤되면 맨 아래 오른쪽 모서리에 맨 위로 이동 단추가 나타납니다.',
107107
backToTopTips2: '버튼 스타일, 표시 / 숨기기, 모양 높이, 반환 높이를 사용자 정의 할 수 있습니다. 텍스트 프롬프트가 필요한 경우 element-ui el-tooltip 요소를 외부에서 사용할 수 있습니다',
108-
imageUploadTips: 'vue @ 1 버전 만 사용하고 있었고 현재 mockjs와 호환되지 않기 때문에 직접 수정했으며 사용하려는 경우 공식 버전을 사용하는 것이 좋습니다.'
108+
imageUploadTips: 'vue @ 1 버전 만 사용하고 있었고 현재 mockjs와 호환되지 않기 때문에 직접 수정했으며 사용하려는 경우 공식 버전을 사용하는 것이 좋습니다.',
109+
changeLanguageTips: '언어 전환 성공'
109110
},
110111
table: {
111112
dynamicTips1: '정렬된 헤더',

src/lang/zh.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export default {
105105
stickyTips: '当页面滚动到预设的位置会吸附在顶部',
106106
backToTopTips1: '页面滚动到指定位置会在右下角出现返回顶部按钮',
107107
backToTopTips2: '可自定义按钮的样式、show/hide、出现的高度、返回的位置 如需文字提示,可在外部使用Element的el-tooltip元素',
108-
imageUploadTips: '由于我在使用时它只有vue@1版本,而且和mockjs不兼容,所以自己改造了一下,如果大家要使用的话,优先还是使用官方版本。'
108+
imageUploadTips: '由于我在使用时它只有vue@1版本,而且和mockjs不兼容,所以自己改造了一下,如果大家要使用的话,优先还是使用官方版本。',
109+
changeLanguageTips: '切换语言成功'
109110
},
110111
table: {
111112
dynamicTips1: '固定表头, 按照表头顺序排序',

0 commit comments

Comments
 (0)