• Labels for the days, months, weeks, hours and so on can’t be translated by WPML String Translation or PO Edit in order to have the timer show labels in different languages when the site is multilingual.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author plugin.builders

    (@pluginbuilders)

    How have you made your site multilingual? Which plugin / theme are you using?
    Currently Waiting doesn’t support Multilingual translations, but if you can edit PHP files, I can give you some code to make it work.

    Thread Starter Vladimir Vassilev

    (@vloo)

    plugin.builders, we are using WPML currently. A patch from you would be great, but why don’t you apply it to the plugin so that everyone could benefit from it?

    Plugin Author plugin.builders

    (@pluginbuilders)

    I assume you have some knowledge of PHP.
    Edit the Waiting.php file of Waiting plugin, look for translateTermsfunction, then replace with the below function.

    Write if/else statements for the lanaguages you need the terms for. See what the constant ICL_LANGUAGE_CODE holds ( uppercase / lowercase etc ), I don’t have WPML installed, I got this constant from some post in their site.

    I have plans for this to include in the plugin, but some users have also asked for Translate forms for each plugin, I’ll have to think about the UI.

    	function translateTerms(){
    		self::$terms['fui'] = array();
    		
    		$unit_terms = array();
    		
    		if( ICL_LANGUAGE_CODE === 'es' ){
    			// Replace Years, Months etc with their Spanish terms
    			$unit_terms =  array(
    				'years' => __('Years', 'waiting'),
    				'months' => __('Months', 'waiting'),
    				'weeks' => __('Weeks', 'waiting'),
    				'days' => __('Days', 'waiting'),
    				'hours' => __('Hours', 'waiting'),
    				'minutes' => __('Minutes', 'waiting'),
    				'seconds' => __('Seconds', 'waiting')
    			);
    		} else if (ICL_LANGUAGE_CODE === 'de'){
    			// Replace Years, Months etc with their German terms
    			$unit_terms =  array(
    				'years' => __('Years', 'waiting'),
    				'months' => __('Months', 'waiting'),
    				'weeks' => __('Weeks', 'waiting'),
    				'days' => __('Days', 'waiting'),
    				'hours' => __('Hours', 'waiting'),
    				'minutes' => __('Minutes', 'waiting'),
    				'seconds' => __('Seconds', 'waiting')
    			);
    		} else {
    			// Return English terms by default. You can make any other language the default one.
    			$unit_terms =  array(
    				'years' => __('Years', 'waiting'),
    				'months' => __('Months', 'waiting'),
    				'weeks' => __('Weeks', 'waiting'),
    				'days' => __('Days', 'waiting'),
    				'hours' => __('Hours', 'waiting'),
    				'minutes' => __('Minutes', 'waiting'),
    				'seconds' => __('Seconds', 'waiting')
    			);
    		} 
    		
    		self::$terms['units'] = $unit_terms;
    	}
    
    Thread Starter Vladimir Vassilev

    (@vloo)

    Yes, I’m familiar with PHP. Sadly the code didn’t work.

    I find it most convenient for the strings not to be editable from the admin panel, but to be available for translation as any other normal string in a theme or plugin, as people wouldn’t want anything else in the Minute label than Minute in their language (I guess?). Anyone building a non-English site will know how to translate the original strings, once they use the gettext functions.

    Plugin Author plugin.builders

    (@pluginbuilders)

    Did you echo ICL_LANGUAGE_CODE; ? I don;t know what’s in ICL_LANGUAGE_CODE. Find the value it contains and compare against it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Does not support multilingual sites’ is closed to new replies.