feat: add translation feature and ban character set functionality

This commit is contained in:
Kwaroran
2024-12-29 04:03:21 +09:00
parent ebdcd5ffcd
commit cd092a5a01
12 changed files with 221 additions and 56 deletions

View File

@@ -2261,4 +2261,36 @@ export class PerformanceDebugger{
this.kv[key].push(...other.kv[key])
}
}
}
export function getLanguageCodes(){
let languageCodes:{
code: string
name: string
}[] = []
for(let i=0x41;i<=0x5A;i++){
for(let j=0x41;j<=0x5A;j++){
languageCodes.push({
code: String.fromCharCode(i) + String.fromCharCode(j),
name: ''
})
}
}
languageCodes = languageCodes.map(v => {
return {
code: v.code.toLocaleLowerCase(),
name: new Intl.DisplayNames([
DBState.db.language === 'cn' ? 'zh' : DBState.db.language
], {
type: 'language',
fallback: 'none'
}).of(v.code)
}
}).filter((a) => {
return a.name
}).sort((a, b) => a.name.localeCompare(b.name))
return languageCodes
}