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 ?
You will need to use the function
load_child_theme_textdomain()
.Also, there is some interesting discussion here.
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:
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.
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.