How to setup non RTL Theme to support TranslatePress
In WordPress sometimes we need to create multi language support websites. There are many plugins are available that allow you to easily add multilingual content to your site.
TransplatePress is a convenient way of translating your WordPress site directly from the front-end, with full support for WooCommerce, complex themes, and site builders.
In this blog, we will take a look at how to change RTL support for the non-supportive themes with TransplatePress.
Following only two essential steps will help you to create RTL support for non-supportive theme –
Step 1
add the following script in your functions.php file
add_action( 'wp_enqueue_scripts', 'load_styles_by_language' );
function load_styles_by_language () {
$current_language = get_locale();
if( $current_language == 'ar' ){
wp_enqueue_style( 'style_rtl', get_template_directory_uri() . '/style-rtl.css' );
}
}
in this function you will add the condition if the active language is Arbic then include style-rtl.css
step -2
In this rtl css you define your rtl class
example –
body {
direction: rtl;
unicode-bidi: embed;
}
.yourclass {
text-align:right !important;
float: left;
clear: right;
}
.image-button{
text-indent:99999px; /* for button make change -99999 to 99999 */
}
You can easily switch languages during the translation, and the live preview will change instantly.