{"id":1309,"date":"2020-03-08T17:10:32","date_gmt":"2020-03-08T10:10:32","guid":{"rendered":"https:\/\/lab.wptips.dev\/?p=1309"},"modified":"2020-06-21T09:42:22","modified_gmt":"2020-06-21T02:42:22","slug":"bogo-multilingual-plugin","status":"publish","type":"post","link":"https:\/\/pixelstudio.id\/blog\/bogo-multilingual-plugin\/","title":{"rendered":"Bogo &#8211; Best (and Underrated) Multi Language Plugin"},"content":{"rendered":"\n<p>Whenever I like a plugin, I usually check out other plugins that are made by the same developer.<\/p>\n\n\n\n<p>From that, I found a hidden gem called <a rel=\"noreferrer noopener\" aria-label=\"Bogo (opens in a new tab)\" href=\"https:\/\/wordpress.org\/plugins\/bogo\/\" target=\"_blank\">Bogo<\/a>, a multilingual plugin made by <a rel=\"noreferrer noopener\" aria-label=\"Contact Form 7 (opens in a new tab)\" href=\"https:\/\/pixelstudio.id\/blog\/contact-form-7\/\" target=\"_blank\">Contact Form 7<\/a>&#8216;s developer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How it Works<\/h2>\n\n\n\n<p>Instead of using custom database tables (like other competing plugins), it duplicates the Page and assigns the <strong>same URL slug<\/strong>. It&#8217;s normally not allowed by WordPress, but the plugin overrides that restriction.<\/p>\n\n\n\n<p>Then visitors can choose the language by clicking the switcher created by the shortcode <code>[bogo]<\/code>.<\/p>\n\n\n\n<p>Now your site will serve the post with the chosen language.  Additionally, your Blog Index page will only list translated posts.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"615\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-frontend.jpg\" alt=\"\" class=\"wp-image-1311\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-frontend.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-frontend-480x394.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>Language Switcher created by the shortcode <code>[bogo]<\/code><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Setup Process<\/h2>\n\n\n\n<ol><li>Download and install <a rel=\"noreferrer noopener\" aria-label=\"Bogo (opens in a new tab)\" href=\"https:\/\/wordpress.org\/plugins\/bogo\/\" target=\"_blank\">Bogo<\/a>. Go to the new &#8220;Languages&#8221; tab and choose the supported languages.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"397\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-activate-language.jpg\" alt=\"\" class=\"wp-image-1312\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-activate-language.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-activate-language-480x254.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>Activate supported language<\/figcaption><\/figure>\n\n\n\n<ol start=\"2\"><li>Edit an existing post or page. You will find a new section in the sidebar to add a translation. Click the button to duplicate the post or page.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"504\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-add-language.jpg\" alt=\"\" class=\"wp-image-1313\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-add-language.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-add-language-480x323.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>Click the annotated button to add translation<\/figcaption><\/figure>\n\n\n\n<ol start=\"3\"><li>Lastly, edit the duplicated post or page and manually translate the text. <strong>Do not change the URL slug<\/strong> since it can break the language switcher.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"594\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-copied-post.jpg\" alt=\"\" class=\"wp-image-1314\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-copied-post.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/03\/bogo-copied-post-480x380.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>Manually translate the post and publish it.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Dropdown Language Switcher<\/h2>\n\n\n\n<p>There is no filter or action that allow us to edit the markup. So we need to create our own.<\/p>\n\n\n\n<p>In the example below, we will create a shortcode named <code>[bogo-dropdown]<\/code>. You need to replace the <code>[bogo]<\/code> shortcode with this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_shortcode( 'bogo-dropdown', 'my_bogo_shortcode' );\n\nfunction my_bogo_shortcode( $atts ) {\n  if( !function_exists( 'bogo_language_switcher_links' ) ) { return; }\n\n  $links = bogo_language_switcher_links( $args );\n  $count = 0;\n  $output = \"&lt;select onchange='this.options[this.selectedIndex].value &amp;&amp; (window.location = this.options[this.selectedIndex].value);' >\";\n\n  foreach( $links as $link ) {\n    \/\/ abort if empty href\n    if(empty( $link['href'] )) { continue; }\n\n    $extra = '';\n    if ( get_locale() === $link['locale'] ) {\n      $extra = 'selected disabled';\n    }\n    \n    $output .= \"&lt;option value='{$link['href']}' {$extra}> {$link['title']} &lt;\/option>\";\n    $count++;\n  }\n\n  $output .= \"&lt;\/select>\";\n\n  \/\/ if only 1 language, output nothing\n  if( $count &lt;= 1 ) {\n    return '';\n  }\n\n  return $output;\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Bogo has been my go-to multilingual plugin for years. It is <strong>solid, reliable and conflict-free<\/strong>.<\/p>\n\n\n\n<p>It doesn&#8217;t try to do fancy stuff like creating a custom Database table. Everything is just a plain post and URL rewrite.<\/p>\n\n\n\n<p>Even if you deactivate the plugin, your translated posts and pages are still there. Although it&#8217;s not visible via front-end.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Feel free to ask any question regarding Bogo in the comment below \ud83d\ude42<\/p><\/blockquote>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bogo is solid, reliable and conflict-free multilingual plugin. It duplicates your post and uses URL Rewrite to serve the correct translation.<\/p>\n","protected":false},"author":1,"featured_media":1316,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1309","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-plugin"],"blocksy_meta":"","_links":{"self":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/comments?post=1309"}],"version-history":[{"count":8,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1309\/revisions"}],"predecessor-version":[{"id":1649,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1309\/revisions\/1649"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media\/1316"}],"wp:attachment":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media?parent=1309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/categories?post=1309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/tags?post=1309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}