mirror of
https://github.com/kmvan/x-prober.git
synced 2026-08-26 21:07:17 +08:00
rebuild language module
change module to ESM
This commit is contained in:
@@ -28,7 +28,21 @@
|
||||
],
|
||||
"plugins": ["prettier", "@typescript-eslint", "react-hooks"],
|
||||
"rules": {
|
||||
"prettier/prettier": "error",
|
||||
"prettier/prettier": [
|
||||
"error",
|
||||
{
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"jsxSingleQuote": true,
|
||||
"singleQuote": true,
|
||||
"quoteProps": "as-needed",
|
||||
"bracketSameLine": false,
|
||||
"trailingComma": "all",
|
||||
"bracketSpacing": true,
|
||||
"semi": false,
|
||||
"arrowParens": "always"
|
||||
}
|
||||
],
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
|
||||
"semi": ["error", "never"],
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
"singleQuote": true,
|
||||
"quoteProps": "as-needed",
|
||||
"bracketSameLine": false,
|
||||
"trailingComma": "es5",
|
||||
"trailingComma": "all",
|
||||
"bracketSpacing": true,
|
||||
"semi": false,
|
||||
"arrowParens": "always"
|
||||
|
||||
-131
@@ -1,131 +0,0 @@
|
||||
/**
|
||||
* @version 1.0.5
|
||||
*/
|
||||
|
||||
const glob = require('glob')
|
||||
const fs = require('fs')
|
||||
const PO = require('pofile')
|
||||
const path = require('path')
|
||||
const dirSrc = path.resolve(__dirname, 'src')
|
||||
const dirComponents = `${dirSrc}/Components`
|
||||
const langs = {}
|
||||
const poEntries = {}
|
||||
const deepSort = require('deep-sort-object')
|
||||
const parseFile = (filePath) => {
|
||||
const code = fs.readFileSync(filePath).toString()
|
||||
const reg = new RegExp(
|
||||
`gettext\\s*\\(\\s*('.+?')\\s*,*\\s*('.+?')*\\s*\\)`,
|
||||
'gm'
|
||||
)
|
||||
|
||||
const matches = code.matchAll(reg)
|
||||
|
||||
if (matches) {
|
||||
for (const match of matches) {
|
||||
const msgid = match[1].slice(1, -1)
|
||||
const msgctxt = (match[2] || '').slice(1, -1)
|
||||
if (poEntries[`${msgid}${msgctxt}`]) {
|
||||
continue
|
||||
}
|
||||
|
||||
poEntries[`${msgid}${msgctxt}`] = `
|
||||
${msgctxt ? `msgctxt ${JSON.stringify(msgctxt)}` : ''}
|
||||
msgid ${JSON.stringify(msgid)}
|
||||
msgstr ""
|
||||
`.trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fetchDirOrFile = (filePathOrDir) => {
|
||||
if (fs.lstatSync(filePathOrDir).isDirectory()) {
|
||||
fs.readdirSync(filePathOrDir).map((p) =>
|
||||
fetchDirOrFile(`${filePathOrDir}/${p}`)
|
||||
)
|
||||
} else {
|
||||
if (['.ts', '.tsx'].includes(path.extname(filePathOrDir))) {
|
||||
parseFile(filePathOrDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const createPot = () => {
|
||||
const toWriteData = `
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \\n"
|
||||
"POT-Creation-Date: \\n"
|
||||
"PO-Revision-Date: \\n"
|
||||
"Last-Translator: \\n"
|
||||
"Language-Team: \\n"
|
||||
"MIME-Version: 1.0\\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\\n"
|
||||
"Content-Transfer-Encoding: 8bit\\n"
|
||||
"X-Generator: Poedit 2.2.1\\n"
|
||||
"X-Poedit-Basepath: ../src\\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\\n"
|
||||
"X-Poedit-KeywordsList: gettext\\n"
|
||||
|
||||
${Object.values(poEntries).join('\n\n')}
|
||||
`.trim()
|
||||
// write pot
|
||||
fs.writeFileSync(
|
||||
path.resolve(__dirname, 'languages/lang.pot'),
|
||||
toWriteData,
|
||||
'utf8'
|
||||
)
|
||||
}
|
||||
|
||||
fetchDirOrFile(dirComponents)
|
||||
// create pot
|
||||
createPot()
|
||||
|
||||
const formatItem = (items) => {
|
||||
return items.map(({ msgctxt, msgid, msgstr }) => {
|
||||
return {
|
||||
msgctxt,
|
||||
msgid,
|
||||
msgstr: msgstr[0],
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const getItem = async (filepath) => {
|
||||
return new Promise((resolve) => {
|
||||
PO.load(filepath, (err, data) => {
|
||||
const langId = path.basename(filepath, '.po')
|
||||
const items = formatItem(data.items)
|
||||
resolve({
|
||||
items,
|
||||
langId,
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const writeJsData = ({ langId, items }) => {
|
||||
items.map(({ msgstr, msgid, msgctxt }) => {
|
||||
const key = `${msgctxt || ''}${msgid}`
|
||||
if (!langs[key]) {
|
||||
langs[key] = {}
|
||||
}
|
||||
langId = langId.toLowerCase().replace('-', '').replace('_', '')
|
||||
langs[key][langId] = msgstr
|
||||
})
|
||||
|
||||
fs.writeFileSync(
|
||||
path.resolve(__dirname, 'src/Components/Language/lang.json'),
|
||||
JSON.stringify(deepSort(langs), null, 2),
|
||||
(err) => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
glob.sync(path.resolve(__dirname, 'languages/*.po')).map(async (filepath) => {
|
||||
writeJsData(await getItem(filepath))
|
||||
})
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"module": "es6",
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
@@ -4,12 +4,12 @@ msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Last-Translator: Km.Van\n"
|
||||
"Language-Team: INN STUDIO\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.2.1\n"
|
||||
"X-Generator: Poedit 3.0.1\n"
|
||||
"X-Poedit-Basepath: ../src\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
+4
-4
@@ -4,10 +4,10 @@
|
||||
"license": "GPL-3",
|
||||
"homepage": "https://github.com/kmvan/x-prober",
|
||||
"scripts": {
|
||||
"lang": "node ./build-lang.js",
|
||||
"dev": "webpack --config webpack.config.js --progress",
|
||||
"lang": "node ./tools/lang-builder.mjs",
|
||||
"dev": "webpack --config webpack.config.mjs",
|
||||
"dev:php": "php ./Make.php dev; php -S localhost:8000 -t .tmp",
|
||||
"build": "webpack --config webpack.config.prod.js --progress",
|
||||
"build": "webpack --config webpack.config.prod.mjs",
|
||||
"build:php": "php-cs-fixer fix ./src --config=.php-cs-fixer53; php ./Make.php build; echo '\nPlease access via http://localhost:8001/prober.php'; php -S localhost:8001 -t dist",
|
||||
"build:php-debug": "php ./Make.php build debug; echo '\nPlease access via http://localhost:8001/prober.php'; php -S localhost:8001 -t dist",
|
||||
"php-cs-fixer-53": "php-cs-fixer fix ./src --config=.php-cs-fixer53"
|
||||
@@ -41,7 +41,7 @@
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"eslint-plugin-react": "^7.29.4",
|
||||
"eslint-plugin-react-hooks": "^4.4.0",
|
||||
"glob": "^7.2.0",
|
||||
"fast-glob": "^3.2.11",
|
||||
"pofile": "^1.1.3",
|
||||
"prettier": "^2.6.1",
|
||||
"terser-webpack-plugin": "^5.3.1",
|
||||
|
||||
@@ -6,103 +6,6 @@
|
||||
"zhhk": "(最新 {{latestPhpVersion}})",
|
||||
"zhtw": "(最新 {{latestPhpVersion}})"
|
||||
},
|
||||
"{{days}} days {{hours}} hours {{mins}} mins {{secs}} secs": {
|
||||
"ja": "{{days}} 日 {{hours}} 時 {{mins}} 分 {{secs}} 秒",
|
||||
"zh": "{{days}} 天 {{hours}} 小时 {{mins}} 分 {{secs}} 秒",
|
||||
"zhcn": "{{days}} 天 {{hours}} 小时 {{mins}} 分 {{secs}} 秒",
|
||||
"zhhk": "{{days}} 天 {{hours}} 時 {{mins}} 分 {{secs}} 秒",
|
||||
"zhtw": "{{days}} 天 {{hours}} 時 {{mins}} 分 {{secs}} 秒"
|
||||
},
|
||||
"{{minute}} minute average": {
|
||||
"ja": "{{minute}} 分ごとの平均負荷",
|
||||
"zh": "{{minute}} 分钟平均负载",
|
||||
"zhcn": "{{minute}} 分钟平均负载",
|
||||
"zhhk": "{{minute}} 分鐘平均負載",
|
||||
"zhtw": "{{minute}} 分鐘平均負載"
|
||||
},
|
||||
"{{sensor}} temperature": {
|
||||
"ja": "{{sensor}} 温度",
|
||||
"zh": "{{sensor}} 温度",
|
||||
"zhcn": "{{sensor}} 温度",
|
||||
"zhhk": "{{sensor}} 溫度",
|
||||
"zhtw": "{{sensor}} 溫度"
|
||||
},
|
||||
"⏳ Please wait {{seconds}}s": {
|
||||
"ja": "⏳ {{seconds}} 秒お待ちください",
|
||||
"zh": "⏳ 请等待 {{seconds}}秒",
|
||||
"zhcn": "⏳ 请等待 {{seconds}}秒",
|
||||
"zhhk": "⏳ 請等待 {{seconds}} 秒",
|
||||
"zhtw": "⏳ 請等待 {{seconds}} 秒"
|
||||
},
|
||||
"⏳ Testing, please wait...": {
|
||||
"ja": "⏳ テストしています。お待ちください...",
|
||||
"zh": "⏳ 跑分中,请稍等……",
|
||||
"zhcn": "⏳ 跑分中,请稍等……",
|
||||
"zhhk": "⏳ 跑分中,請稍等……",
|
||||
"zhtw": "⏳ 跑分中,請稍等……"
|
||||
},
|
||||
"⏳ Updating, please wait a second...": {
|
||||
"ja": "⏳ 更新しています。しばらくお待ちください...",
|
||||
"zh": "⏳ 更新中,请稍等一会……",
|
||||
"zhcn": "⏳ 更新中,请稍等一会……",
|
||||
"zhhk": "⏳ 更新中,請稍等……",
|
||||
"zhtw": "⏳ 更新中,請稍等……"
|
||||
},
|
||||
"⏸️ Stop ping": {
|
||||
"ja": "⏸️ Pingを停止",
|
||||
"zh": "⏸️ 停止 Ping",
|
||||
"zhcn": "⏸️ 停止 Ping",
|
||||
"zhhk": "⏸️ 停止 Ping",
|
||||
"zhtw": "⏸️ 停止 Ping"
|
||||
},
|
||||
"⚔️ Different versions cannot be compared, and different time servers have different loads, just for reference.": {
|
||||
"zh": "⚔️ 不同版本的不能比较,不同的时间服务器存在不同的负载,仅作参考。",
|
||||
"zhcn": "⚔️ 不同版本的不能比较,不同的时间服务器存在不同的负载,仅作参考。",
|
||||
"zhhk": "不同的版本有不同的分數,不同的時間伺服器有不同的負載,僅供參考。",
|
||||
"zhtw": "⚔️ 不同版本無法比較,不同時間的伺服器具有不同的負載,僅供參考。"
|
||||
},
|
||||
"✨ Found update! Version {{oldVersion}} → {{newVersion}}": {
|
||||
"ja": "✨ アップデートが見た!バージョン {{oldVersion}} → {{newVersion}}",
|
||||
"zh": "✨ 发现更新!版本 {{oldVersion}} → {{newVersion}}",
|
||||
"zhcn": "✨ 发现更新!版本 {{oldVersion}} → {{newVersion}}",
|
||||
"zhhk": "✨ 發現更新!版本 {{oldVersion}} → {{newVersion}}",
|
||||
"zhtw": "✨ 發現更新!版本 {{oldVersion}} → {{newVersion}}"
|
||||
},
|
||||
"❌ Update error, click here to try again?": {
|
||||
"ja": "❌ 更新エラー。ここをクリックして再試行しますか?",
|
||||
"zh": "❌ 更新错误,点击此处再试一次?",
|
||||
"zhcn": "❌ 更新错误,点击此处再试一次?",
|
||||
"zhhk": "❌ 更新錯誤,點擊此處再試一次?",
|
||||
"zhtw": "❌ 更新錯誤,點擊此處再試一次?"
|
||||
},
|
||||
"👆 Click for detail": {
|
||||
"ja": "詳細はこちら",
|
||||
"zh": "👆 详细信息",
|
||||
"zhcn": "👆 详细信息",
|
||||
"zhhk": "👆 查看詳細",
|
||||
"zhtw": "👆 查看詳細"
|
||||
},
|
||||
"👆 Click to fetch": {
|
||||
"ja": "👆 クリックしてフェッチ",
|
||||
"zh": "👆 点击获取",
|
||||
"zhcn": "👆 点击获取",
|
||||
"zhhk": "👆 點擊獲取",
|
||||
"zhtw": "👆 點擊獲取"
|
||||
},
|
||||
"👆 Click to test": {
|
||||
"ja": "👆 クリックしてテスト",
|
||||
"zh": "👆 点击跑分",
|
||||
"zhcn": "👆 点击跑分",
|
||||
"zhhk": "👆 點擊跑分",
|
||||
"zhtw": "👆 點擊跑分"
|
||||
},
|
||||
"👆 Start ping": {
|
||||
"ja": "👆 Pingを開始",
|
||||
"zh": "👆 开始 Ping",
|
||||
"zhcn": "👆 开始 Ping",
|
||||
"zhhk": "👆 開始 Ping",
|
||||
"zhtw": "👆 開始 Ping"
|
||||
},
|
||||
"Becnhmark": {
|
||||
"ja": "基準",
|
||||
"zh": "跑分",
|
||||
@@ -110,19 +13,19 @@
|
||||
"zhhk": "跑分",
|
||||
"zhtw": "跑分"
|
||||
},
|
||||
"Buffers are in-memory block I/O buffers. They are relatively short-lived. Prior to Linux kernel version 2.4, Linux had separate page and buffer caches. Since 2.4, the page and buffer cache are unified and Buffers is raw disk blocks not represented in the page cache—i.e., not file data.": {
|
||||
"ja": "",
|
||||
"zh": "内存缓冲是指内存块的输入输出缓冲。它们是相对短暂存储的。 在 Linux 内核版本 2.4 之前,Linux 具有单独的页面和缓冲区高速缓存。 从 2.4 开始,页面和缓冲区高速缓存是统一的,而缓冲区是原始磁盘块,并不代表存在于页面缓存,即不是文件数据。",
|
||||
"zhcn": "内存缓冲是指内存块的输入输出缓冲。它们是相对短暂存储的。 在 Linux 内核版本 2.4 之前,Linux 具有单独的页面和缓冲区高速缓存。 从 2.4 开始,页面和缓冲区高速缓存是统一的,而缓冲区是原始磁盘块,并不代表存在于页面缓存,即不是文件数据。",
|
||||
"zhhk": "",
|
||||
"zhtw": ""
|
||||
"CPU model": {
|
||||
"ja": "CPUモデル",
|
||||
"zh": "CPU 型号",
|
||||
"zhcn": "CPU 型号",
|
||||
"zhhk": "CPU 型號",
|
||||
"zhtw": "CPU 型號"
|
||||
},
|
||||
"Cached memory is memory that Linux uses for disk caching. However, this doesn\\'t count as \"used\" memory, since it will be freed when applications require it. Hence you don\\'t have to worry if a large amount is being used.": {
|
||||
"ja": "",
|
||||
"zh": "内存缓存指 Linux 使用的磁盘缓存。不管怎样,这些都不算作“已用”内存,如果程序有需要的话,它们就会被释放并为其所用。所以您不需要担心缓存过大会造成什么问题。",
|
||||
"zhcn": "内存缓存指 Linux 使用的磁盘缓存。不管怎样,这些都不算作“已用”内存,如果程序有需要的话,它们就会被释放并为其所用。所以您不需要担心缓存过大会造成什么问题。",
|
||||
"zhhk": "",
|
||||
"zhtw": ""
|
||||
"CPU usage": {
|
||||
"ja": "CPU 使用率",
|
||||
"zh": "CPU 占用",
|
||||
"zhcn": "CPU 占用",
|
||||
"zhhk": "CPU 使用率",
|
||||
"zhtw": "CPU 使用率"
|
||||
},
|
||||
"Can not fetch IP": {
|
||||
"ja": "IPを取得できません",
|
||||
@@ -173,19 +76,12 @@
|
||||
"zhhk": "拷貝分數",
|
||||
"zhtw": "拷貝分數"
|
||||
},
|
||||
"CPU model": {
|
||||
"ja": "CPUモデル",
|
||||
"zh": "CPU 型号",
|
||||
"zhcn": "CPU 型号",
|
||||
"zhhk": "CPU 型號",
|
||||
"zhtw": "CPU 型號"
|
||||
},
|
||||
"CPU usage": {
|
||||
"ja": "CPU 使用率",
|
||||
"zh": "CPU 占用",
|
||||
"zhcn": "CPU 占用",
|
||||
"zhhk": "CPU 使用率",
|
||||
"zhtw": "CPU 使用率"
|
||||
"DB": {
|
||||
"ja": "DB",
|
||||
"zh": "数据库",
|
||||
"zhcn": "数据库",
|
||||
"zhhk": "資料庫",
|
||||
"zhtw": "資料庫"
|
||||
},
|
||||
"Dark": {
|
||||
"ja": "闇",
|
||||
@@ -201,13 +97,6 @@
|
||||
"zhhk": "資料庫",
|
||||
"zhtw": "資料庫"
|
||||
},
|
||||
"DB": {
|
||||
"ja": "DB",
|
||||
"zh": "数据库",
|
||||
"zhcn": "数据库",
|
||||
"zhhk": "資料庫",
|
||||
"zhtw": "資料庫"
|
||||
},
|
||||
"Default": {
|
||||
"ja": "デフォルト",
|
||||
"zh": "默认",
|
||||
@@ -257,13 +146,6 @@
|
||||
"zhhk": "錯誤報告",
|
||||
"zhtw": "錯誤報告"
|
||||
},
|
||||
"Error: can not fetch remote config data, update checker is disabled.": {
|
||||
"ja": "エラー:リモート設定データを取得できません。更新チェッカーが無効になっています。",
|
||||
"zh": "错误:无法获取远程配置数据,更新检测已禁用。",
|
||||
"zhcn": "错误:无法获取远程配置数据,更新检测已禁用。",
|
||||
"zhhk": "錯誤:無法獲取配置數據,更新檢測已禁用。",
|
||||
"zhtw": "錯誤:無法獲取配備資料,更新檢測已禁用。"
|
||||
},
|
||||
"Ext": {
|
||||
"ja": "拡張",
|
||||
"zh": "扩展",
|
||||
@@ -278,13 +160,6 @@
|
||||
"zhhk": "獲取錯誤,請刷新頁面。",
|
||||
"zhtw": "獲取錯誤,請重新整理頁面。"
|
||||
},
|
||||
"Fetch failed. Detail in Console.": {
|
||||
"ja": "フェッチに失敗しました。 コンソールの詳細。",
|
||||
"zh": "获取失败。详情请看控制台。",
|
||||
"zhcn": "获取失败。详情请看控制台。",
|
||||
"zhhk": "獲取失敗。詳情在控制檯",
|
||||
"zhtw": "獲取失敗。詳情在控制檯"
|
||||
},
|
||||
"Fetch failed. Node returns {{code}}.": {
|
||||
"ja": "フェッチに失敗しました。 ノードは {{code}} を返します。",
|
||||
"zh": "获取失败。节点返回了 {{code}} 错误码。",
|
||||
@@ -299,27 +174,6 @@
|
||||
"zhhk": "獲取中……",
|
||||
"zhtw": "獲取中……"
|
||||
},
|
||||
"Generator {{appName}} / Author {{authorName}} / {{memUsage}} / {{time}}ms": {
|
||||
"ja": "このページは {{appName}} によって生成されます / 著者は {{authorName}} / {{memUsage}} / {{time}} ミリ秒",
|
||||
"zh": "该页面由 {{appName}} 生成 / 作者为 {{authorName}} / {{memUsage}} / {{time}} 毫秒",
|
||||
"zhcn": "该页面由 {{appName}} 生成 / 作者为 {{authorName}} / {{memUsage}} / {{time}} 毫秒",
|
||||
"zhhk": "該頁面由 {{appName}} 生成 / 作者爲 {{authorName}} / {{memUsage}} / {{time}} 毫秒",
|
||||
"zhtw": "該頁面由 {{appName}} 生成 / 作者為 {{authorName}} / {{memUsage}} / {{time}} 毫秒"
|
||||
},
|
||||
"idle: {{idle}} \\nnice: {{nice}} \\nsys: {{sys}} \\nuser: {{user}}": {
|
||||
"ja": "idle: {{idle}} \\nnice: {{nice}} \\nsys: {{sys}} \\nuser: {{user}}",
|
||||
"zh": "idle: {{idle}} \\nnice: {{nice}} \\nsys: {{sys}} \\nuser: {{user}}",
|
||||
"zhcn": "idle: {{idle}} \\nnice: {{nice}} \\nsys: {{sys}} \\nuser: {{user}}",
|
||||
"zhhk": "idle: {{idle}} \\nnice: {{nice}} \\nsys: {{sys}} \\nuser: {{user}}",
|
||||
"zhtw": "idle: {{idle}} \\nnice: {{nice}} \\nsys: {{sys}} \\nuser: {{user}}"
|
||||
},
|
||||
"In development": {
|
||||
"ja": "開発中",
|
||||
"zh": "开发中",
|
||||
"zhcn": "开发中",
|
||||
"zhhk": "開發中",
|
||||
"zhtw": "開發中"
|
||||
},
|
||||
"Info": {
|
||||
"ja": "情報",
|
||||
"zh": "信息",
|
||||
@@ -327,13 +181,6 @@
|
||||
"zhhk": "訊息",
|
||||
"zhtw": "訊息"
|
||||
},
|
||||
"Linux comes with many commands to check memory usage. The \"free\" command usually displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The \"top\" command provides a dynamic real-time view of a running system.": {
|
||||
"ja": "",
|
||||
"zh": "Linux 有许多命令来查看内存使用量。命令“free”通常用于显示系统可用的物理内存和交换分区内存,以及内核所占用的缓存。“top”命令提供系统正在运行的实时视图。",
|
||||
"zhcn": "Linux 有许多命令来查看内存使用量。命令“free”通常用于显示系统可用的物理内存和交换分区内存,以及内核所占用的缓存。“top”命令提供系统正在运行的实时视图。",
|
||||
"zhhk": "",
|
||||
"zhtw": ""
|
||||
},
|
||||
"Loaded extensions": {
|
||||
"ja": "ロードエクステンション",
|
||||
"zh": "已加载的扩展",
|
||||
@@ -348,6 +195,13 @@
|
||||
"zhhk": "載入中……",
|
||||
"zhtw": "載入中……"
|
||||
},
|
||||
"Max POST size": {
|
||||
"ja": "最大 POST サイズ",
|
||||
"zh": "POST 提交限制",
|
||||
"zhcn": "POST 提交限制",
|
||||
"zhhk": "POST 提交限制",
|
||||
"zhtw": "POST 提交限制"
|
||||
},
|
||||
"Max execution time": {
|
||||
"ja": "最大実行時間",
|
||||
"zh": "运行超时秒数",
|
||||
@@ -369,13 +223,6 @@
|
||||
"zhhk": "執行記憶體限制",
|
||||
"zhtw": "執行記憶體限制"
|
||||
},
|
||||
"Max POST size": {
|
||||
"ja": "最大 POST サイズ",
|
||||
"zh": "POST 提交限制",
|
||||
"zhcn": "POST 提交限制",
|
||||
"zhhk": "POST 提交限制",
|
||||
"zhtw": "POST 提交限制"
|
||||
},
|
||||
"Max upload size": {
|
||||
"ja": "最大アップロードサイズ",
|
||||
"zh": "上传文件限制",
|
||||
@@ -439,34 +286,6 @@
|
||||
"zhhk": "上移",
|
||||
"zhtw": "上移"
|
||||
},
|
||||
"My browser languages (via JS)": {
|
||||
"ja": "私のブラウザの言語(JS)",
|
||||
"zh": "我的浏览器语言(JS)",
|
||||
"zhcn": "我的浏览器语言(JS)",
|
||||
"zhhk": "我的瀏覽器語言(JS)",
|
||||
"zhtw": "我的瀏覽器語言(JS)"
|
||||
},
|
||||
"My browser languages (via PHP)": {
|
||||
"ja": "私のブラウザの言語(PHP)",
|
||||
"zh": "我的浏览器语言(PHP)",
|
||||
"zhcn": "我的浏览器语言(PHP)",
|
||||
"zhhk": "我的瀏覽器語言(PHP)",
|
||||
"zhtw": "我的瀏覽器語言(PHP)"
|
||||
},
|
||||
"My browser UA": {
|
||||
"ja": "私のブラウザ UA",
|
||||
"zh": "我的浏览器 UA",
|
||||
"zhcn": "我的浏览器 UA",
|
||||
"zhhk": "我的瀏覽器",
|
||||
"zhtw": "我的瀏覽器"
|
||||
},
|
||||
"My Information": {
|
||||
"ja": "私の情報",
|
||||
"zh": "我的信息",
|
||||
"zhcn": "我的信息",
|
||||
"zhhk": "我的訊息",
|
||||
"zhtw": "我的訊息"
|
||||
},
|
||||
"My IPv4": {
|
||||
"ja": "私のIPv4",
|
||||
"zh": "我的 IPv4",
|
||||
@@ -481,6 +300,34 @@
|
||||
"zhhk": "我的 IPv6",
|
||||
"zhtw": "我的 IPv6"
|
||||
},
|
||||
"My Information": {
|
||||
"ja": "私の情報",
|
||||
"zh": "我的信息",
|
||||
"zhcn": "我的信息",
|
||||
"zhhk": "我的訊息",
|
||||
"zhtw": "我的訊息"
|
||||
},
|
||||
"My browser UA": {
|
||||
"ja": "私のブラウザ UA",
|
||||
"zh": "我的浏览器 UA",
|
||||
"zhcn": "我的浏览器 UA",
|
||||
"zhhk": "我的瀏覽器",
|
||||
"zhtw": "我的瀏覽器"
|
||||
},
|
||||
"My browser languages (via JS)": {
|
||||
"ja": "私のブラウザの言語(JS)",
|
||||
"zh": "我的浏览器语言(JS)",
|
||||
"zhcn": "我的浏览器语言(JS)",
|
||||
"zhhk": "我的瀏覽器語言(JS)",
|
||||
"zhtw": "我的瀏覽器語言(JS)"
|
||||
},
|
||||
"My browser languages (via PHP)": {
|
||||
"ja": "私のブラウザの言語(PHP)",
|
||||
"zh": "我的浏览器语言(PHP)",
|
||||
"zhcn": "我的浏览器语言(PHP)",
|
||||
"zhhk": "我的瀏覽器語言(PHP)",
|
||||
"zhtw": "我的瀏覽器語言(PHP)"
|
||||
},
|
||||
"My location (IPv4)": {
|
||||
"ja": "私の場所 (IPv4)",
|
||||
"zh": "我的位置(IPv4)",
|
||||
@@ -502,13 +349,6 @@
|
||||
"zhhk": "流量",
|
||||
"zhtw": "流量"
|
||||
},
|
||||
"Network error, please try again later.": {
|
||||
"ja": "ネットワークエラーです。しばらくしてからもう一度お試しください。",
|
||||
"zh": "网络错误,请稍候重试。",
|
||||
"zhcn": "网络错误,请稍候重试。",
|
||||
"zhhk": "網路錯誤,請稍後重試。",
|
||||
"zhtw": "網路錯誤,請稍後重試。"
|
||||
},
|
||||
"Network Ping": {
|
||||
"ja": "ネットワークPing",
|
||||
"zh": "网络 Ping",
|
||||
@@ -523,16 +363,12 @@
|
||||
"zhhk": "流量統計",
|
||||
"zhtw": "流量統計"
|
||||
},
|
||||
"No sensor data.": {
|
||||
"zh": "无传感器",
|
||||
"zhcn": "无传感器"
|
||||
},
|
||||
"Node [${nodeId}] fetch failed.": {
|
||||
"ja": "ノード [${nodeId}] のフェッチに失敗しました。",
|
||||
"zh": "获取节点 [${nodeId}] 失败。",
|
||||
"zhcn": "获取节点 [${nodeId}] 失败。",
|
||||
"zhhk": "獲取節點 [${nodeId}] 失敗。",
|
||||
"zhtw": "獲取節點 [${nodeId}] 失敗。"
|
||||
"Network error, please try again later.": {
|
||||
"ja": "ネットワークエラーです。しばらくしてからもう一度お試しください。",
|
||||
"zh": "网络错误,请稍候重试。",
|
||||
"zhcn": "网络错误,请稍候重试。",
|
||||
"zhhk": "網路錯誤,請稍後重試。",
|
||||
"zhtw": "網路錯誤,請稍後重試。"
|
||||
},
|
||||
"Nodes": {
|
||||
"ja": "ノード",
|
||||
@@ -548,13 +384,6 @@
|
||||
"zhhk": "不支援",
|
||||
"zhtw": "不支援"
|
||||
},
|
||||
"Opcache enabled": {
|
||||
"ja": "Opcache 有効",
|
||||
"zh": "OPcache 已启用",
|
||||
"zhcn": "OPcache 已启用",
|
||||
"zhhk": "OPcache 已啓用",
|
||||
"zhtw": "OPcache 已啟用"
|
||||
},
|
||||
"Opcache JIT enabled": {
|
||||
"ja": "Opcache JIT 有効",
|
||||
"zh": "OPcache JIT 已启用",
|
||||
@@ -562,6 +391,13 @@
|
||||
"zhhk": "OPcache JIT 已啓用",
|
||||
"zhtw": "OPcache JIT 已啟用"
|
||||
},
|
||||
"Opcache enabled": {
|
||||
"ja": "Opcache 有効",
|
||||
"zh": "OPcache 已启用",
|
||||
"zhcn": "OPcache 已启用",
|
||||
"zhhk": "OPcache 已啓用",
|
||||
"zhtw": "OPcache 已啟用"
|
||||
},
|
||||
"PHP": {
|
||||
"ja": "PHP",
|
||||
"zh": "PHP",
|
||||
@@ -583,13 +419,6 @@
|
||||
"zhhk": "PHP 資訊",
|
||||
"zhtw": "PHP 資訊"
|
||||
},
|
||||
"PHP version": {
|
||||
"ja": "PHP バージョン",
|
||||
"zh": "PHP 版本",
|
||||
"zhcn": "PHP 版本",
|
||||
"zhhk": "PHP 版本",
|
||||
"zhtw": "PHP 版本"
|
||||
},
|
||||
"Ping": {
|
||||
"ja": "Ping",
|
||||
"zh": "Ping",
|
||||
@@ -597,12 +426,6 @@
|
||||
"zhhk": "Ping",
|
||||
"zhtw": "Ping"
|
||||
},
|
||||
"Read": {
|
||||
"zh": "读",
|
||||
"zhcn": "读",
|
||||
"zhhk": "讀",
|
||||
"zhtw": "讀"
|
||||
},
|
||||
"SAPI interface": {
|
||||
"ja": "SAPI インタフェース",
|
||||
"zh": "SAPI 接口",
|
||||
@@ -610,6 +433,20 @@
|
||||
"zhhk": "SAPI 介面",
|
||||
"zhtw": "SAPI 介面"
|
||||
},
|
||||
"SMTP support": {
|
||||
"ja": "SMTP サポート",
|
||||
"zh": "SMTP 支持",
|
||||
"zhcn": "SMTP 支持",
|
||||
"zhhk": "SMTP 支援",
|
||||
"zhtw": "SMTP 支援"
|
||||
},
|
||||
"STAR 🌟 ME": {
|
||||
"ja": "星🌟印",
|
||||
"zh": "星 🌟 标",
|
||||
"zhcn": "星 🌟 标",
|
||||
"zhhk": "星🌟標",
|
||||
"zhtw": "星🌟標"
|
||||
},
|
||||
"Script path": {
|
||||
"ja": "スクリプトパス",
|
||||
"zh": "脚本路径",
|
||||
@@ -624,13 +461,6 @@
|
||||
"zhhk": "伺服器性能跑分",
|
||||
"zhtw": "伺服器性能跑分"
|
||||
},
|
||||
"Server Information": {
|
||||
"ja": "サーバー情報",
|
||||
"zh": "服务器信息",
|
||||
"zhcn": "服务器信息",
|
||||
"zhhk": "伺服器訊息",
|
||||
"zhtw": "伺服器訊息"
|
||||
},
|
||||
"Server IPv4": {
|
||||
"ja": "サーバー IPv4",
|
||||
"zh": "服务器 IPv4",
|
||||
@@ -645,6 +475,27 @@
|
||||
"zhhk": "伺服器 IPv6",
|
||||
"zhtw": "伺服器 IPv6"
|
||||
},
|
||||
"Server Information": {
|
||||
"ja": "サーバー情報",
|
||||
"zh": "服务器信息",
|
||||
"zhcn": "服务器信息",
|
||||
"zhhk": "伺服器訊息",
|
||||
"zhtw": "伺服器訊息"
|
||||
},
|
||||
"Server OS": {
|
||||
"ja": "サーバー OS",
|
||||
"zh": "服务器系统",
|
||||
"zhcn": "服务器系统",
|
||||
"zhhk": "伺服器系統",
|
||||
"zhtw": "伺服器系統"
|
||||
},
|
||||
"Server Status": {
|
||||
"ja": "サーバーの状態",
|
||||
"zh": "服务器状态",
|
||||
"zhcn": "服务器状态",
|
||||
"zhhk": "伺服器狀態",
|
||||
"zhtw": "伺服器狀態"
|
||||
},
|
||||
"Server location (IPv4)": {
|
||||
"ja": "サーバーの場所 (IPv4)",
|
||||
"zh": "服务器地理位置(IPv4)",
|
||||
@@ -659,13 +510,6 @@
|
||||
"zhhk": "伺服器名",
|
||||
"zhtw": "伺服器名"
|
||||
},
|
||||
"Server OS": {
|
||||
"ja": "サーバー OS",
|
||||
"zh": "服务器系统",
|
||||
"zhcn": "服务器系统",
|
||||
"zhhk": "伺服器系統",
|
||||
"zhtw": "伺服器系統"
|
||||
},
|
||||
"Server software": {
|
||||
"ja": "サーバーソフトウェア",
|
||||
"zh": "服务器软件",
|
||||
@@ -673,13 +517,6 @@
|
||||
"zhhk": "伺服器軟體",
|
||||
"zhtw": "伺服器軟體"
|
||||
},
|
||||
"Server Status": {
|
||||
"ja": "サーバーの状態",
|
||||
"zh": "服务器状态",
|
||||
"zhcn": "服务器状态",
|
||||
"zhhk": "伺服器狀態",
|
||||
"zhtw": "伺服器狀態"
|
||||
},
|
||||
"Server time": {
|
||||
"ja": "サーバー時間",
|
||||
"zh": "服务器时间",
|
||||
@@ -694,20 +531,6 @@
|
||||
"zhhk": "持續上線時間",
|
||||
"zhtw": "持續上線時間"
|
||||
},
|
||||
"SMTP support": {
|
||||
"ja": "SMTP サポート",
|
||||
"zh": "SMTP 支持",
|
||||
"zhcn": "SMTP 支持",
|
||||
"zhhk": "SMTP 支援",
|
||||
"zhtw": "SMTP 支援"
|
||||
},
|
||||
"STAR 🌟 ME": {
|
||||
"ja": "星🌟印",
|
||||
"zh": "星 🌟 标",
|
||||
"zhcn": "星 🌟 标",
|
||||
"zhhk": "星🌟標",
|
||||
"zhtw": "星🌟標"
|
||||
},
|
||||
"Status": {
|
||||
"ja": "状態",
|
||||
"zh": "状态",
|
||||
@@ -757,13 +580,6 @@
|
||||
"zhhk": "溫度傳感器",
|
||||
"zhtw": "溫度傳感器"
|
||||
},
|
||||
"The author only has 10,000 API requests per month, please do not abuse it.": {
|
||||
"ja": "作成者は月に10,000のAPIリクエストしか持っていません。乱用しないでください。",
|
||||
"zh": "作者只有每月 10,000 次 API 请求,且用且珍惜。",
|
||||
"zhcn": "作者只有每月 10,000 次 API 请求,且用且珍惜。",
|
||||
"zhhk": "作者每月只有 10,000 次 API 請求,且用且珍惜。",
|
||||
"zhtw": "作者每月只有10,000 次 API 請求,且用且珍惜"
|
||||
},
|
||||
"Timeout for socket": {
|
||||
"ja": "ソケットのタイムアウト",
|
||||
"zh": "Socket 超时秒数",
|
||||
@@ -827,16 +643,120 @@
|
||||
"zhhk": "訪問官網",
|
||||
"zhtw": "瀏覽官網"
|
||||
},
|
||||
"idle: {{idle}} \\\\nnice: {{nice}} \\\\nsys: {{sys}} \\\\nuser: {{user}}": {
|
||||
"ja": "idle: {{idle}} \\\\nnice: {{nice}} \\\\nsys: {{sys}} \\\\nuser: {{user}}",
|
||||
"zh": "idle: {{idle}} \\\\nnice: {{nice}} \\\\nsys: {{sys}} \\\\nuser: {{user}}",
|
||||
"zhcn": "idle: {{idle}} \\\\nnice: {{nice}} \\\\nsys: {{sys}} \\\\nuser: {{user}}",
|
||||
"zhhk": "idle: {{idle}} \\\\nnice: {{nice}} \\\\nsys: {{sys}} \\\\nuser: {{user}}",
|
||||
"zhtw": "idle: {{idle}} \\\\nnice: {{nice}} \\\\nsys: {{sys}} \\\\nuser: {{user}}"
|
||||
},
|
||||
"{{days}} days {{hours}} hours {{mins}} mins {{secs}} secs": {
|
||||
"ja": "{{days}} 日 {{hours}} 時 {{mins}} 分 {{secs}} 秒",
|
||||
"zh": "{{days}} 天 {{hours}} 小时 {{mins}} 分 {{secs}} 秒",
|
||||
"zhcn": "{{days}} 天 {{hours}} 小时 {{mins}} 分 {{secs}} 秒",
|
||||
"zhhk": "{{days}} 天 {{hours}} 時 {{mins}} 分 {{secs}} 秒",
|
||||
"zhtw": "{{days}} 天 {{hours}} 時 {{mins}} 分 {{secs}} 秒"
|
||||
},
|
||||
"{{minute}} minute average": {
|
||||
"ja": "{{minute}} 分ごとの平均負荷",
|
||||
"zh": "{{minute}} 分钟平均负载",
|
||||
"zhcn": "{{minute}} 分钟平均负载",
|
||||
"zhhk": "{{minute}} 分鐘平均負載",
|
||||
"zhtw": "{{minute}} 分鐘平均負載"
|
||||
},
|
||||
"{{sensor}} temperature": {
|
||||
"ja": "{{sensor}} 温度",
|
||||
"zh": "{{sensor}} 温度",
|
||||
"zhcn": "{{sensor}} 温度",
|
||||
"zhhk": "{{sensor}} 溫度",
|
||||
"zhtw": "{{sensor}} 溫度"
|
||||
},
|
||||
"⏳ Please wait {{seconds}}s": {
|
||||
"ja": "⏳ {{seconds}} 秒お待ちください",
|
||||
"zh": "⏳ 请等待 {{seconds}}秒",
|
||||
"zhcn": "⏳ 请等待 {{seconds}}秒",
|
||||
"zhhk": "⏳ 請等待 {{seconds}} 秒",
|
||||
"zhtw": "⏳ 請等待 {{seconds}} 秒"
|
||||
},
|
||||
"⏳ Testing, please wait...": {
|
||||
"ja": "⏳ テストしています。お待ちください...",
|
||||
"zh": "⏳ 跑分中,请稍等……",
|
||||
"zhcn": "⏳ 跑分中,请稍等……",
|
||||
"zhhk": "⏳ 跑分中,請稍等……",
|
||||
"zhtw": "⏳ 跑分中,請稍等……"
|
||||
},
|
||||
"⏳ Updating, please wait a second...": {
|
||||
"ja": "⏳ 更新しています。しばらくお待ちください...",
|
||||
"zh": "⏳ 更新中,请稍等一会……",
|
||||
"zhcn": "⏳ 更新中,请稍等一会……",
|
||||
"zhhk": "⏳ 更新中,請稍等……",
|
||||
"zhtw": "⏳ 更新中,請稍等……"
|
||||
},
|
||||
"⏸️ Stop ping": {
|
||||
"ja": "⏸️ Pingを停止",
|
||||
"zh": "⏸️ 停止 Ping",
|
||||
"zhcn": "⏸️ 停止 Ping",
|
||||
"zhhk": "⏸️ 停止 Ping",
|
||||
"zhtw": "⏸️ 停止 Ping"
|
||||
},
|
||||
"✨ Found update! Version {{oldVersion}} → {{newVersion}}": {
|
||||
"ja": "✨ アップデートが見た!バージョン {{oldVersion}} → {{newVersion}}",
|
||||
"zh": "✨ 发现更新!版本 {{oldVersion}} → {{newVersion}}",
|
||||
"zhcn": "✨ 发现更新!版本 {{oldVersion}} → {{newVersion}}",
|
||||
"zhhk": "✨ 發現更新!版本 {{oldVersion}} → {{newVersion}}",
|
||||
"zhtw": "✨ 發現更新!版本 {{oldVersion}} → {{newVersion}}"
|
||||
},
|
||||
"❌ Update error, click here to try again?": {
|
||||
"ja": "❌ 更新エラー。ここをクリックして再試行しますか?",
|
||||
"zh": "❌ 更新错误,点击此处再试一次?",
|
||||
"zhcn": "❌ 更新错误,点击此处再试一次?",
|
||||
"zhhk": "❌ 更新錯誤,點擊此處再試一次?",
|
||||
"zhtw": "❌ 更新錯誤,點擊此處再試一次?"
|
||||
},
|
||||
"👆 Click for detail": {
|
||||
"ja": "詳細はこちら",
|
||||
"zh": "👆 详细信息",
|
||||
"zhcn": "👆 详细信息",
|
||||
"zhhk": "👆 查看詳細",
|
||||
"zhtw": "👆 查看詳細"
|
||||
},
|
||||
"👆 Click to fetch": {
|
||||
"ja": "👆 クリックしてフェッチ",
|
||||
"zh": "👆 点击获取",
|
||||
"zhcn": "👆 点击获取",
|
||||
"zhhk": "👆 點擊獲取",
|
||||
"zhtw": "👆 點擊獲取"
|
||||
},
|
||||
"👆 Click to test": {
|
||||
"ja": "👆 クリックしてテスト",
|
||||
"zh": "👆 点击跑分",
|
||||
"zhcn": "👆 点击跑分",
|
||||
"zhhk": "👆 點擊跑分",
|
||||
"zhtw": "👆 點擊跑分"
|
||||
},
|
||||
"👆 Start ping": {
|
||||
"ja": "👆 Pingを開始",
|
||||
"zh": "👆 开始 Ping",
|
||||
"zhcn": "👆 开始 Ping",
|
||||
"zhhk": "👆 開始 Ping",
|
||||
"zhtw": "👆 開始 Ping"
|
||||
},
|
||||
"Error: can not fetch remote config data, update checker is disabled.": {
|
||||
"zh": "错误:无法获取远程配置数据,更新检测已禁用。",
|
||||
"zhcn": "错误:无法获取远程配置数据,更新检测已禁用。",
|
||||
"zhhk": "錯誤:無法獲取配置數據,更新檢測已禁用。",
|
||||
"zhtw": "錯誤:無法獲取配備資料,更新檢測已禁用。"
|
||||
},
|
||||
"Read": {
|
||||
"zh": "读",
|
||||
"zhcn": "读",
|
||||
"zhhk": "讀",
|
||||
"zhtw": "讀"
|
||||
},
|
||||
"Write": {
|
||||
"zh": "写",
|
||||
"zhcn": "写",
|
||||
"zhhk": "寫",
|
||||
"zhtw": "寫"
|
||||
},
|
||||
"X Prober": {
|
||||
"zh": "X 探针",
|
||||
"zhcn": "X 探针",
|
||||
"zhhk": "X 探針",
|
||||
"zhtw": "X 探針"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @version 1.0.0
|
||||
*/
|
||||
import DeepSort from 'deep-sort-object'
|
||||
import FastGlob from 'fast-glob'
|
||||
import { writeFileSync } from 'fs'
|
||||
import path, { basename, dirname } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { PoParser } from './po-parser.mjs'
|
||||
import { PotBuilder } from './pot-builder.mjs'
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
class LangBuilder {
|
||||
data = {}
|
||||
constructor() {
|
||||
this.build()
|
||||
}
|
||||
setData = async () => {
|
||||
new PotBuilder({
|
||||
potPath: path.resolve(__dirname, '../locales/lang.pot'),
|
||||
sourceDir: path.resolve(__dirname, '../src'),
|
||||
})
|
||||
const files = await FastGlob(path.resolve(__dirname, '../locales/*.po'))
|
||||
files.map((file) => {
|
||||
const lang = basename(file, '.po')
|
||||
const langId = lang.replace('_', '').toLowerCase()
|
||||
const parser = new PoParser({
|
||||
poPath: path.resolve(__dirname, `../locales/${lang}.po`),
|
||||
})
|
||||
const items = parser.parse()
|
||||
Object.keys(items).map((text) => {
|
||||
if (!this.data[text]) {
|
||||
this.data[text] = {}
|
||||
}
|
||||
if (!this.data[text][langId]) {
|
||||
this.data[text][langId] = items[text]
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
build = async () => {
|
||||
await this.setData()
|
||||
this.data = DeepSort(this.data)
|
||||
const jsonPath = path.resolve(
|
||||
__dirname,
|
||||
`../src/Components/Language/data.json`,
|
||||
)
|
||||
writeFileSync(jsonPath, JSON.stringify(this.data, null, 2))
|
||||
}
|
||||
}
|
||||
new LangBuilder()
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @version 1.0.0
|
||||
*/
|
||||
import { existsSync, readFileSync } from 'fs'
|
||||
export class PoParser {
|
||||
poPath = ''
|
||||
items = {}
|
||||
constructor({ poPath }) {
|
||||
this.poPath = poPath
|
||||
if (!existsSync(this.poPath)) {
|
||||
throw new Error(`${this.poPath} not exists`)
|
||||
}
|
||||
}
|
||||
parse = () => {
|
||||
const code = readFileSync(this.poPath).toString()
|
||||
const reg = new RegExp(
|
||||
`(msgctxt\\s+"(.+?)"\\s+)?msgid\\s+"(.+?)"\\s+msgstr\\s+"(.+?)"`,
|
||||
'gm',
|
||||
)
|
||||
;[...code.matchAll(reg)].map(([, , ctxt = '', id, str]) => {
|
||||
const key = ctxt !== '' ? `${ctxt}|${id}` : id
|
||||
this.items[key] = str
|
||||
})
|
||||
this.items = Object.keys(this.items)
|
||||
.sort()
|
||||
.reduce((r, k) => ((r[k] = this.items[k]), r), {})
|
||||
return this.items
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @version 1.0.0
|
||||
*/
|
||||
import { lstatSync, readdirSync, readFileSync, writeFileSync } from 'fs'
|
||||
import { extname } from 'path'
|
||||
export class PotBuilder {
|
||||
potPath = ''
|
||||
sourceDir = ''
|
||||
entries = {}
|
||||
/**
|
||||
* @type {string[]}
|
||||
*/
|
||||
filePaths = []
|
||||
constructor({ potPath, sourceDir }) {
|
||||
this.potPath = potPath
|
||||
this.sourceDir = sourceDir
|
||||
this.fetchDirOrFile(this.sourceDir)
|
||||
this.filePaths.map(this.buildEntries)
|
||||
this.buildPotFile()
|
||||
}
|
||||
buildEntries = (path) => {
|
||||
const code = readFileSync(path).toString()
|
||||
const reg = new RegExp(
|
||||
`gettext\\s*\\(\\s*('.+?')\\s*,*\\s*('.+?')*\\s*\\)`,
|
||||
'gm',
|
||||
)
|
||||
const matches = code.matchAll(reg)
|
||||
if (matches) {
|
||||
for (const match of matches) {
|
||||
const msgid = match[1].slice(1, -1)
|
||||
const msgctxt = (match[2] || '').slice(1, -1)
|
||||
if (this.entries[`${msgid}${msgctxt}`]) {
|
||||
continue
|
||||
}
|
||||
this.entries[`${msgid}${msgctxt}`] = `
|
||||
${msgctxt ? `msgctxt ${JSON.stringify(msgctxt)}` : ''}
|
||||
msgid ${JSON.stringify(msgid)}
|
||||
msgstr ""
|
||||
`.trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
buildPotFile = () => {
|
||||
const toWriteData = `
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \\n"
|
||||
"POT-Creation-Date: \\n"
|
||||
"PO-Revision-Date: \\n"
|
||||
"Last-Translator: Km.Van\\n"
|
||||
"Language-Team: INN STUDIO\\n"
|
||||
"MIME-Version: 1.0\\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\\n"
|
||||
"Content-Transfer-Encoding: 8bit\\n"
|
||||
"X-Generator: Poedit 3.0.1\\n"
|
||||
"X-Poedit-Basepath: ../src\\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\\n"
|
||||
"X-Poedit-KeywordsList: gettext\\n"
|
||||
|
||||
${Object.values(this.entries).join('\n\n')}
|
||||
`.trim()
|
||||
writeFileSync(this.potPath, toWriteData, 'utf8')
|
||||
}
|
||||
fetchDirOrFile = (filePathOrDir) => {
|
||||
if (lstatSync(filePathOrDir).isDirectory()) {
|
||||
readdirSync(filePathOrDir).map((p) =>
|
||||
this.fetchDirOrFile(`${filePathOrDir}/${p}`),
|
||||
)
|
||||
} else {
|
||||
if (['.ts', '.tsx'].includes(extname(filePathOrDir))) {
|
||||
this.filePaths.push(filePathOrDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { readdirSync, rmdirSync, statSync, unlinkSync } from 'fs'
|
||||
import path from 'path'
|
||||
/**
|
||||
* Remove files
|
||||
* @param {string} dir
|
||||
*/
|
||||
export const rmFiles = (dir) => {
|
||||
const files = readdirSync(dir)
|
||||
for (const file of files) {
|
||||
const filePath = path.join(dir, file)
|
||||
if (statSync(filePath).isDirectory()) {
|
||||
rmFiles(filePath)
|
||||
} else {
|
||||
unlinkSync(filePath)
|
||||
}
|
||||
}
|
||||
rmdirSync(dir)
|
||||
}
|
||||
+3
-11
@@ -10,7 +10,7 @@
|
||||
"jsx": "react-jsx",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"rootDir": "src",
|
||||
// "rootDir": "src",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": false,
|
||||
@@ -41,15 +41,7 @@
|
||||
"ssr": false
|
||||
}
|
||||
],
|
||||
"include": ["src"],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"build",
|
||||
"scripts",
|
||||
"acceptance-tests",
|
||||
"webpack",
|
||||
"jest",
|
||||
"src/setupTests.ts"
|
||||
],
|
||||
"include": ["src/**/*", "*.mjs", "./tools/**/*"],
|
||||
"exclude": ["node_modules", "build", "scripts", "webpack", "jest"],
|
||||
"includes": ["styled-components.d.ts"]
|
||||
}
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const webpack = require('webpack')
|
||||
const path = require('path')
|
||||
const createStyledComponentsTransformer =
|
||||
require('typescript-plugin-styled-components').default
|
||||
const styledComponentsTransformer = createStyledComponentsTransformer()
|
||||
const rimraf = require('rimraf')
|
||||
|
||||
rimraf('.tmp', {}, () => {})
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
entry: {
|
||||
app: './src/Components/Bootstrap/components/index.tsx',
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, '.tmp'),
|
||||
filename: '[name].js',
|
||||
publicPath: './.tmp',
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.tsx', '.js'],
|
||||
alias: {
|
||||
root: __dirname,
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
__DEV__: true,
|
||||
'process.env': {
|
||||
NODE_ENV: JSON.stringify('development'),
|
||||
WEBPACK_ENV: JSON.stringify('development'),
|
||||
},
|
||||
DEBUG: true,
|
||||
}),
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
// {
|
||||
// test: /\.m?js$/,
|
||||
// type: 'javascript/auto',
|
||||
// resolve: {
|
||||
// fullySpecified: false,
|
||||
// },
|
||||
// },
|
||||
{
|
||||
test: /\.(ts|tsx)$/,
|
||||
// type: 'javascript/auto',
|
||||
// resolve: {
|
||||
// fullySpecified: false,
|
||||
// },
|
||||
exclude: /node_modules/,
|
||||
include: path.resolve(__dirname, 'src'),
|
||||
use: [
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
transpileOnly: true,
|
||||
getCustomTransformers: () => ({
|
||||
before: [styledComponentsTransformer],
|
||||
}),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpg|gif)$/i,
|
||||
use: [
|
||||
{
|
||||
loader: 'url-loader',
|
||||
options: {
|
||||
// limit: 8192
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
// stats: {
|
||||
// modules: true,
|
||||
// reasons: true,
|
||||
// errorDetails: true,
|
||||
// timings: true,
|
||||
// },
|
||||
devtool: 'source-map',
|
||||
watch: true,
|
||||
// watchOptions: {
|
||||
// poll: 1000,
|
||||
// aggregateTimeout: 1000,
|
||||
// ignored: /node_modules/,
|
||||
// },
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import path, { dirname } from 'path'
|
||||
import { createTransformer } from 'typescript-plugin-styled-components'
|
||||
import { fileURLToPath } from 'url'
|
||||
import webpack from 'webpack'
|
||||
import { rmFiles } from './tools/rm-files.mjs'
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
rmFiles(path.resolve(__dirname, '.tmp'))
|
||||
export default {
|
||||
mode: 'development',
|
||||
entry: {
|
||||
app: path.resolve(
|
||||
__dirname,
|
||||
'src/Components/Bootstrap/components/index.tsx'
|
||||
),
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, '.tmp'),
|
||||
filename: '[name].js',
|
||||
publicPath: './.tmp',
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.tsx', '.js', '.mjs'],
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
__DEV__: true,
|
||||
'process.env': {
|
||||
NODE_ENV: JSON.stringify('development'),
|
||||
WEBPACK_ENV: JSON.stringify('development'),
|
||||
},
|
||||
DEBUG: true,
|
||||
}),
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(ts|tsx)$/,
|
||||
exclude: /node_modules/,
|
||||
include: path.resolve(__dirname, 'src'),
|
||||
use: [
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
transpileOnly: true,
|
||||
getCustomTransformers: () => ({
|
||||
before: [createTransformer()],
|
||||
}),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
devtool: 'source-map',
|
||||
watch: true,
|
||||
}
|
||||
@@ -1,21 +1,16 @@
|
||||
'use strict'
|
||||
|
||||
const webpack = require('webpack')
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
const path = require('path')
|
||||
const createStyledComponentsTransformer =
|
||||
require('typescript-plugin-styled-components').default
|
||||
const styledComponentsTransformer = createStyledComponentsTransformer({
|
||||
minify: true,
|
||||
})
|
||||
const rimraf = require('rimraf')
|
||||
|
||||
rimraf('.tmp', {}, () => {})
|
||||
|
||||
module.exports = {
|
||||
import path from 'path'
|
||||
import TerserPlugin from 'terser-webpack-plugin'
|
||||
import { createTransformer } from 'typescript-plugin-styled-components'
|
||||
import webpack from 'webpack'
|
||||
import { rmFiles } from './tools/rm-files.mjs'
|
||||
rmFiles(path.resolve(__dirname, '.tmp'))
|
||||
export default {
|
||||
mode: 'production',
|
||||
entry: {
|
||||
app: './src/Components/Bootstrap/components/index.tsx',
|
||||
app: path.resolve(
|
||||
__dirname,
|
||||
'src/Components/Bootstrap/components/index.tsx'
|
||||
),
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, '.tmp'),
|
||||
@@ -23,7 +18,7 @@ module.exports = {
|
||||
publicPath: './.tmp',
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.tsx', '.js'],
|
||||
extensions: ['.ts', '.tsx', '.js', '.mjs'],
|
||||
alias: {
|
||||
root: __dirname,
|
||||
},
|
||||
@@ -73,23 +68,16 @@ module.exports = {
|
||||
options: {
|
||||
transpileOnly: true,
|
||||
getCustomTransformers: () => ({
|
||||
before: [styledComponentsTransformer],
|
||||
before: [
|
||||
createTransformer({
|
||||
minify: true,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpg|gif)$/i,
|
||||
use: [
|
||||
{
|
||||
loader: 'url-loader',
|
||||
options: {
|
||||
// limit: 8192
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
devtool: 'hidden-source-map',
|
||||
Reference in New Issue
Block a user