前言介紹
- 這款 WordPress 外掛「LangBranch Shortcode」是 2022-07-29 上架。 目前已經下架不再更新,不建議安裝使用。
- 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
- 上一次更新是 2022-07-30,距離現在已有 1008 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛要求網站主機運作至少需要 PHP 版本 7.4 以上。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
hollen9 |
外掛標籤
locale | language | shortcode | translate | TranslatePress |
內容簡介
什麼是LangBranch?
它是一個簡單的外掛,讓您可以使用像下面這樣的縮短碼(Shortcode),根據get_locale()顯示對應的內容語言版本。
`php
[langbranch aio en_US=”英文版” en_GB=”en_US” zh_TW=”中文版” ja_JP=”日本語版”]
[langbranch en_US]
只有get_locale()返回"en_US"時,這裡的內容才會顯示。
[/langbranch]
[langbranch en_US zh_TW]
只有get_locale()返回"en_US"或"zh_TW"時,這裡的內容才會顯示。
[/langbranch]
`
激勵
我一直在使用TranslatePress提供多語言體驗給訪客。
然而,每當我更新原始語言的內容時,我就會遺失翻譯的內容,直到我決定創建一個簡單的縮短碼來解決這個問題。
使用方法
AIO(1行)模式
“`php
[langbranch aio en_US=”英文版” en_GB=”en_US” zh_TW=”中文版” ja_JP=”日本語版”]
在langbranch主標記後添加`aio`,您可以在多種語言中設置一個特定的段落,並且如果您決定將某些語言共享給某些地區/國家,您可以直接在內容中輸入想要引用的地區/國家的代碼。例如,您可以將英國版與美國版設置為相同版本。
但是,如果分叉太深(堆疊超過5個),它將失敗。
請勿這樣做:
–1—||—2—||—3—||—4—||—5—||—6—> Oh no!
en_US -> en_GB -> en_AU -> en_HK -> zh_TW -> ja_JP
分開模式
“`php
[langbranch en_US]
只有get_locale()返回"en_US"時,這裡的內容才會顯示。
[/langbranch][langbranch en_US zh_TW]
只有get_locale()返回"en_US"或"zh_TW"時,這裡的內容才會顯示。
要非常直接的,但使用多個縮短碼時,建議您不要在[/langbranch]和[langbranch]之間加入斷行來防止意外出現斷行`被呈現。
可選步驟
所有由[langbranch]包含的內容都會被包含在
中呈現。因此,如果您正在使用TranslatePress等自動機器翻譯功能,您可能希望排除所有選擇器.langbranch。
概括
這個"外掛"所做的事情非常簡單,它既沒有訪問文件系統,也沒有訪問數據庫。
但是,使用時仍有可能遇到一些問題。
在最壞的情況下,如果腳本產生錯誤,它會破壞您的網站。
如果發生這種情況,不要恐慌!
只需轉到wp-content/plugins目錄並刪除langbranch即可。
連結
訪問Github存儲庫以追蹤和報告問題。
訪問hollen9.com以獲取最新更新和想法。
請為我買杯咖啡以支持我的工作。
原文外掛簡介
What is LangBranch
It’s a simple plugin enable you to use a shortcode like below to display correspond language version of content based on get_locale().
`php
[langbranch aio en_US=”English version” en_GB=”en_US” zh_TW=”中文版本” ja_JP=”日本語バージョン”]
[langbranch en_US]
Content here will only be displayed if get_locale() returns “en_US”.
[/langbranch]
[langbranch en_US zh_TW]
Content here will only be displayed if get_locale() returns “en_US” or “zh_TW”.
[/langbranch]
`
Motivation
I’ve been using TranslatePress to provide multi locale experience for visiters.
However, I had been suffering from losting translated content once I update original language’s content, until I decided to create a simple shortcode to solve this problem.
Usages
AIO (1-liner) Mode
“`php
[langbranch aio en_US=”English version” en_GB=”en_US” zh_TW=”中文版本” ja_JP=”日本語バージョン”]
By appendingaio` after langbranch main tag, you can setup one specific paragraph in several languages, and if you decide that some locale user to share the same language, you can just type the locale code you want to refer to directly in content. For example, you can make UK version the same as US version.
However, if LangBranch go too deep (chain over 5 stacks) it will fail.
Don’t do this:
–1—||—2—||—3—||—4—||—5—||—6—> Oh no!
en_US -> en_GB -> en_AU -> en_HK -> zh_TW -> ja_JP
Seperate Mode
“`php
[langbranch en_US]
Content here will only be displayed if get_locale() returns “en_US”.
[/langbranch][langbranch en_US zh_TW]
Content here will only be displayed if get_locale() returns “en_US” or “zh_TW”.
這裡的內容,只有當 get_locale() 回傳 “en_US” 或 “zh_TW” 才會顯示。
[/langbranch]
Very straight forward, isn't?
But when using several shortcodes, I would suggest you don't put a linebreak between[/langbranch]and[langbranch], in order to prevent unwanted linebreak` being rendered.
Optional step
All contents enclosed by [langbranch] will be rendered enclosed by
So if you are using auto machine translating like TranslatePress offers, you may want to exclude all selector .langbranch.
Recaps
What this “plugin” do is very simple, it doesn’t has access to either filesystem or database.
However, you still have chance to encounter some issues while using it.
For the worst case, it breaks your site up if script produce error.
If that happen, do not be panic!
Just go to your wp-content/plugins directory and delete langbranch and you shall be fine.
Links
Visit Github repo for issues tracking and reporting.
Visit hollen9.com for latest updates and thoughts.
Buy me a coffee for supporting my works.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「LangBranch Shortcode」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Bogo 》https://ideasilo.wordpress.com/bogo/, Bogo 是一個簡單易用的 WordPress 多語言插件。, WordPress 自身就具備本地化功能,可以讓您在除英語外的另一種語言...。
Admin Locale 》這個外掛提供了在網站上以某種語言運行(例如阿拉伯語),並在管理面板中使用另一種語言(例如英語)的能力。, 只需前往「設定」»「一般」,然後選擇您...。
Language Fallback 》從WordPress 4.3開始,您可以在您的WordPress安裝中使用像“Deutsch (Sie)”(正式德語)這樣的語言。但是,如果您使用的主題或外掛沒有這種語言的...。
Localize WordPress 》這個外掛能夠讓你將 WordPress 安裝語言切換為在 GlotPress 上提供的任何語言。, 一些功能包括:, , 無需 gettext 編譯器!, 完成所有繁瑣的編輯 wp-config.p...。
WPSSO User Locale Selector 》, 在 WordPress 管理者工具列中提供方便的語言 / 地區選擇器。, 非常適合需要快速更改語言的使用者:, 讓已登入使用者可以輕鬆地在工具列選單中更改他們偏好...。
Locale Auto Switch 》根據瀏覽器語言自動切換語言環境。, , 可以指定多種瀏覽器語言。, 可以透過 CSV 匯入與匯出瀏覽器語言與 WordPress 語言環境設定檔案。, 。
JSM User Locale Selector 》在 WordPress 的後台管理和前端工具列菜單中加入使用者語系下拉選單的外掛程式。, 適合需要快速切換語言設定的使用者使用,允許已登入的使用者從工具列菜單中...。
Add More Body Classes 》「Add More Body Classes」外掛可新增額外的類別至 body 標籤中,新增的類別包括:, , locale-[locale]:例如:對於日文站台會新增 locale-ja,預設英文站則...。
LanguageBack 》我創建了這個外掛,因為我想要前端設置特定的區域功能,而不是使用佈景主題。 我認為我不是唯一想要後端僅限於 en_US 的人,所以這就是這個外掛的用途..., 它...。
JM Buddy Translate 》新增一個「翻譯」按鈕於 WordPress 後台工具列,以翻譯任何所選取的文字。, 新增「翻譯」按鈕於 BuddyPress 和 bbPress 訊息中。, 翻譯選取的文字至當前語系...。
Complete Language Switcher 》Complete Language Switcher 是一個外掛程式,可以讓您建立具備多語言支援的部落格。, 此外,它還可以使用簡單的旗幟清單在語言間切換,而這些旗幟清單也可以...。
Comment Translator 》您是否經常到其他網站看到別人的留言,但卻不了解他們在說什麼?是否因為不理解而感到孤單呢?, 有了 Comment Translator,人與人之間將更加親近 :D。, 功能...。
TrashMail Contact Me 》在您的網站上加入mailto連結,並透過TrashMail服務生成每位訪客的唯一一次性郵件地址。。
Preferred Locale 》根據訪客偏好動態設置網站語言環境。, 此偏好來自用戶的瀏覽器。, 要安裝所有可用的翻譯,請在「設定」->「一般」中點擊「全部安裝」按鈕。, 要安裝單獨的語...。