Translation
- Themes are multilingual ready.
- Find .pot file at its default location.
Location: Theme folder / languages / .pot
Step 1:
Edit .pot file ( add your translations) and generate a .po / .mo file for your language
Step 2:
Upload these both .mo/.po files for your language, in Child Theme inside folder named as languages.
So .mo/.po File Upload Location will be:
Child Theme folder / languages / es_MX.po and es_MX.mo ( for Spanish (Mexico) language )
Step 3:
Add below function in child theme’s functions.php and save.
Child theme contains this functions.php file by default.
// Load translation files from child theme instead of the parent theme function my_child_theme_locale() { load_child_theme_textdomain( 'vrukshagra', get_stylesheet_directory() . '/languages' ); } add_action( 'after_setup_theme', 'my_child_theme_locale' );
- That’s all. Frontend will show translated text.
!Never add language translation files (.mo/.po), in main theme itself. Please make sure to read below mentioned.
- Never add your .po/.mo files in main theme.
- You will loose these files on theme update.
- To avoid this, always use child theme.
- Better way to add these files is in child theme at the same location.
Location: Child Theme folder / languages / es_MX.po and es_MX.mo ( for Spanish (Mexico) language )