New answers tagged

1

The text_direction property of the WP_Locale class defaults to 'ltr' as per it's declaration, then may be modified in the class's init() initialization function in wp-includes/locale.php (near line #207 in WP 4.5) with the following logic: // Set text direction. if ( isset( $GLOBALS['text_direction'] ) ) $this->text_direction = ...


0

Here is a better solution that will not change anything in your post, but will only add a meta // Set the post language when loading up the page based on the store meta function ppl_set_post_language() { $postID = url_to_postid( $_SERVER["REQUEST_URI"] ); if ($postID > 0) { $postLanguage = esc_attr( get_post_meta( $postID, ...


0

I couldn't find an answer so I ended up providing the solution. It wasn't simple given that I am not an expert with wordpress nor with php but Wordpress documentation is great so here is the solution: // Set the post language when loading up the page based on the store meta function ppl_set_post_language() { $postID = url_to_postid( ...


0

I found the solution. There was no languages folder in /wp-content directory. I created a the directory and gave it proper permissions. Switching between languages worked after that.


3

To do it properly, you need to generate a valid .mo file and load the text domain in your theme functions.php: function wpse222346_localize_theme() { load_theme_textdomain( 'your_theme_domain', get_template_directory() . '/languages' ); } add_action( 'after_setup_theme', 'wpse222346_localize_theme' ); You can check the WordPress Codex for more info ...



Top 50 recent answers are included