Btranslate:基于百度翻译 API 的免费开源 WordPress 多语言插件

BTranslate is a WordPress multilingual translation plugin that uses the Baidu Translation Open Platform API to translate articles, pages, and other content on a website into different languages and generate independent language access addresses for the translations.

The plugin will save the translation results on the server. Unless the user actively refreshes the translation, the same content only needs to be translated once in the same target language, without the need to repeatedly call the translation API every time the page is accessed, which helps reduce API requests and improve page loading speed.

Project address

Audit status: BTranslate has not yet passed the WordPress.org plugin directory review, so it cannot be directly installed through the WordPress backend plugin market at the moment. At this stage, please download and manually install from the GitHub repository.

Main functions

Baidu Translation API Integration

BTranslate uses the translation API provided by Baidu Translation Open Platform. Users can configure their own App ID and key in the WordPress backend, and have the plugin handle request signing, translation calls, and error handling.

Article and page translation

The plugin supports translating the main content of WordPress articles and pages, including:

  • Title
  • Body text
  • Abstract
  • SEO Fields
  • Image replaces text
  • Tag
  • Category Directory
  • Partial interface text

Multilingual access address

BTranslate can generate independent access addresses for different languages and supports:

  • Language subdirectories, such as /en/The/ja/
  • Bind different domain names in different languages
  • Generate fixed links for the corresponding language based on the configuration

Translation result persistence

After the translation is completed, the results will be saved in the WordPress server. When accessing the same translation in the future, the plugin will prioritize reading the saved results instead of requesting the Baidu Translation API again.

When the original text changes, the corresponding translation will be marked as needing to be updated to avoid continuing to use old translations that are inconsistent with the original text.

WordPress content compatibility

When translating content, plugins will try to preserve:

  • Gutenberg block tagging
  • HTML Structure
  • Shortcode Short code
  • placeholder
  • URL
  • Protected special content

Multilingual SEO

BTranslate provides necessary SEO support for multilingual pages, including:

  • Multi language fixed links
  • Canonical URL
  • hreflang Multilingual Link
  • Site map compatibility
  • SEO field translation

Failed rollback

If the Baidu Translation API request fails, the plugin will not cause the website page to report an error:

  • If there is no available translation, display the source language content of the website.
  • If there are previously successfully saved translations, continue to use the old translation.

Quick Start

1、 Get Baidu Translation API

  1. openBaidu Translation Open Platform.
  2. Register or log in to a Baidu account.
  3. Enter the management console.
  4. Open the universal text translation API service.
  5. Create an application and fill in the application information.
  6. Get it on the application management page APP ID and Key.

The APP ID and key are sensitive information, please do not submit them to public GitHub repositories, and do not expose them through web front-end code or public logs.

Please refer to the specific activation method, billing rules, and call restrictions of Baidu Translation APIOfficial documentation of Baidu Translation API.

2、 Install plugins

As the plugin has not yet been approved by WordPress.org, it needs to be manually installed from GitHub.

Method 1: Upload ZIP compressed file

  1. visit BTranslate GitHub repository.
  2. Click Releases.
  3. Download zip file from the latest version btranslate-*.zip
  4. Log in to the WordPress management backend.
  5. Open "Plugin" → "Install Plugin".
  6. Click on 'Upload Plugin'.
  7. Select the downloaded ZIP file and start the installation.
  8. Enable BTranslate after installation is complete.

Method 2: Upload to the server

  1. visit BTranslate GitHub repository.
  2. Click Releases.
  3. Download zip file from the latest version btranslate-*.zip
  4. Translate into English btranslate Upload directory to WordPress plugin directory: wp-content/plugins/btranslate/
  5. Log in to the WordPress management backend.
  6. Open "Plugin" → "Installed Plugin".
  7. Find BTranslate and click 'Enable'.

3、 Configure plugins

  1. Log in to the WordPress management backend.
  2. Open the BTranslate settings page.
  3. Fill in the form provided by Baidu Translation Open Platform APP ID and Key.
  4. Set the source language for the website.
  5. Add the target language that needs to be enabled.
  6. Choose the language URL mode, such as language subdirectories or domain name binding.
  7. Save settings.

After modifying the language routing settings, it is recommended to open "Settings" ->"Fixed Links" in the WordPress backend and confirm that the fixed link configuration has taken effect correctly.

4、 Start using

  1. Open the article or page that needs to be translated in the WordPress backend.
  2. Save or update content.
  3. Generate target language translations using the translation function provided by BTranslate.
  4. Waiting for the translation task to be completed.
  5. Check the translation by accessing the corresponding language address.

For example, suppose the source language page address is:

https:/ / example.com/about/

English usage /en/ When it comes to subdirectories, the translation address is:

https:/ / example.com/en/about/

Japanese usage /ja/ When it comes to subdirectories, the translation address is:

https:/ / example.com/ja/about/

The plugin will prioritize using saved translations. Only when the original text changes, the translation becomes invalid, or the user requests a refresh, is it necessary to call the translation API again.

Usage recommendations

  • Before officially launching, please check the fixed links and multilingual routing in the testing environment.
  • Set reasonable call limits and security policies for Baidu Translate API.
  • Do not save API keys in source code, frontend JavaScript, or public logs.
  • Before publishing the translation, it is recommended to manually check the brand name, professional terminology, and important pages.
  • After modifying the original text, it is necessary to check whether the corresponding language translation needs to be updated.
  • When configuring domain name binding, it is necessary to complete DNS, HTTPS certificate, and server domain name settings simultaneously.
  • After modifying the language routing, please check the Canonical URLhreflang Is the site map correct.

system requirements

  • WordPress 6.4 or higher version
  • PHP 8.1 or higher version
  • A server network environment that can access Baidu Translate API normally
  • Effective Baidu Translation Open Platform APP ID and Key

Problem feedback and contribution

If you encounter any problems during use or wish to submit feature suggestions, you can go to the GitHub repository to provide feedback:

https://github.com/hanyixuanten/btranslate

When submitting a question, it is recommended to provide the following information:

  • WordPress version
  • PHP version
  • BTranslate version
  • Language and routing mode used
  • Problem reproduction steps
  • Hidden error logs of sensitive information

Welcome to participate in BTranslate improvement through Issue or Pull Request.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注