Multilingual Customizr – how to guide (using qTranslate) for Customizr 3.0.8
-
First off, I want to thank Nikeo for this awesome theme.
In this guide I will teach what needs to be modified in the current version (3.0.8) in order to make Customizr play nice with qTranslate. However, my sincere hope is that in some future version, Customizr will become multilingual ready and all these tiny mods won’t be necessary.
PLEASE BEWARE: If you modify theme files you will lose all those mods on theme update so only do this if you’re willing to do them again with each version or if you’re going to freeze updates for Customizr.
1. Remove limitations on slider titles, slider descriptions and slider buttons:
Go to /wp-content/themes/customizr/inc/admin/class-admin-meta-boxes.php and comment out the following lines: 521 to 527, 552 to 558, 756 to 762 (the if-s, with the corresponding accolade). To comment out you either put // in front of each line, or you put /* before the block of lines and */ at the end. Example: (how to comment out lines 756 to 762):default://for button, color, title and post link field (actually not a link but an id) /* if (strlen( $mydata) > 80) { $mydata = substr( $mydata,0,strpos( $mydata, ' ' ,80)); $mydata = esc_attr( $mydata) . ' ...'; } else { $mydata = esc_attr( $mydata); } */ break;
To remove the 200 chars limitation for featured pages description (between the image and the button, on first page) you need to comment out lines 118 to 125 in /wp-content/themes/customizr/parts/class-content-featured_pages.php.
An alternative to removing the limitations is to set them higher, in accordance with the number of languages your multilingual website will be set to (double the limit for 2 languages, triple it for 3, etc.).
This is because qTranslate saves all languages content in the same field and parses the text before it gets output to the browser, only keeping the active language content.
2. run __() function on content before it gets output in browser
After we have removed the limitations, we have to make sure that qTranslate actually parses the texts before they get printed in the browser. To do that, we have to make sure they are run by the __() function, but before the text is run through any of the esc_attr(), esc_html() or any similar functions, as they might strip away the language shortcodes.For multilingual slider, you need to apply the __() function on $title, $text and $button_text variables in /wp-content/themes/customizr/parts/class-header-slider.php on lines 188, 189 and 191, before the esc_attr() and esc_html() functions, like this:
$title = esc_attr(__(get_post_meta( $id, $key = 'slide_title_key' , $single = true ))); $text = esc_html(__(get_post_meta( $id, $key = 'slide_text_key' , $single = true ))); $text_color = esc_attr(get_post_meta( $id, $key = 'slide_color_key' , $single = true )); // this line doesn't need modifying $button_text = esc_attr(__(get_post_meta( $id, $key = 'slide_button_key' , $single = true )));
As of now, I haven’t been able to make multilingual excerpts for pages work with Customizr, but I was able to display multilingual content in featured pages area using laguage shortcodes (eg: [:en]English featured page text[:es]Spanish featured page text) in the custom descriptions provided by the Customizr options screen. For this to work you need to wrap the $text variable in __() function on line 196 in /wp-content/themes/customizr/parts/class-content-featured_pages.php, like this:
<p class=”fp-text-<?php echo $area ?>”><?php echo __($text); ?></p>
and, for the buttons, on line 199:
<?php echo esc_attr(__(tc__f(‘__get_option’ , ‘tc_featured_page_button_text’))) ?>
I hope I didn’t forget anything and also that this helps those of you who were desperately hoping for a solution to make Customizr slider and featured pages multilingual.
One more thing: in order for all this to work you have to put multilingual texts in the slide fields using qTranslate shortcodes ([:en] english text[:es]spanish text, etc). This is obvious for many, but you need to actually do it in order for the whole thing to work. ??
Wishing some tweaks into future releases of the theme will render my post useless, I thank you for your time.
- The topic ‘Multilingual Customizr – how to guide (using qTranslate) for Customizr 3.0.8’ is closed to new replies.