Skip to content

Commit

Permalink
Improve locale.
Browse files Browse the repository at this point in the history
  • Loading branch information
LiarOnce committed Jul 18, 2024
1 parent be20426 commit 9be68bd
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 199 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
datas*.json
locales*.json

node_modules
.DS_Store
Expand Down
66 changes: 0 additions & 66 deletions docs/components/filters.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,3 @@
import i18n from "../.vitepress/theme/i18n"
const $t = i18n.global.t;

export const filtersStatus = [
{ text: $t("status.unknown"), value: 0 },
{ text: $t("status.compatible"), value: 1 },
{ text: $t("status.partial"), value: 2 },
{ text: $t("status.new_world"), value: 3 },
{ text: $t("status.unsupported"), value: -1 },
];

export const filtersHardwareBrand = [
{ text: "八位堂(8BitDo)", value: "8BitDo" },
{ text: "威刚(ADATA)", value: "ADATA" },
{ text: "超威半导体(AMD)", value: "AMD" },
{ text: "华硕(ASUS)", value: "ASUS" },
{ text: "艾酷(Akko)", value: "Akko" },
{ text: "兄弟(Brother)", value: "Brother" },
{ text: "七彩虹(Colorful)", value: "Colorful" },
{ text: "英睿达/美光(Crucial/Micron)", value: "Crucial/Micron" },
{ text: "江波龙(longsys/FORESEE)", value: "longsys/FORESEE" },
{ text: "光威(Gloway)", value: "Gloway" },
{ text: "芯动科技(InnoSilicon)", value: "InnoSilicon" },
{ text: "英特尔(Intel)", value: "Intel" },
{ text: "景嘉微(JINGJIA Micro)", value: "JINGJIA Micro" },
{ text: "金百达(KingBank)", value: "KingBank" },
{ text: "金士顿(Kingston)", value: "Kingston" },
{ text: "凌久微电子(Lingjiu Micro)", value: "Lingjiu Micro" },
{ text: "联发科(MediaTek)", value: "MediaTek" },
{ text: "微软(Microsoft)", value: "Microsoft" },
{ text: "摩尔线程(Moore Threads)", value: "Moore Threads" },
{ text: "裕太微电子(Motorcomm)", value: "Motorcomm" },
{ text: "英伟达(NVIDIA)", value: "NVIDIA" },
{ text: "铨兴(Quanxing)", value: "Quanxing" },
{ text: "瑞昱(Realtek)", value: "Realtek" },
{ text: "三星(Samsung)", value: "Samsung" },
{ text: "思得/SK海力士(Solidigm/SK Hynix)", value: "Solidigm/SK Hynix" },
{ text: "西安紫光国芯(UniIC)", value: "UniIC" },
{ text: "西部数据(Western Digital)", value: "Western Digital" },
{ text: "小米(Xiaomi)", value: "Xiaomi" },
{ text: "致态/长江存储(ZHITAI/YMTC)", value: "ZHITAI/YMTC" }
];

export const filtersHardwareType = [
{ text: "内存(UDIMM)", value: "Memory_UDIMM" },
{ text: "内存(UDIMM/ECC)", value: "Memory_UDIMMECC" },
{ text: "内存(RDIMM)", value: "Memory_RDIMM" },
{ text: "内存(SO-DIMM)", value: "Memory_SODIMM" },
{ text: "显卡", value: "GPU" },
{ text: "有线网卡", value: "Ethernet" },
{ text: "无线网卡", value: "Wireless" },
{ text: "固态硬盘(SATA)", value: "SSD_SATA" },
{ text: "固态硬盘(NVMe)", value: "SSD_NVMe" },
{ text: "机械硬盘(SATA)", value: "HDD_SATA" },
{ text: "其他存储类设备(SATA)", value: "Storage_SATA" },
{ text: "键盘", value: "Keyboard" },
{ text: "鼠标", value: "Mouse" },
{ text: "手柄控制器", value: "Gamepad" },
{ text: "打印机", value: "Printer" },
{ text: "扫描仪", value: "Scanner" },
{ text: "打印复印一体机", value: "Printer_AIO" },
{ text: "PCIe 扩展卡", value: "PCIe_Card" },
{ text: "USB 设备", value: "USB_Device" },
{ text: "固件", value: "Firmware" }
];

export const filtersLatStatus = [
{ text: "未知", value: 0 },
{ text: "兼容", value: 1 },
Expand Down
126 changes: 0 additions & 126 deletions docs/components/filters.json

This file was deleted.

18 changes: 12 additions & 6 deletions docs/components/hardwares.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
>
<el-table-column prop="model" :label="$t('components.model')" width="300" />
<el-table-column prop="brand" :label="$t('components.brand')" column-key="brand" width="150" sortable
:filters="filtersHardwareBrand"
:filters="filter_data[current_lang].filters_hardware_brand"
:filter-method="filterBrand"
/>
<el-table-column prop="type" :label="$t('components.type')" width="200"
:filters="filtersHardwareType"
:filters="filter_data[current_lang].filters_hardware_type"
:filter-method="filterType"
filter-placement="bottom-end"
>
<template #default="scope">
<span v-for="(hardware, index) in filtersHardwareType" :key="index">
<span v-for="(hardware, index) in filter_data[current_lang].filters_hardware_type" :key="index">
<span v-if="scope.row.type == hardware.value">{{ hardware.text }}</span>
</span>
</template>
</el-table-column>
<el-table-column prop="status" :label="$t('components.status')" width="170"
:filters="filtersStatus"
:filters="filter_data[current_lang].filters_status"
:filter-method="filterStatus"
filter-placement="bottom-end"
>
Expand All @@ -33,7 +33,12 @@
<el-tag v-if="scope.row.status == -1" type="danger">{{ $t('status.unsupported') }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="notes" :label="$t('components.notes')" min-width="200" />
<el-table-column prop="notes" :label="$t('components.notes')" min-width="200">
<template #default="scope">
<span v-if="current_lang == 'en' && scope.row.notes_en">{{ scope.row.notes_en }}</span>
<span v-else>{{ scope.row.notes }}</span>
</template>
</el-table-column>
<el-table-column prop="link" :label="$t('components.link')" width="60">
<template #default="scope">
<span v-if="scope.row.link"><a :href="scope.row.link">{{ $t('components.doc_link') }}</a></span>
Expand All @@ -49,8 +54,9 @@ import { useI18n } from 'vue-i18n'
const { locale } = useI18n()
import databaseJson from '../data/datas.min.json'
import filter_data from '../data/locales.min.json'
const current_lang = document.documentElement.lang
import { filtersHardwareBrand, filtersHardwareType, filtersStatus } from './filters.js'
// let filtersJson
const tableRef = ref()
Expand Down
14 changes: 13 additions & 1 deletion docs/data/generateDatabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { glob } from "glob"
// Fix __filename and __dirname in ESM
import { fileURLToPath } from 'url'
import { dirname } from 'path'
import { type } from "os"
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(fileURLToPath(import.meta.url))

Expand All @@ -14,6 +15,11 @@ const json_template = {
liblol: []
}

const locale_template = {
zh: {},
en: {}
}

const glob_options = {
ignore: ['**/template*.yml']
}
Expand All @@ -39,10 +45,16 @@ liblol.forEach(files => {
json_template.liblol.push(jsonResult)
})

// Generate locales
locale_template.zh = JSON.parse(fs.readFileSync(__dirname + "/locales/zh.json"))
locale_template.en = JSON.parse(fs.readFileSync(__dirname + "/locales/en.json"))
// End

// console.log(json_template)
if(fs.existsSync(__dirname + "/datas.json") || fs.existsSync(__dirname + "/datas.min.json")){
fs.rmSync(__dirname + "/datas.json")
fs.rmSync(__dirname + "/datas.min.json")
}
fs.writeFileSync(__dirname + "/datas.json", JSON.stringify(json_template, null, "\t"))
fs.writeFileSync(__dirname + "/datas.min.json", JSON.stringify(json_template))
fs.writeFileSync(__dirname + "/datas.min.json", JSON.stringify(json_template))
fs.writeFileSync(__dirname + "/locales.min.json", JSON.stringify(locale_template))
62 changes: 62 additions & 0 deletions docs/data/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"filters_status": [
{ "text": "Unknown", "value": 0 },
{ "text": "Compatible", "value": 1 },
{ "text": "Partial Support", "value": 2 },
{ "text": "New-world Available", "value": 3 },
{ "text": "Unsupported", "value": -1 }
],
"filters_hardware_brand": [
{ "text": "8BitDo", "value": "8BitDo" },
{ "text": "ADATA", "value": "ADATA" },
{ "text": "AMD", "value": "AMD" },
{ "text": "ASUS", "value": "ASUS" },
{ "text": "Akko", "value": "Akko" },
{ "text": "Brother", "value": "Brother" },
{ "text": "Colorful", "value": "Colorful" },
{ "text": "Crucial/Micron", "value": "Crucial/Micron" },
{ "text": "longsys/FORESEE", "value": "longsys/FORESEE" },
{ "text": "Gloway", "value": "Gloway" },
{ "text": "InnoSilicon", "value": "InnoSilicon" },
{ "text": "Intel", "value": "Intel" },
{ "text": "JINGJIA Micro", "value": "JINGJIA Micro" },
{ "text": "KingBank", "value": "KingBank" },
{ "text": "Kingston", "value": "Kingston" },
{ "text": "Lingjiu Micro", "value": "Lingjiu Micro" },
{ "text": "MediaTek", "value": "MediaTek" },
{ "text": "Microsoft", "value": "Microsoft" },
{ "text": "Moore Threads", "value": "Moore Threads" },
{ "text": "Motorcomm", "value": "Motorcomm" },
{ "text": "NVIDIA", "value": "NVIDIA" },
{ "text": "Quanxing", "value": "Quanxing" },
{ "text": "Realtek", "value": "Realtek" },
{ "text": "Samsung", "value": "Samsung" },
{ "text": "Solidigm/SK Hynix", "value": "Solidigm/SK Hynix" },
{ "text": "UniIC", "value": "UniIC" },
{ "text": "Western Digital", "value": "Western Digital" },
{ "text": "Xiaomi", "value": "Xiaomi" },
{ "text": "ZHITAI/YMTC", "value": "ZHITAI/YMTC" }
],
"filters_hardware_type": [
{ "text": "Memory UDIMM", "value": "Memory_UDIMM" },
{ "text": "Memory UDIMM/ECC", "value": "Memory_UDIMMECC" },
{ "text": "Memory RDIMM", "value": "Memory_RDIMM" },
{ "text": "Memory SO-DIMM", "value": "Memory_SODIMM" },
{ "text": "GPU", "value": "GPU" },
{ "text": "Ethernet", "value": "Ethernet" },
{ "text": "Wireless", "value": "Wireless" },
{ "text": "SATA SSD", "value": "SSD_SATA" },
{ "text": "NVMe SSD", "value": "SSD_NVMe" },
{ "text": "SATA HDD", "value": "HDD_SATA" },
{ "text": "SATA Storage", "value": "Storage_SATA" },
{ "text": "Keyboard", "value": "Keyboard" },
{ "text": "Mouse", "value": "Mouse" },
{ "text": "Gamepad", "value": "Gamepad" },
{ "text": "Printer", "value": "Printer" },
{ "text": "Scanner", "value": "Scanner" },
{ "text": "Printer All-in-One", "value": "Printer_AIO" },
{ "text": "PCIe Card", "value": "PCIe_Card" },
{ "text": "USB Devices", "value": "USB_Device" },
{ "text": "Firmware", "value": "Firmware" }
]
}
Loading

0 comments on commit 9be68bd

Please sign in to comment.