{"id":160665,"date":"2022-07-30T22:38:37","date_gmt":"2022-07-30T22:38:37","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/langbranch-shortcode\/"},"modified":"2022-07-30T22:38:20","modified_gmt":"2022-07-30T22:38:20","slug":"langbranch-shortcode","status":"closed","type":"plugin","link":"https:\/\/kn.wordpress.org\/plugins\/langbranch-shortcode\/","author":20546614,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.0.1","stable_tag":"trunk","tested":"6.0.12","requires":"","requires_php":"7.4","requires_plugins":"","header_name":"LangBranch Shortcode","header_author":"Hollen9","header_description":"Display desired string based on current get_locale();","assets_banners_color":"","last_updated":"2022-07-30 22:38:20","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/buymeacoffee.com\/hollen9","header_plugin_uri":"http:\/\/hollen9.com\/","header_author_uri":"http:\/\/hollen9.com\/","rating":0,"author_block_rating":0,"active_installs":0,"downloads":528,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","changelog"],"tags":[],"upgrade_notice":[],"ratings":[],"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[1385,3926,80,95,195341],"plugin_category":[43,48],"plugin_contributors":[],"plugin_business_model":[],"class_list":["post-160665","plugin","type-plugin","status-closed","hentry","plugin_tags-language","plugin_tags-locale","plugin_tags-shortcode","plugin_tags-translate","plugin_tags-translatepress","plugin_category-customization","plugin_category-language-tools","plugin_committers-hollen9"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/langbranch-shortcode.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\nWhat is LangBranch\n\n<p>It's a simple plugin enable you to use a shortcode like below to display correspond language version of content based on <code>get_locale()<\/code>.\n    `php\n[langbranch aio en_US=\"English version\" en_GB=\"en_US\" zh_TW=\"\u4e2d\u6587\u7248\u672c\" ja_JP=\"\u65e5\u672c\u8a9e\u30d0\u30fc\u30b8\u30e7\u30f3\"]<\/p>\n\n<p>[langbranch en_US]\nContent here will only be displayed if get_locale() returns \"en_US\".\n[\/langbranch]\n[langbranch en_US zh_TW]\nContent here will only be displayed if get_locale() returns \"en_US\" or \"zh_TW\".\n[\/langbranch]\n    `<\/p>\n\nMotivation\n\n<p>I've been using TranslatePress to provide multi locale experience for visiters.\nHowever, 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.<\/p>\n\nUsages\n\n<h3>AIO (1-liner) Mode<\/h3>\n\n<p>```php\n[langbranch aio en_US=\"English version\" en_GB=\"en_US\" zh_TW=\"\u4e2d\u6587\u7248\u672c\" ja_JP=\"\u65e5\u672c\u8a9e\u30d0\u30fc\u30b8\u30e7\u30f3\"]\n    <code>By appending<\/code>aio` 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.<\/p>\n\n<p>However, if LangBranch go too deep (chain over 5 stacks) it will fail.\nDon't do this:\n    --1---||---2---||---3---||---4---||---5---||---6---&gt; Oh no!\n    en_US -&gt; en_GB -&gt; en_AU -&gt; en_HK -&gt; zh_TW -&gt; ja_JP<\/p>\n\n<h3>Seperate Mode<\/h3>\n\n<p>```php\n[langbranch en_US]\nContent here will only be displayed if get_locale() returns \"en_US\".\n[\/langbranch][langbranch en_US zh_TW]\nContent here will only be displayed if get_locale() returns \"en_US\" or \"zh_TW\".\n\u9019\u88e1\u7684\u5167\u5bb9\uff0c\u53ea\u6709\u7576 get_locale() \u56de\u50b3 \"en_US\" \u6216 \"zh_TW\" \u624d\u6703\u986f\u793a\u3002\n[\/langbranch]\n    <code>Very straight forward, isn't?\nBut when using several shortcodes, I would suggest you don't put a linebreak between<\/code>[\/langbranch]<code>and<\/code>[langbranch]<code>, in order to prevent unwanted linebreak<\/code><br \/>` being rendered.<\/p>\n\nOptional step\n\n<p>All contents enclosed by <code>[langbranch]<\/code> will be rendered enclosed by <code>&lt;div class=\"langbranch\"&gt;&lt;\/div&gt;<\/code>\nSo if you are using auto machine translating like TranslatePress offers, you may want to exclude all selector <code>.langbranch<\/code>.<\/p>\n\nRecaps\n\n<p>What this \"plugin\" do is very simple, it doesn't has access to either filesystem or database.<\/p>\n\n<p>However, you still have chance to encounter some issues while using it.\nFor the worst case, it breaks your site up if script produce error.\nIf that happen, do not be panic!\nJust go to your <code>wp-content\/plugins<\/code> directory and delete <code>langbranch<\/code> and you shall be fine.<\/p>\n\nLinks\n\n<p><a href=\"https:\/\/github.com\/hollen9\/wordpress-plugin-langbranch\">Visit Github repo<\/a> for issues tracking and reporting.\n<a href=\"https:\/\/hollen9.com\/plugin-langbranch-shortcode\/\">Visit hollen9.com<\/a> for latest updates and thoughts.\n<a href=\"https:\/\/buymeacoffee.com\/hollen9\">Buy me a coffee<\/a> for supporting my works.<\/p>\n\n<!--section=changelog-->\n<h4>1.01<\/h4>\n\n<ul>\n<li>Check array's key before accessing it in order to avoid PHP notice message.<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>Init push<\/li>\n<\/ul>","raw_excerpt":"It&#039;s a simple plugin enable you to use a shortcode like below to display correspond language version of content based on get_locale().","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/160665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=160665"}],"author":[{"embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/hollen9"}],"wp:attachment":[{"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=160665"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=160665"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=160665"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=160665"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=160665"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=160665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}