Divide and Conquer: Separated Bilingualism

I had set up my old site, fodina.de bilin­gual. With the help of WP-Globus. As nice as this worked for years, at last WP-Globus got lost. Thor­ough­ly! When I edit­ed the Ger­man text, it made the Eng­lish dis­ap­pear. And vice ver­sa. Some­thing like that shall not hap­pen to me again. The restora­tion was com­plex and com­pli­cat­ed. So, while migrat­ing to bootScore, I switched to two sep­a­rate sites.

karsten-reincke.de is a Ger­man lan­guage site, fodina.de an Eng­lish. Now there’s no need any­more to trans­late all con­tri­bu­tions alter­nate­ly. Makes no sense with those, which address only Ger­man-speak­ing read­ers. Besides this opens the­mat­ic free spaces: fodina.de is about FOSS, karsten-reincke.de about my oth­er life.

How­ev­er, the pages of my pairs shall still refer to each oth­er. So I need an inde­pen­dent eas­i­ly to insert lan­guage ‘switch­er’. In oth­er words: a short­code. Maybe you will also need such a thing some­times

[ en | de ]

Solution

  • Add the fol­low­ing code to functions.php of your child theme:
/*
 * (c) 2023 Karsten Reincke
 * SPDX-License-Identifier: MIT
 */
function switch_fromto($atts){
  $toSite="http://woimmer.de/mywp.toLang";
  $atts = (array) $atts;
  $fromLang=$atts[0];
  $toLang=$atts[1];
  $toPage=$atts[2];
  $lsw= '<div class="text-right">[ ' . $fromLang . ' | <a href="' 
    .$toSite . "/". $toPage . '">'. $toLang . '</a> ]</div>';
  $res=
  '<div class="container">' .
    '<div class="d-flex justify-content-end sample-row">' .
      '<div class="col-xs">' . 
        $lsw .
    '</div></div></div>';
  return $res;
}
add_shortcode('fromto', 'switch_fromto');
  • Adjust woimmer.de/mywp.toLang to your real­i­ty.
  • Add
    [ de | en ]
    on the Ger­man page of the pair and
    [ en | de ]
    on Englisch.

Background

Plu­g­ins for mul­ti­lin­gual sites actu­al­ly always work the same way. Pages and posts exist inter­nal­ly in two ver­sions. WP-Globus put all vari­ants into the same data­base entry, sep­a­rat­ed with mark­ers {:de}...{:}{:en}...{:}. The rest is opti­cal sug­ar that the plu­g­in puts over it. That’s why these plu­g­ins can and must also include a lan­guage chang­er that is geared to their own kind, which the site admin­is­tra­tor can have inte­grat­ed into the menu.

If the mul­ti-lan­guage plu­g­in gets lost, how­ev­er, you are in trou­ble. After all, access to the indi­vid­ual lan­guage sec­tions is only pos­si­ble via the plu­g­in itself any­way. There­fore, the safe option is to work with two sep­a­rate sites. The over­head of main­te­nance out­weighs reli­a­bil­i­ty.

To top