Multilangual WP with qTranslate X

17 March 2017

A new community-driven plugin – qTranslate XT (support PHP7, Gutenberg, WooCommerce, ACF, All in one SEO, Events Made Easy, Gravity Forms and other).

Install


wp plugin install https://github.com/qtranslate/qtranslate-xt/archive/master.zip --activate

Usage

In PHP:

/*
** where ('[shortcode]')
*/

<?php echo __('[:en]car[:ru]автомобиль[:lv]automašīna');  ?>

With language check:

<?php
  if ( qtrans_getLanguage() == 'en' ) { 
     echo 'english';
  }
  elseif ( qtrans_getLanguage() == 'ru' ) {
    echo 'russian';
   }
  else { 
    echo 'other language';
}?>

or

<?php if(get_locale() == 'ru_RU') { ?>
  Russian
<?php } else { ?>
  English
<?php } ?>

In content:

[:ru]язык[:en]language[:lv]valoda[:]

Display:

/* 
** Text
*/

<?php qtranxf_generateLanguageSelectCode('text', 'language'); ?>

/* 
** Text and flag
*/

<?php qtranxf_generateLanguageSelectCode('both', 'language'); ?>

/*
** Flag
*/

<?php qtranxf_generateLanguageSelectCode('image', 'language'); ?>

/*
** Dropdown
*/

<?php qtranxf_generateLanguageSelectCode('dropdown', 'language'); ?>