HTBD is a multilingual translation plugin for WordPress. It uses the Baidu Translate API to translate posts, pages, and other website content into different languages, with a dedicated URL for each translated version.
Translations are stored on the server in {$wpdb->prefix}hyx_bd_translations. Unless a user explicitly refreshes a translation, the same content is translated only once for each target language. Existing {$wpdb->prefix}btranslate_translations data is migrated when the renamed plugin is activated. This avoids calling the translation API on every page visit, reducing API usage and improving page load performance.
- Plugin homepage: https://www.vblg.top/index.php/archives/147
- GitHub repository: https://github.com/hanyixuanten/HTBD
- WordPress plugin page: https://wordpress.org/plugins/hyx-translator-for-baidu-translate/
Review status: HTBD has been approved for the WordPress.org Plugin Directory and is listed at wordpress.org/plugins/hyx-translator-for-baidu-translate. The recommended way to install it is directly from Plugins > Add New Plugin in WordPress Admin. GitHub releases remain available for manual installation and for older versions.
HTBD uses the translation API provided by the Baidu Translate Open Platform. Users can configure their own App ID and secret key in WordPress Admin, and the plugin handles request signing, API calls, and error handling.
The plugin supports translating the main content of any public post type and public taxonomy selected in the settings, including:
- Titles
- Body content
- Excerpts
- SEO fields
- Image alternative text
- Tags
- Categories and custom taxonomy terms
- Selected interface text
HTBD can generate dedicated URLs for different languages, with support for:
- Language subdirectories such as
/en/and/jp/ - A separate domain for each language
- Language-specific permalinks based on the configured routing mode
Visitors can move between languages without editing the URL:
- The
[htbd_language_switcher]shortcode, withformat="list"orformat="inline" - The HTBD language switcher block for block themes
- A classic widget for themes without block support
Each link points at the current page in the selected language, keeps the query string, and marks the active language with aria-current.
When the feature is enabled under Settings > HTBD, a visitor whose browser prefers another configured language sees a small dismissible notice offering that version of the current page:
- The suggestion is decided in the browser, so a cached page never carries a notice meant for a different visitor.
- Nothing is redirected automatically. The notice contains a real link to the same page in the suggested language, and every language keeps its own canonical URL.
- The choice is remembered in
localStorage, so a dismissed or accepted suggestion is not repeated for that language. - The notice is not rendered for feeds, embeds, previews, 404 responses, or a site with a single language, and it stays hidden when JavaScript is unavailable.
After a translation is generated, it is stored on the WordPress server. Future requests for the same translation use the stored result instead of calling the Baidu Translate API again.
When the source content changes, the corresponding translation is marked as requiring an update, preventing an outdated translation from being used for changed content.
When translating content, the plugin makes every effort to preserve:
- Gutenberg block markup
- HTML structure
- Shortcodes
- Placeholders
- URLs
- Content inside
<pre>and<code>elements, which is left untranslated - Protected special content
Text segments that belong to the same post are sent to Baidu in one multi line request where possible, instead of one request per paragraph. Requests are spaced by the configured interval so the free plan's per-second limit is not exceeded, and transient provider errors are retried automatically.
HTBD provides essential SEO support for multilingual pages, including:
- Multilingual permalinks
- Canonical URLs
hreflangalternate links on singular views and in localized sitemapsx-defaultpointing at the source language- SEO field translation
If a Baidu Translate API request fails, the plugin does not cause the website page to fail:
- If no translation is available, the website's source-language content is displayed.
- If a previously saved successful translation exists, the previous translation continues to be used.
The settings screen includes a diagnostics panel that checks the translation table, the permalink structure, language URL routing, the scheduled task queue, and the Baidu credentials with one short test request.
When WP-CLI is available, translations can be managed without the admin screen:
# Translate every published post into English, 20 at a time
wp htbd translate --language=en --limit=20
# Retranslate a single post
wp htbd translate --post_id=42 --force
# Translate categories and tags
wp htbd translate-terms --taxonomy=category
# Show the configuration, queued jobs, and stored row counts
wp htbd status
# Move stored translations between sites
wp htbd export translations.csv
wp htbd import translations.csv --dry-run- Open the Baidu Translate Open Platform.
- Register or sign in with a Baidu account.
- Open the management console.
- Activate the General Text Translation API service.
- Create an application and enter the required application information.
- Obtain the APP ID and secret key from the application management page.
Your APP ID and secret key are sensitive credentials. Do not commit them to a public GitHub repository or expose them in front-end code or public logs.
For activation instructions, pricing, and usage limits, see the official Baidu Translate API documentation.
HTBD is listed in the WordPress.org Plugin Directory, so WordPress can install and update it automatically.
- Sign in to WordPress Admin.
- Open Plugins > Add New Plugin.
- Search for HTBD or hyx Translator for Baidu Translate.
- Select Install Now, then select Activate.
- Visit the HTBD GitHub repository.
- Select Releases.
- Download the hyx-translator-for-baidu-translate-*.zip file from the latest release.
- Sign in to WordPress Admin.
- Open Plugins > Add New Plugin.
- Select Upload Plugin.
- Choose the downloaded ZIP file and start the installation.
- Activate HTBD after installation is complete.
- Visit the HTBD GitHub repository.
- Select Releases.
- Download the hyx-translator-for-baidu-translate-*.zip file from the latest release.
- Upload the
hyx-translator-for-baidu-translatedirectory to the WordPress plugin directory:wp-content/plugins/hyx-translator-for-baidu-translate/. - Sign in to WordPress Admin.
- Open Plugins > Installed Plugins.
- Find HTBD and select Activate.
- Sign in to WordPress Admin.
- Open the HTBD settings page.
- Enter the APP ID and secret key provided by the Baidu Translate Open Platform.
- Set the website's source language, or enable Automatically detect the source language to use Baidu's
autosource language mode. - Add the target languages you want to enable.
- Select a language URL mode, such as language subdirectories or domain binding.
- Choose the post types and taxonomies to translate.
- Adjust the request interval if your Baidu plan allows more than one request per second.
- Save the settings.
After changing language routing settings, open Settings > Permalinks in WordPress Admin and confirm that the permalink configuration is working correctly.
Automatic detection is stored as a separate setting. Entering auto in the source language field without enabling automatic detection remains a distinct configuration state.
- Open the post or page you want to translate in WordPress Admin.
- Save or update the content.
- Use the translation feature provided by HTBD to generate translations for the target languages.
- Wait for the translation tasks to finish.
- Check each translation at its language-specific URL.
For example, suppose the source-language page is available at:
https://example.com/about/When English uses the /en/ subdirectory, its translated URL is:
https://example.com/en/about/When Japanese uses the /jp/ subdirectory, its translated URL is:
https://example.com/jp/about/Requests for wp-login.php or wp-admin through a target-language subdirectory or bound domain are redirected to the corresponding source-site URL. Query parameters are preserved.
The plugin prioritizes saved translations. It calls the translation API again only when the source content changes, a translation becomes invalid, or a user explicitly requests a refresh.
- Test permalinks and multilingual routing in a staging environment before enabling the plugin in production.
- Set appropriate usage quotas and security policies for the Baidu Translate API.
- Do not store API credentials in source code, front-end JavaScript, or public logs.
- Manually review brand names, technical terminology, and important pages before publishing translations.
- After changing source content, check whether the corresponding translations need to be updated.
- When configuring domain binding, also configure DNS, HTTPS certificates, and the server's domain settings.
- After changing language routing, verify that canonical URLs,
hreflanglinks, and sitemaps are correct. - Run the diagnostics panel after any hosting, permalink, or credential change.
- WordPress 6.4 or later
- PHP 8.1 or later
- A server environment that can connect to the Baidu Translate API
- A valid Baidu Translate Open Platform APP ID and secret key
# Lint every PHP file
find . -path './.git' -prune -o -name '*.php' -print0 | xargs -0 -n1 php -l
# Run the standalone checks: no WordPress, network access, or credentials needed
for test in tests/*.php; do php "$test" || exit 1; done
# Build the installable ZIP, verified against the header and readme stable tag
./build.sh buildThe checks in tests/ stub the WordPress functions they call, so they run on any machine with PHP. They cover translation batching, cron argument normalization, sitemap fallback markup, URL rewriting, domain normalization, translation context parsing, browser language matching, and the PO to JED JSON conversion used by the block editor.
Script translations are a separate channel from PHP translations. The block editor reads JED JSON through wp_set_script_translations() and never consults the MO file, so build.sh regenerates languages/hyx-translator-for-baidu-translate-zh_CN-htbd-language-switcher-block.json from the PO file with tools/make-json.php and fails if the JSON file is missing from the archive. A raw checkout therefore contains neither the MO file nor the JSON file until ./build.sh build runs.
To report a problem or suggest a feature, visit the GitHub repository:
https://github.com/hanyixuanten/HTBD
When opening an issue, consider including the following information:
- WordPress version
- PHP version
- HTBD version
- Languages and routing mode in use
- Steps to reproduce the problem
- Error logs with sensitive information removed
Contributions through issues and pull requests are welcome.