Before your question goes to someone else on my team, let me explain some first steps to help you. This will make getting support faster.
From the example you provided, there are two texts available
1) Choose an option
2) Choose a size
The 2nd one should be translated without any issue, the 1st one is added as an if/else condition so it will not be available for translations, in general, any code that's being printed/displayed should be translated.
If you want to check multiple items as either or for translations you can modify the code accordingly.
if ( $domain === 'woocommerce' && ( $text === 'Choose an option' || $text === 'Translated choose an option' ) ) {
// Your code here if the condition is met
}
The above code checks if either the text is choose an option or Translated choose an option.
I replaced the code but now the text "Choose an option" doesn't change on English version (hidden link). However, I can translate it into the other languages. How can I fix it?
As mentioned in my previous reply, with the mentioned code, you can't translate "Choose a options" I think it's added using themes or plugins so please follow the below steps:
- Go to WPML->Strings Translations->Auto Register strings for translations
- Enable the "Look for strings while pages are rendered" options
- Now visit the page on front-end where string is shown, this will automatically register strings from that page
- Now go to WPML->Strings Translations->Auto Register strings for translations and disable the options
- Search for the strings in WPML->String Translations and translate it
or
- Go to WPML->String Translations
- At the bottom of the String Translation table, click on “Translate link in admin screens”
- Search for the strings there and see if you can find it.
- If you are able to find it, select it and add it using “Add to string translation” button
- Click on “Return to String Translations”
- Translate it
On your first message you said "The 2nd one should be translated without any issue", but this is wrong because the text I can translate is the 1st one "Choose an option", as you can see on the screenshot I'm attaching.
So with my snippet I could change the text "Choose an option" to "Choose a size" but I can't translate "Choose a size". How can I translate it?
If the problem still exists, To debug this issue further, I would need to check your site settings once, for this I would need temporary access (wp-admin and ftp) to your site.
So could you please provide me with those details, you will find the needed fields for this below the comment area when you log in to leave your next reply. hidden link