Can't translate Carpress WP theme widget
-
Hello
I am trying to translate “Opening Hours” widget from Carpress WP theme.
Theme was prepackaged with some languages (.po and .mo files) and there was translation of day names in “Opening Hours” widget.There is code where traslatable strins are placed:
/** * Days of the week, needed for display and $instance variable */ private $days; /** * Register widget with WordPress. */ public function __construct() { parent::__construct( false, // ID, auto generate when false _x( "Carpress: Opening Time" , 'backend', 'carpress_wp'), // Name array( 'description' => _x( 'Opening Time Widget for placing it into the sidebar or above the slider', 'backend', 'carpress_wp'), 'classname' => 'opening-time' ) ); // set the right order of the days $start_of_week = get_option( 'start_of_week ' ); // integer [0,6], 0 = Sunday, 1 = Monday ... $this->days = array( 'Sun' => __('Sunday', 'carpress_wp'), 'Mon' => __('Monday', 'carpress_wp'), 'Tue' => __('Tuesday', 'carpress_wp'), 'Wed' => __('Wednesday', 'carpress_wp'), 'Thu' => __('Thursday', 'carpress_wp'), 'Fri' => __('Friday', 'carpress_wp'), 'Sat' => __('Saturday', 'carpress_wp'), ); $this->rotate_days( $start_of_week ); }
But the problem is that translation of this day names do not appear in front-end. Maybe there is something incompatible with Polylang? As theme support say, translation is working with WPML plugin. And all other content in this theme is translated well.
-
Hello
Deactivate Polylang and in Settings > General: change your default language by the dropdown “Site Language”.
If your strings switch in this default language it’s a conflict either with Polylang or an ajax problem (don’t reload the content).
Could you give a link?You are right. When I disabled plugin and switched language in Settings translation start working.
There is the link http://www.auto.bewus.com/
(currently I am trying to set up LV language)So, is there anything I can do with this code or the problem is much deeper?
Hi!
That’s very strange. Could you add this code just above:
$this->days = array(
?> <pre><?php echo get_locale(); ?></pre> <?php
Then check your front page. Somewhere you should see ‘lv’ or ‘en_US’ (or maybe nothing?).
Hi, Chouby.
I see en_GB even on “Latvian” page.
OK. Could you check your Polylang settings and choose the option The language is set from the directory name in pretty permalinks
This works great! Now widget is translated correctly.
Thank you
- The topic ‘Can't translate Carpress WP theme widget’ is closed to new replies.