I want to put a function in the functions.php file so that when the user activates the template, all the files with .mo and .po extensions are copied to the wp-content\languages\themes
path.
For this purpose I have used the following code which did not work:
function load_the_languages() {
load_theme_textdomain( 'themePro', get_template_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'load_the_languages' );
The source I used to write the above function:
Please help me to create a function that can copy all files with .mo and .po extension to wp-content\languages\themes
path.
I came up with the above code after a lot of searching and I hope there is a better way to do this.
Thanks in advance for any help.
The function
load_theme_textdomain
() is used to load the translation files for the theme, but it doesn't actually copy the files to a different location. If you want to copy the .mo and .po files from your theme'slanguages
directory to thewp-content/languages/themes directory
when the theme is activated, you can use theafter_switch_theme
hook, which fires after the theme iss switched.Hope that helps!