国际化

This commit is contained in:
John
2024-03-10 12:04:23 +08:00
parent 44e109ae4b
commit b734a72fc6
7 changed files with 217 additions and 39 deletions

View File

@@ -18,17 +18,19 @@
<script setup lang="ts">
import { getDefaultLocal } from '@/api/system/user';
const lang = localStorage.getItem('lang')
if (!lang) {
const _getDefaultLocal = () => {
getDefaultLocal().then(res => {
console.log('res', res)
if (res === 'gu_IN') {
localStorage.setItem('lang', 'hi')
} else {
localStorage.setItem('lang', 'zh')
if (lang !== res) {
localStorage.setItem('lang', res)
location.reload()
}
location.reload()
})
}
_getDefaultLocal()
</script>
<style>

175
src/lang/en_us.ts Normal file
View File

@@ -0,0 +1,175 @@
// en_us.js文件
export default {
app: {
home: 'Home',
serveList: 'Wallet',
message: 'Customer Service',
my: 'Mine',
yuan: 'Yuan',
second: 'Second',
month: 'Month',
prompt: 'Prompt',
tips: 'Tips',
enterLogout: 'Are you sure you want to log out?',
enterWithdrawal: 'Are you sure you want to withdraw?',
withdrawal: 'Withdrawal',
info: 'Info',
success: 'Success',
withdrawalAmount: 'Withdrawal Amount',
pleaseWithdrawalAmount: 'Please enter the withdrawal amount',
submit: 'Submit',
submittedSuccessfully: 'Successfully submitted',
submitApplication: 'Submit Application',
bankCardAbnormality: 'Bank card abnormality',
receivedSuccessfully: 'Received successfully',
phoneNumber: 'Phone number',
verificationCode: 'Verification code',
confirm: 'Confirm',
enter: 'Please enter',
select: 'Please select',
send: 'Send',
login: 'Login',
account: 'Account',
logout: 'Logout',
register: 'Register',
password: 'Password',
forgotPassword: 'Forgot password',
passwordPlaceholder: 'Please set a password of 6-16 digits',
passwordPlaceholder1: 'Please confirm the password again',
next: 'Next',
update: 'Update',
noData: 'No data',
none: 'None',
contract: 'Contract',
loan: 'Loan',
totalLoan: 'Total loan',
complete: 'Complete',
noComplete: 'Incomplete',
signature: 'Signature',
identityInformation: 'Identity information',
information: 'Information',
signatureInformation: 'Signature information',
receivingBank: 'Receiving bank card',
rwmljndzlxx: 'Let us know your information',
upPNGOrJPG: 'Please upload a JPG or PNG format image',
},
home: {
productDetails: 'Product Details',
minimumDailyInterestRate: 'Minimum Daily Interest Rate',
borrowingLimit: 'Borrowing Limit',
installmentPeriod: 'Installment Period',
optional: 'Optional',
applicationAmount: 'Application Amount',
loanTerm: 'Loan Term',
repaymentPerInstallment: 'Repayment Per Installment',
dailyInterestRate: 'Daily Interest Rate',
totalInterest: 'Total Interest',
successfulBorrowing: 'Successful Borrowing',
enterAgreement: 'I have read and agreed to',
authAgreement: 'Authorization Agreement',
serviceAgreement: 'Platform Service Agreement',
lawAgreement: 'Legal Agreement',
loansAgreement: 'Loan Agreement',
immediateBorrowing: 'Borrow Now',
pleaseFillInYourPersonalInformationFirst: 'Please fill in your personal information first',
pleaseEnterAgreement: 'Please read and agree to the relevant agreements',
},
my: {
userInfo: 'My Profile',
loan: 'My Loans',
repayment: 'My Repayments',
legalLiability: 'Legal Liability',
uploadPassword: 'Change Password',
logout: 'Logout',
language: 'Switch Language',
},
serveList: {
loan: 'My Loans',
balance: 'Account Balance',
amountToBeRepaid: 'Amount to Be Repaid',
immediateWithdrawal: 'Borrow Now',
financialSecurity: 'Account funds security is guaranteed by the bank',
},
borrowInfo: {
applicationTime: 'Application Time',
loanDetails: 'Loan Details',
loanInfo: 'Borrowing Information',
loanNo: 'Loan Number',
loanAmount: 'Loan Amount',
loanCycle: 'Loan Cycle',
withdrawalBank: 'Withdrawal Bank',
repaymentPerInstallment: 'Repayment Per Installment',
describe: 'Description',
receivingAccount: 'Receiving Account',
usageOfLoan: 'Purpose of Loan',
},
loans: {
enterSubmitApplication: 'Are you sure you want to apply for a loan?'
},
userInfo: {
realPrompt: 'Please fill in true and valid information to pass the review.',
idCardPrompt: 'Please use your own ID card, and make sure the content is clear and readable.',
photographPrompt: 'Please confirm that the camera permission is enabled.',
name: 'Name',
idCard: 'ID Card Number',
idCardUp1: 'Click to upload the front side of your ID card',
idCardUp2: 'Click to upload the back side of your ID card (with the national emblem)',
idCardUp3: 'Click to upload a photo holding your ID card',
shootingRequirements: 'Photography Requirements',
standardShooting: 'Standard Shooting',
missingBorder: 'Missing Borders',
outOfFocus: 'Blurry Photo',
flashStrongly: 'Strong Flash',
unitName: 'Company Name',
position: 'Position',
workTelephone: 'Work Phone',
workingAge: 'Years of Work Experience',
monthlyPay: 'Monthly Salary',
unitAddress: 'Company Address',
addressInfo: 'Detailed Address',
currentResidentialAddress: 'Current Residential Address',
directFamilyContactPerson: 'Immediate Family Contact',
relationship: 'Relationship',
parents: 'Parents',
spouse: 'Spouse',
children: 'Children',
grandparents: 'Grandparents',
bankOfDeposit: 'Bank of Deposit',
bankCard: 'Bank Card Number',
},
router: {
home: 'Home',
serveList: 'Wallet',
message: 'Chat',
my: 'Mine',
userInfo: 'My Profile',
userInfo1: 'Basic Information',
signature: 'Signature',
contract: 'Contract',
userInfo2: 'Submit Documents',
userInfo3: 'Receiving Bank Card',
loansInfo: 'Loan Details',
loansInfo1: 'Withdrawal',
myLoan: 'My Loans',
myRepayment: 'My Repayments',
borrowInfo: 'Borrowing Details',
uploadPassword: 'Change Password',
login: 'Login',
register: 'Register',
forget: 'Forgot Password',
agreement: 'Agreement',
}
}

View File

@@ -137,11 +137,6 @@ export default {
bankOfDeposit: 'खाता खोलने वाला बैंक',
bankCard: 'बैंक कार्ड नंबर',
},
language: {
zh: '中文',
id: 'Bahasa indonesia',
hi: 'हिंदी'
},
router: {
home: 'मुख्य पृष्ठ',
serveList: 'वॉलेट',

View File

@@ -137,11 +137,6 @@ export default {
bankOfDeposit: 'Bank tempat rekening',
bankCard: 'Nomor rekening bank',
},
language: {
zh: '中文',
id: 'Bahasa indonesia',
hi: 'हिंदी'
},
router: {
home: 'Beranda',
serveList: 'Dompet',

View File

@@ -3,9 +3,11 @@ import {Locale} from 'vant'
import zhCN from 'vant/lib/locale/lang/zh-CN'
import idId from 'vant/lib/locale/lang/id-ID'
import hiIN from 'vant/lib/locale/lang/hi-IN'
import enUS from 'vant/lib/locale/lang/en-US'
import zhLocale from './zh_cn'
import idLocale from './id_ID'
import hiLocale from './hi-IN'
import enLocale from './en_us'
import type { App } from 'vue';
@@ -21,6 +23,10 @@ const messages = {
hi: {
...hiIN,
...hiLocale
},
en: {
...enUS,
...enLocale
}
}
@@ -40,15 +46,24 @@ const i18n = createI18n({
// 更新vant组件库本身的语言变化支持国际化
function vantLocales (app: App<Element>) {
app.use(i18n)
const lan = defLanguage || language.split('-')[0] || 'zh'
if (lan === 'hi') {
Locale.use(lan, hiIN)
console.log('========================', lan)
} else if (lan === 'id') {
Locale.use(lan, idId)
} else {
Locale.use(lan, zhCN)
const lan = defLanguage || language.split('-')[0] || 'zh-CN'
const lanMap = {
'hi-IN': hiIN,
'id-ID': idId,
'zh-CN': zhCN,
'en-US': enUS,
}
Locale.use(lan, lanMap[lan] || zhCN)
// if (lan === 'hi') {
// Locale.use(lan, hiIN)
// console.log('========================', lan)
// } else if (lan === 'id') {
// Locale.use(lan, idId)
// } else {
// Locale.use(lan, zhCN)
// }
}
export {i18n, vantLocales}

View File

@@ -137,11 +137,6 @@ export default {
bankOfDeposit: '开户银行',
bankCard: '银行卡号',
},
language: {
zh: '中文',
id: 'Bahasa indonesia',
hi: 'हिंदी'
},
router: {
home: '首页',
serveList: '钱包',

View File

@@ -67,13 +67,13 @@
</div>
</template>
</van-cell>
<van-cell :title="$t('my.language')" is-link @click="checkLanguage()" >
<template #icon>
<div style="display: flex; justify-content: center; align-items: center; padding-right: 5px">
<van-icon name="chat-o" />
</div>
</template>
</van-cell>
<!-- <van-cell :title="$t('my.language')" is-link @click="checkLanguage()" >-->
<!-- <template #icon>-->
<!-- <div style="display: flex; justify-content: center; align-items: center; padding-right: 5px">-->
<!-- <van-icon name="chat-o" />-->
<!-- </div>-->
<!-- </template>-->
<!-- </van-cell>-->
<van-cell :title="$t('my.logout')" is-link @click="logout" >
<template #icon>
<div style="display: flex; justify-content: center; align-items: center; padding-right: 5px">
@@ -154,9 +154,10 @@ const checkLanguage = () => {
const showPicker = ref(false)
const columns = [
{ text: '中文', value: 'zh' },
{ text: 'Bahasa indonesia', value: 'id' },
{ text: 'हिंदी', value: 'hi' },
{ text: '中文', value: 'zh-CN' },
{ text: 'Bahasa indonesia', value: 'id-ID' },
{ text: 'हिंदी', value: 'hi-IN' },
{ text: 'English', value: 'en-US' },
// { text: t('language.zh'), value: 'zh' },
// { text: t('language.hi'), value: 'hi' },
// { text: t('language.id'), value: 'id' },