diff --git a/AGENTS.md b/AGENTS.md index ed89819..947af8e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -48,6 +48,7 @@ Unless a user explicitly requests a refresh, each translatable value must be tra - Plugin slug and PHP prefix: `hyx-translator-for-baidu-translate` and `htbd_`/`HTBD_`. The custom translation table is `{$wpdb->prefix}hyx_bd_translations`. The current minimum supported PHP version is 8.1 and the current minimum WordPress version is 6.4. - The repository has no Composer-managed development dependencies or bundled automated test suite. Validate PHP syntax with `find . -path './.git' -prune -o -type f -name '*.php' -print0 | xargs -0 -n1 php -l`. Any future automated tests must mock WordPress API calls and must not require live credentials, external network access, or a WordPress database. - Document supported languages, routing modes, data retention, translation lifecycle, and known limitations in the README whenever the implementation changes. +- Whenever any README or readme file is updated, update the corresponding PO translation file under `languages/` in the same change so the translated documentation remains synchronized. ## Release Workflow diff --git a/build.sh b/build.sh index 77bdf2f..8d2fa19 100755 --- a/build.sh +++ b/build.sh @@ -30,7 +30,6 @@ build() { cp "${script_dir}/${plugin_file}" \ "${script_dir}/uninstall.php" \ "${script_dir}/readme.txt" \ - "${script_dir}/readme-zh_CN.txt" \ "${script_dir}/LICENSE" \ "${plugin_dir}/" cp -R "${script_dir}/includes" "${plugin_dir}/" @@ -49,7 +48,6 @@ build() { unzip -p "${archive_path}" "${plugin_slug}/${plugin_file}" | grep -q '^ \* Plugin Name: HTBD - hyx Translator powered by Baidu Translate$' unzip -p "${archive_path}" "${plugin_slug}/readme.txt" | grep -q "^Stable tag: ${version}$" - unzip -p "${archive_path}" "${plugin_slug}/readme-zh_CN.txt" | grep -q "^Stable tag: ${version}$" unzip -Z1 "${archive_path}" | grep -q "^${plugin_slug}/languages/${plugin_slug}-zh_CN.mo$" if unzip -Z1 "${archive_path}" | grep -q '/wp-plugins-.*\.po$'; then printf 'Unexpected GlotPress submission file found in archive.\n' >&2 diff --git a/readme-zh_CN.txt b/readme-zh_CN.txt deleted file mode 100644 index c737247..0000000 --- a/readme-zh_CN.txt +++ /dev/null @@ -1,89 +0,0 @@ -=== HTBD - hyx Translator powered by Baidu Translate === -Contributors: hanyixuanten -Homepage: https://www.vblg.top/index.php/archives/147 -Requires at least: 6.4 -Tested up to: 7.0 -Requires PHP: 8.1 -Stable tag: 0.3.0 -License: GPL-3.0-only -License URI: https://www.gnu.org/licenses/gpl-3.0.html - -使用百度翻译 API 生成并持久化保存 WordPress 多语言内容。 - -== Description == - -HTBD 使用百度翻译 API 翻译 WordPress 内容,并将每个翻译结果持久化保存以供重复使用。插件支持语言子目录 URL 和语言域名绑定。 - -WordPress 后台界面会跟随当前 WordPress 语言,默认显示英文。WordPress.org 已批准的官方语言包优先;WordPress 设为 `zh_CN` 且官方语言包不可用时,插件会回退使用内置的简体中文翻译。 - -支持的内容包括已发布文章和页面的标题、正文、摘要、图片替代文本、分类、标签及部分 SEO 字段。插件只为 `publish` 状态的文章和页面自动安排翻译。完成的翻译保存在 `{$wpdb->prefix}hyx_bd_translations` 自建数据表中;启用改名后的插件时,已有 `{$wpdb->prefix}btranslate_translations` 数据会自动迁移。前端渲染只读取已保存的翻译,不会动态请求翻译服务。 - -子目录路由支持 `/en/example-post/` 等路径。域名路由可将配置的主机名映射到目标语言。通过目标语言路由请求 `wp-login.php`、`wp-admin` 时,插件会重定向到源站对应地址并保留查询参数。翻译失败不会中断页面请求;没有有效译文时会回退显示源语言内容。 - -== Installation == - -1. 将 `hyx-translator-for-baidu-translate` 目录上传到 `/wp-content/plugins/`。 -2. 在 WordPress 的“插件”页面启用 HTBD。 -3. 打开“设置 > HTBD”,配置百度翻译凭据、源语言、目标语言和路由模式。勾选“自动识别源语言”可使用百度翻译的 `auto` 源语言模式。 -4. 第一次保存设置后,手动执行“重新翻译所有内容”,为已有内容安排翻译任务。 -5. 此后保存文章或页面时,插件会自动安排翻译任务。 - -自动识别状态使用独立选项保存。未勾选自动识别时主动将源语言填写为 `auto`,仍属于不同的配置状态。 - -== External Services == - -HTBD 连接由百度提供的百度翻译开放平台 API,以翻译 WordPress 内容。没有该外部服务,插件无法生成新的翻译。站点管理员需要百度翻译账户、应用 ID 和密钥;百度可能根据管理员选择的服务方案实施请求配额或收取使用费用。 - -已发布文章或页面保存后、支持的分类或标签创建或编辑后,或者管理员明确安排或刷新翻译时,计划任务会请求该 API。前端页面访问只读取已保存的翻译,不会请求百度。已有有效持久化翻译时也不会请求百度,除非管理员明确执行重新翻译。 - -每次翻译请求会发送待翻译文本、配置的源语言和目标语言代码、百度应用 ID、随机盐值和请求签名。根据待翻译内容,文本可能包含已发布文章或页面的标题、正文、摘要、指定 SEO 标题和描述、附件图片替代文本,以及分类或标签的名称和描述。作为 HTTPS 请求的一部分,百度也能看到来源服务器 IP 等标准网络信息。密钥只在本地用于生成签名,不会作为独立请求字段发送。 - -HTBD 将百度返回的译文保存在 WordPress 数据库中,但不保存完整百度响应。发送给百度的数据受百度自身条款和隐私规则约束: - -* 百度翻译 API 文档:https://fanyi-api.baidu.com/doc/23 -* 百度翻译开放平台服务协议:https://fanyi-api.baidu.com/doc/6 -* 百度隐私政策:https://privacy.baidu.com/policy - -== Frequently Asked Questions == - -= 插件会在每次页面请求时翻译内容吗? = - -不会。翻译由计划任务生成并持久化保存。前端请求只读取已保存的翻译结果。 - -= 插件会翻译文章或页面中的代码吗? = - -不会。HTML `
` 和 `` 元素内的内容会保留源语言,不会发送翻译请求。
-
-= 翻译失败后如何重试? =
-
-失败的文章、页面、分类或标签会显示在设置页进度条下方。点击对应的“重新翻译”按钮可逐项重试。
-
-= 支持哪些 URL 路由模式? =
-
-支持语言子目录、域名绑定,或同时启用这两种模式。域名和 DNS 必须预先指向同一个 WordPress 站点。
-
-= 卸载插件会删除哪些数据? =
-
-卸载会删除插件设置、计划任务和自建翻译表,包括所有已持久化的翻译。停用插件不会删除这些数据。
-
-== Changelog ==
-
-= 0.3.0 =
-
-* 新增使用百度翻译 `auto` 模式自动识别源语言的功能。
-* 将目标语言路由中的 `wp-admin` 和 `wp-login.php` 请求重定向到源站,并保留查询参数。
-* 新增 GitHub Release 自动打包及 WordPress.org SVN 自动部署工作流。
-
-= 0.2.4 =
-
-* 修复单篇内容页面未按当前文章上下文显示翻译标题的问题。
-* 保留 HTML `` 和 `` 元素内的内容,不再将其发送翻译。
-* 完善插件安全元数据和译者署名。
-* 更新插件主页 URL。
-
-= 0.2.3 =
-
-* 将插件及代码库重命名为 HTBD / hyx-translator-for-baidu-translate。
-* 自动迁移旧版自建数据表中的翻译数据。
-* 更新打包流程、本地化资源、文档和问题模板以适配新的插件标识。
-* 修复发布归档构建流程。
\ No newline at end of file