[WordPress] 外掛分享: WP Base Translate

WordPress 外掛 WP Base Translate 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「WP Base Translate」是 2017-02-23 上架。
  • 目前有 10 個安裝啟用數。
  • 上一次更新是 2020-05-22,距離現在已有 1808 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.1 以上版本才可以安裝。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

geronikolov |

外掛標籤

modern | simple | translate | translating | translation |

內容簡介

大部分的翻譯外掛程式都是非常複雜且混亂的…
因此使用 WP_BASE_TRANSLATE,您只需要點擊幾下即可創建、編輯或移除新語言!

當安裝了此外掛時,它會執行以下操作:

註冊語言客製文章類型(CPT)
在安裝的數據庫中創建_WP_PREFIX_page_language_relations表格
在文章/頁面(Post/Page)中添加語言的相關框框(這也可以用於所有的CPT)
添加可翻譯的可用語言相關框框。

如何添加新語言?

語言是使用語言CPT中的文章註冊到您的數據庫中的。
因此,只需轉到“語言”>“新增”>輸入語言名稱(作為文章標題)>選擇語言國旗圖示(可選)即可創建新的語言。

這就是全部!

如何翻譯?

如上所述,您可以翻譯 WordPress 中安裝的每個 CPT 中的每篇文章。

為了實現這一點,外掛登記了一個稱為“可翻譯語言”的元框,該元框表示您可以用哪些語言(作為啟用的按鈕)來翻譯特定頁面。
在開始翻譯之前,您必須從“頁面語言”下拉框中選擇該頁的當前語言。這將告訴外掛哪種語言是母語並將其與翻譯版本連接起來。
選擇完成後,只需選擇要查看該頁面的語言,然後開始翻譯內容即可。

就是這樣!

在前台如何運作?

WP_BASE_TRANSLATE 的設計目的就是簡單易用,因此,如果您的網站目前已經有與語言選單選項連接,該外掛也可以使用。
只有一項該外掛正常運作所需要遵守的要求,那就是在您的網頁URL中添加 lang 參數。

例子:http://geronikolov.com/blog —> http://geronikolov.com/blog?lang=bg (那將會呼叫Blog頁的保加利亞語翻譯版)

如果我網站上沒有該語言實現呢?

WP_BASE_TRANSLATE 為您提供了一個簡單的語言下拉選單,可將其放在任何您想要的地方!
要添加到您的文章、頁面或代碼中,只需使用這個短代碼 – [language_menu]

如何構建語言列表菜單?

由於該外掛不提供硬編碼菜單,因此它提供了一種非常靈活的後端方法,可讓您與您的網站進行實現結合,該外掛的核心獨享提供了一個名為 get_registered_languages() 的函數,返回一組表示已註冊語言的物件。

每個語言物件都包含:

語言ID:該文章在數據庫中的ID
語言名稱:該文章的標題
語言代碼:語言標題的簡短版本,例如,如果您標題是 EN,則代碼將為 en。您應該在導航菜單中使用它作為 lang 參數的值。
語言全名:該語言的全名。例如:EN = 英語;ES = 西班牙語
語言Slug:您從 WordPress Dashboard 中選擇的文章Slug。 默認情況下,它是等於語言代碼的標題的較小版本。
語言鏈接:該語言文章物件的永久鏈接。
語言作者:在您的 WordPress 安裝中創建此語言的管理員的ID。
語言圖標:選自 WP Dashboard 的語言圖標的連接,通常為該語言的父國家的國旗。

原文外掛簡介

Most of the translation plugins are built in very complicated and messy way…
That’s why with WP_BASE_TRANSLATE you can create, edit or remove new languages in just a few clicks!
When the plugin is installed it performs the following things:

Registers the Language Custom Post Type (CPT)
Creates the _WP_PREFIX_page_language_relations table in your installation Database
Adds page language metabox to Post / Page (it works with all CPTs as well)
Adds avalilable languages metabox on which your page can be translated

How to add a new language?
The languages are registered in your database as Posts from Language CPT.
So to create a new language just go to Languages > Add new > Enter name (as title of the post) > Choose the icon of the language (optional as featured image).
That’s it!
How to translate?
As we mentioned above you can translate every post from a CPT in your WordPress installation.
To achieve that the plugin is registering a meta box called Available Languages, which represents the list of all available languages (as active buttons) on which you can translate the specific page.
Before you can start translating, you have to choose the current language of the page from the Page Language dropdown box. That will tell the plugin which is the parent language and connect the translated versions with it.
Once you do that, you just have to select the language on which you want to see your page and start translate the content in it.
That’s all!
How it works on the front?
WP_BASE_TRANSLATE is meant to be easy, so if you currently have a language menu option connected on your website it’ll work with it.
The only requirement for the plugin to work properly is to add lang parameter in your page URL.
Example: http://geronikolov.com/blog —> http://geronikolov.com/blog?lang=bg (that will call the Blog page translated in Bulgarian)
What happens if I don’t have that language implementation in my site?
WP_BASE_TRANSLATE gives you a simple language dropdown menu, which can be placed everywhere you want it!
Do add to your Posts, Pages or Code, just use this shortcode – [language_menu]
How to build the Language listing menu?
Since the plugin doesn’t provide a hardcoded menu, it provides a very flexible back-end method for implementing it with your website.
The core of the plugin gives you a function called get_registered_languages() which returns an Array of Objects which represent the registered Language objects.
Every language object has:

Language ID: That’s the ID of the Post in the database
Language Name: That’s the Title of the Post
Language Code: That’s the small version of your language title, for example if you have EN as title, the code will be en. In the navigation menu you should use it as value of the lang parameter.
Language Full Name: That’s the full name of the language. Example: EN = English; ES = Espanol;
Language Slug: That’s the post slug you’ve choosed from the WordPress Dashboard. By default it’s smaller version of the title equal to the Language Code
Language Link: That’s the permalink of the Language Post Object.
Language Author: That’s the ID of the Administrator who created the language in your WordPress installation.
Language Icon: That’s the link to the language icon, which was selected from the WP Dashboard. Usually it’s the flag of the Parent Country of the language.

The wpbt_get_registered_languages() function can be found in the functions.php file positioned in the root folder of the plugin.
Functions list: functions.php
wpbt_get_registered_languages()
wpbt_get_translation_id()
How to contribute?
You just have to clone the repository and build!
If you want to extend the WP_BASE_TRANSLATE Core make sure to add small comment block above each of your functions.
The code block should look like:

/*
* Function name: example_function
* Function arguments: $post_id [ INT ]
* Function purpose: This function is just for an example.
*/
function example_function( $post_id ) { return "John Snow is alive!"; }

Join the contributions!

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「WP Base Translate」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0 | 1.1 | 2.0 | 3.0 | 3.1 | trunk |

延伸相關外掛(你可能也想知道)

  • Never POEDIT 》功能, 這個外掛允許您翻譯在管理員控制台中沒有翻譯函數套用的任何文本。該外掛提供您編寫詞彙表的功能, 並指定要在哪些部分網站中進行輸入內容的翻譯。, 支...。
  • Magic Post Translate 》使用 Deepl 自動翻譯文章和頁面。 , 您需要一個 Deepl API 金鑰來進行翻譯。, 您可以:, , 設置您的 Deepl API 金鑰, 選擇 9 種語言:英語、德語、法語、西班...。
  • Yard DeepL 》總結:, 此外掛註冊安全的API端點,允許您直接從DeepL請求翻譯,而不需公開DeepL API金鑰。只有在提供有效nonce時才能訪問這些端點。在向網站訪問者提供翻譯時...。

文章
Filter
Apply Filters
Mastodon