Link to a .po file in a child theme

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 :

Read More
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 ?

Related posts

Leave a Reply

3 comments

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

    load_child_theme_textdomain(
        'PARENT THEME DIRECTORY NAME', 
        dirname(__FILE__) . '/LANGUAGE FILES SUBDIRECTORY NAME'
    );
    

    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.

  2. 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.

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