Tagged: Poedit, translation
-
AuthorPosts
-
July 19, 2019 at 6:23 pm #1120309
Hi Enfold Team,
we are using Enfold for a lot of projects (at least over 20) and are having trouble translating our child themes.
We tried to fix this issue by ourselves for quite some time now, but couldn’t succeed.
Our Setup:
- Multisite (one for each language)
- Language is being set on wp admin screen (options general)
- We’ve created language files (po/mo) in a /lang/-folder
- We are using poedit for translation (and would love to keep it that way)
- We defined text domain and domain path within style.css (following the instructions here: https://developer.wordpress.org/themes/functionality/internationalization/)
- We tried using the instructions here https://kriesi.at/documentation/enfold/translation/ but this didn’t help
- Further information can be found here: https://wordpress.stackexchange.com/questions/334595/child-theme-translations-with-poedit
Main Issues:
- Translations for our text domain are being loaded correctly
- Translations for the Enfold parent theme are not being loaded (e.g. 404 page, enfold widgets, etc)
- When updating poedit, all enfold translations are being removed from the files, just leaving the child theme translations. Could this be the reason?
Code:
functions.phpadd_action( 'after_setup_theme', 'avia_lang_setup' ); function avia_lang_setup() { $lang = get_stylesheet_directory() . '/lang'; load_child_theme_textdomain( 'mytextdomain', $lang ); }
style.css
/* Theme Name: mytheme Description: A <a href='http://codex.wordpress.org/Child_Themes'>Child Theme</a> for ClientXYZ. Version: 1.0 Template: enfold Text Domain: mytextdomain Domain Path: /lang */
Notes:
As documented here https://developer.wordpress.org/themes/functionality/internationalization/The text domain name must use dashes and not underscores and be lowercase.
-> We made sure not to use underscores in our text domains (as opposed to the stackexchange question)
-> BUT the Enfold text domain is “avia_framework” (could this be an / the issue?)July 23, 2019 at 6:53 am #1121098Hey Chris,
Thank you for using Enfold.
Are you trying to use your own translation in the child theme? Please remove the current code in the functions.php file and replace it with the following snippet.
function overwrite_language_file_child_theme() { $lang = get_stylesheet_directory().'/lang'; return $lang; } add_filter('ava_theme_textdomain_path', 'overwrite_language_file_child_theme');
Which texts in particular are you trying to translate?
Best regards,
IsmaelJuly 23, 2019 at 11:56 am #1121165Hi Ismael,
Thanks for your help, but the code you provided unfortunately couldn’t solve the problem. Actually after embedding your code no translation was loaded at all.
There are a lot of strings we’d like to translate like
– “Share this entry”
– “You might also like”
– “Leave a reply”
– Placeholder “Search” in the search bar
– and so on.Basically we can say that only child theme strings which are comprised in the child theme po/mo files are being translated, while none of the parent theme strings are.
Looking forward to your reply.
Thanks a lot in advance!
July 25, 2019 at 2:59 pm #1121920Hi,
Thank you for the update.
Did you put the language files (.po|.mo) inside the “lang” folder of the child theme? The purpose of the filter above is to redirect the theme text domain directory to the child theme’s “lang” folder.
You can also use this plugin.
// https://wordpress.org/plugins/loco-translate/
Best regards,
IsmaelJuly 25, 2019 at 3:02 pm #1121921Hi Ismael,
yes, we have the po/mo files in the child theme /lang/ folder.
As we have really a lot of enfold installs in this configuration we’d love not to use a plugin.
If you need any server access please just let me know.
Thanks a lot again in advance!
July 26, 2019 at 4:37 am #1122049Hi,
Thank you for the update.
Yes, please post the WP and FTP details in the private field. Can you provide the corresponding translations for the texts so that I can add them?
Best regards,
IsmaelJuly 26, 2019 at 1:40 pm #1122164Thanks for your reply Ismael!
Please find the login data attached.
July 29, 2019 at 5:40 am #1122626Hi,
Thank you for the update.
We disabled the “avia_lang_setup” function in your child theme and reactivated the “avf_overwrite_language_file_child_theme” function. (see private field)
Best regards,
IsmaelJuly 29, 2019 at 12:08 pm #1122721Hi Ismael,
Thanks a lot for your help!
We have a 1:1 copy of the environment you just made the changes.
When just activating the “avf_overwrite_language_file_child_theme” there we still have the same issue.
Did you do anything else (no matter how unimportant) ???
Thanks again a lot in advance!
July 30, 2019 at 3:41 am #1123018Hi,
Did you update the language files? Sorry, I forgot to mention that I also updated the language files in the “lang” folder using the latest version from the parent theme.
Thank you for the update.
Best regards,
IsmaelJuly 30, 2019 at 2:47 pm #1123158Hi Ismael,
Thanks a lot for your help.
Updating the language files might be part of the solution. Could you explain to me in detail how you updated them?
We use Poedit and it automatically scans our child theme for new strings matching our text domain.
When doing so it also automatically removes all strings which have a different text domain from the po/mo files, which means all the strings with “avia_framework” as text domain (enfold strings) are being removed.
We always thought that this step is how it’s supposed to be, but now we get the feeling that this might be part of the problem.
Is there a way to manually add the strings to our language files?
August 1, 2019 at 10:00 am #1123820Hi,
We just copied the latest version from the parent theme and place it in the child theme’s lang folder. You need to use the “avia_framework” text domain because the strings that you’re trying to translate belongs to it. The underscores in the text domain name may not be in accordance with the I18n standards but it’s still going to work. If you want to use POEdit, try to manually open the PO file in the lang folder, translate the strings, then compile the MO file.
Best regards,
IsmaelAugust 14, 2019 at 4:38 pm #1127657Hey Ismael,
Thanks for your latest reply!
We just realized that this code here works for us:
add_action( 'after_setup_theme', 'avia_lang_setup' ); function avia_lang_setup() { $lang = apply_filters('enfold', get_template_directory() . '/lang'); load_theme_textdomain('avia_framework', $lang); load_child_theme_textdomain( 'child-theme-text-domain', get_stylesheet_directory() . '/lang' ); }
August 14, 2019 at 4:51 pm #1127660Hi,
Great! Did you need additional help or shall we close this topic?
Best regards,
Jordan ShannonAugust 14, 2019 at 5:57 pm #1127678Hi Jordan,
all good now, you can close the topic.
Thanks!
August 14, 2019 at 6:05 pm #1127681Hi,
If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘Translation with Poedit and Child Theme’ is closed to new replies.