From 96f0c67bbc0a1bb0337bc574d6b54fa6b510f241 Mon Sep 17 00:00:00 2001 From: JGZYES Date: Fri, 4 Sep 2026 22:58:30 +0800 Subject: [PATCH] web: translate.php -> per-language cards (view/download/contribute) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each language pack is now a card in a grid with the locale name, key count, a [查看] toggle that shows the prettified .pjson, a [下载 .pjson] button and a [贡献修订] link. Contribution goes by email (luoriguodu@qq.com) or a GitHub Issue, with a step-by-step guide on adding a new language. No server writes / online editor (keeps it simple and safe). Verified by rendering via the PHP built-in server: 2 cards (zh-CN/en-US), 124 keys each, no PHP errors. --- web/translate.php | 79 +++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/web/translate.php b/web/translate.php index 17cab26..6450dd5 100644 --- a/web/translate.php +++ b/web/translate.php @@ -2,48 +2,73 @@ define('PMM_SITE', 1); require __DIR__ . '/_common.php'; -/* List available .pjson language packs under web/mirror/lang/. */ +/* Language packs under web/mirror/lang/. */ $langDir = __DIR__ . '/mirror/lang'; $packs = []; if (is_dir($langDir)) { foreach (glob($langDir . '/*.pjson') as $f) { $locale = basename($f, '.pjson'); - $keys = 0; + $keys = 0; $raw = ''; $data = json_decode((string)file_get_contents($f), true); - if (is_array($data)) $keys = count($data); - $packs[] = ['locale' => $locale, 'keys' => $keys, 'file' => 'mirror/lang/' . basename($f)]; + if (is_array($data)) { + $keys = count($data); + ksort($data); + $raw = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + } + $packs[] = [ + 'locale' => $locale, + 'keys' => $keys, + 'file' => 'mirror/lang/' . basename($f), + 'raw' => $raw, + ]; } } usort($packs, function ($a, $b) { return strcmp($a['locale'], $b['locale']); }); +$mail = 'luoriguodu@qq.com'; +$issues = 'https://github.com/JGZYES/ParlzPackageManger/issues/new'; + pmm_header('translate', '翻译 · Translate'); pmm_page_open('TRANSLATE', '翻译 / Language'); ?> -
-

PMM 的界面文案由 .pjson 语言包驱动。默认内置 zh-CNen-US,社区可以提交新的语言包或修正译文。

+
+
+

PMM 的界面文案由 .pjson 语言包驱动。每门语言一个包;想新增语言或修订译文,请 + 发邮件 + 或在 GitHub 提 Issue

- - - - - - - - - - - - - -
Locale键数下载
(暂无语言包)
下载 .pjson ↓
+
+ +
暂无语言包
+ +
+ + -

如何贡献翻译

-

复制 zh-CN.pjson 为你的语言(如 ja-JP.pjson),键名保持不变、只改值,然后提交到仓库的 - web/mirror/lang/ 目录,或在 GitHub 提交 Issue / PR。社区翻译会即时更新镜像,用户即可通过 - pmm setting lang <locale> 安装。

+
+ 查看 +
+
-

安装语言包:

-
pmm setting lang ja-JP
+          
+        
+ +
+ +

如何贡献一门语言

+
    +
  1. 打开任一语言(如 zh-CN)卡片 → 下载 .pjson
  2. +
  3. zh-CN 的键名保留、只改值,另存为你的语言,如 ja-JP.pjsonzh-TW.pjson
  4. +
  5. 将文件作为附件发到 ,或在 GitHub 提 Issue 粘贴内容。
  6. +
  7. 通过后即进入镜像 web/mirror/lang/,用户用 pmm setting lang <locale> 安装。
  8. +
+ +

安装语言包:

+
pmm setting lang ja-JP
 pmm setting lang -l
-
+
+