-
13
Jan
For a new hosting service I am using the new WordPress 3.x multi-site features extensively. For new customers I added a custom theme based on the default Twenty Ten theme. As the main audience aren’t native speakers – English that is – I also need translations for my custom theme. I followed the path twentyten is showing my copying my .mo file into a subdirectory of the theme called languages. Unfortunately the file is not loaded automagically so you need some custom code which I added to my custom theme’s functions.php file.
1 2 3 4 5 6 7 | const MY_THEME = 'name of your theme'; function mytheme_setup() { // The first occurence of MY_THEME is the name of your textdomain as used in the templates load_theme_textdomain( MY_THEME, str_replace('twentyten', MY_THEME, TEMPLATEPATH) . '/languages' ); } // Tell WordPress to run mytheme_setup() when the 'after_setup_theme' hook is run. add_action( 'after_setup_theme', 'mytheme_setup' ); |
If you are defining your own version of twentyten_setup() just add the line with load_theme_textdomain(…) in there. OOP in WordPress would be nice here and make things so much easier!
- Veröffentlicht von Fabio Bacigalupo in: Howto Software Tricks WordPress
- Wenn Sie diese Seite mögen, abonnieren Sie doch unseren RSS-Feed!


Hinterlasse eine Antwort