[EventCalendar] EC3 + qTranslate

Marc Boivin mjsdesign at gmail.com
Sun Mar 22 13:02:15 UTC 2009


Well in some way or another code needs to be done. You won't get the  
kind of support you're looking for without some modification of one or  
both plugins (Unless I'm hugely mistaken).

By looking at qTranslate hooks it seems like it's using standard  
locale strings.

You could, provided that you have the required files for translating  
the EC3 calendar plugin, wrote a custom load_plugin_textdomain that  
would look like this:

(WARNING: THIS IS UNTESTED CODE, COMES AS-IS. DON'T USE THAT UNLESS  
YOU KNOW WHAT YOU ARE DOING)

/**
  * Loads the plugin's translated strings, with an optional custom  
language option
  *
  * If the path is not given then it will be the root of the plugin  
directory.
  * The .mo file should be named based on the domain with a dash  
followed by a
  * dash, and then the locale exactly.
  *
  * @param string $domain Unique identifier for retrieving translated  
strings
  * @param string $abs_rel_path Optional. Relative path to ABSPATH of  
a folder,
  * 	where the .mo file resides. Deprecated, but still functional  
until 2.7
  * @param string $plugin_rel_path Optional. Relative path to  
WP_PLUGIN_DIR. This is the preferred argument to use. It takes  
precendence over $abs_rel_path
  * @param string $locale Specify the local you want to load the mo  
file in. This is used to facilitate pages with multiple locales
  */
function custom_load_plugin_textdomain($domain, $abs_rel_path = false,  
$plugin_rel_path = false, $locale=false) {
	if(!$locale)
                 $locale = get_locale();

	if ( false !== $plugin_rel_path	)
		$path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/');
	else if ( false !== $abs_rel_path)
		$path = ABSPATH . trim( $abs_rel_path, '/');
	else
		$path = WP_PLUGIN_DIR;

	$mofile = $path . '/'. $domain . '-' . $locale . '.mo';
	load_textdomain($domain, $mofile);
}

Then you could use that custom custom_load_plugin_textdomain to load  
EC3 language file with the qTranslate locale. This is UNTESTED and  
only a concept. It requires coding, testing and more testing. But it  
could be a solution.

If someone feels like testing it and code the function that links  
qTranslate and EC3, it'll be nice.

Good luck,

Marc

On 21-Mar-09, at 1:51 PM, ecir hana wrote:

> On Sat, Mar 21, 2009 at 6:01 PM, Marc Boivin <mjsdesign at gmail.com>  
> wrote:
>> EC3 uses the built-in translate functions to handle localization.  
>> This means
>> that it will display in the current language -- like you said, the  
>> wplang
>> setting-- not the language of the post.
>>
>> Maybe you could fiddle around changing the local on the fly. But  
>> that would
>> require some programming.
>>
>> If you feel up to the challange check out the l10n.php file from
>> wp-includes. It has everything you need. You could create a EC3- 
>> qTranslate
>> support extension. It would check if the qTranslate extension is  
>> loaded, if
>> so, override the current locale while rendering the calendar and  
>> setting it
>> back to default when done.
>>
>>
>
> Or, one can specify the title of "Upcoming Events" in "Current
> Widgets" in admin section so if I could somehow write there:
>
> <!--:en-->english text<!--:--><!--:de-->german text<!--:-->
>
> or
>
> [:en]English[:de]Deutsch
>
> and it would get translated.
>
> Maybe this would be more simple to add in the EC source code  
> somewhere...?
>
> _______________________________________________
> Blog: http://wpcal.firetree.net/
> EventCalendar at firetree.net mailing list
> Unsubscribe: http://penguin.firetree.net/eventcalendar




More information about the EventCalendar mailing list