i'm working in a twenty ten child theme, i want to change the

load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );

$locale = get_locale();
$locale_file = TEMPLATEPATH . "/languages/$locale.php";
if ( is_readable( $locale_file ) )
  require_once( $locale_file );

locate in the twentyten functions by the one in my child theme :

load_theme_textdomain( 'BETA', STYLESHEETPATH . '/languages' );
$locale = get_locale();
$locale_file = STYLESHEETPATH . "/languages/$locale.php";
if ( is_readable( $locale_file ) )
  require_once( $locale_file ); 

With this change in the stylesheetpath the twenty ten function is still taking over my own function How can i fix that ?

  • Do you want to use your translations instead of the ones from Twenty Ten, or do you have extra strings that you want to translate, in addition to those from Twenty Ten? (Use @Jan in your reply so I get a notification) – Jan Fabry Jan 21 '11 at 12:18
  • @Jan i want to add extra strings (my custom post, metabox...) in addition to the Twenty Ten ones – user2621 Jan 24 '11 at 8:09

You will need to use the function load_child_theme_textdomain().

Also, there is some interesting discussion here.

  • i put load_child_theme_textdomain('BETA'); in my child theme function and my BETA.mo file directly in the child theme folder but it doesn't work, i must miss something – user2621 Jan 21 '11 at 9:40
  • @3emeOeil: Your .mo file should not be called BETA.mo, but {$locale}.mo (eg. fr_FR.mo for French). – Jan Fabry Jan 24 '11 at 10:34

If you need to load language files from a subdirectory in a theme child directory, you can use:


For example, if your parent theme name is 'perfect-theme' and you child theme name is 'perfect-theme-child' and the language files are in subdirectory 'languages' of the child theme, the code would be as follows:

load_child_theme_textdomain('perfect-theme', dirname(__FILE__) . '/languages');

The code will only work if language file has appropriate name, which means it should have name LOCALE.mo where LOCALE is you current language settings in wordpress admin.

Example, if your current language is Spanish, wordpress will look for file with name es_ES.mo.


There're multiple approaches to that: First, you could simply remove the function from the hook it's wrapper callback is hooked to.

// Wrapper callback: twentyten_setup()
add_action( 'after_setup_theme', 'twentyten_setup' );
// Inside a child themes functions.php file - wrapped up in a callback, hooked to the same hook:
remove_action( 'after_setup_theme', 'twentyten_setup' );

But then you would be forced to replace the complete Theme Setup process.

Easier, as in @Piero answer noted, you could as well simply load the textdomain from the child theme. The difference to the other answer is, that this example uses the appropriate root location and can be placed in either a child or a parent themes functions.php file.

Note: If placed in the parent themes file, it would force the child theme to have a languages folder that holds the translation files.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy