[wp-hackers] Plugin Localization

Ryan Boren ryan at boren.nu
Fri Jun 24 16:01:42 GMT 2005


On Thu, 2005-06-23 at 21:41 -0400, Ryan Duff wrote:
> Thats my pick of the two. We've begun to throw wp-contact-form into a 
> folder to keep all the files together. Cleaner for the dev and the user. 
> One folder to upload, one folder to delete.
> 
> Maybe something like this for an updated load_plugin_textdomain() 
> function to check if the plugin resides in a sub-folder...
> 
> function load_plugin_textdomain($domain) {
>      $locale = get_locale();
>      $plug_dir = dirname(__FILE__);
> 		
> 		if ($plug_dir != 'plugins') {
> 				$mofile = $plug_dir . "$domain-$locale.mo";
> 		} else {
> 				$mofile = ABSPATH . "wp-content/plugins/$domain-$locale.mo";
> 		}
> 
>      load_textdomain($domain, $mofile);
> }
> 
> 
> rboren: any comments?

Just some technical details.  __FILE__ in this context will always
be .../wp-includes/wp-l10n.php, not the plugin file.  __FILE__ needs to
be passed to load_plugin_textdomain(), perhaps as an optional second
argument.

Ryan



More information about the wp-hackers mailing list