This thread is resolved. Here is a description of the problem and solution.
Problem:
Custom Code is not translatable.
Solution:
The code should be wrapped by the GetText function, then scan the theme/plugin via WPML-> Theme and Plugin Localization.
After that, the strings will be translatable in WPML-> String Translation.
Relevant Documentation:
https://wpml.org/documentation/support/translating-the-theme-you-created/
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Tagged: Custom Work, Documentation request
This topic contains 10 replies, has 2 voices.
Last updated by dvirH-2 1 year, 8 months ago.
Assisted by: Osama Mersal.
Author | Posts |
---|---|
May 20, 2023 at 12:13 am #13681649 | |
dvirH-2 |
Hi, I need help with an issue related to the translation of some custom strings I've added to a WooCommerce registration form via my theme/plugin. In my code, I've added a checkbox for Terms and Conditions, and I'd like to ensure these strings: "I've read and accept the terms & conditions" // Add term and conditions check box on registration form if ( wc_get_page_id( 'terms' ) > 0 && is_account_page() ) { // Validate required term and conditions check box return $validation_errors; Currently, I'm using 'woocommerce' as the text domain in my gettext calls. I've tried scanning for strings in WooCommerce using the String Translation tool in WPML and also checked the Admin Screen Strings, but these custom strings do not seem to appear there, probably because they might not be present in the WooCommerce's original text strings. Can you guide me on how I can make these custom strings translatable? Do I need to create a separate .pot file for these strings and load it with my unique text domain? If so, how do I do that and make it work with WPML? I appreciate any guidance or resources you can provide. Thank you in advance for your assistance. Best regards, |
May 21, 2023 at 9:51 am #13684187 | |
Osama Mersal Supporter
Languages: English (English ) Arabic (العربية ) Timezone: Africa/Cairo (GMT+02:00) |
Hi, Thanks for contacting WPML forums support. I'll be glad to help you today. I'm afraid supporting custom code is out of our support scope, but please check this guide to help you fix the issue. (https://wpml.org/documentation/support/translating-the-theme-you-created/) Also, please try the following steps to help you register the strings if the GetText call is done correctly. Best regards, |
May 21, 2023 at 10:20 am #13684275 | |
dvirH-2 |
Hi Osama, I know the method you mentioned, but I can't scan this page while logged in because it's the site registration/login page. Do you have a solution for this? Thanks, |
May 21, 2023 at 10:22 am #13684277 | |
Osama Mersal Supporter
Languages: English (English ) Arabic (العربية ) Timezone: Africa/Cairo (GMT+02:00) |
Hi, Please let me know where this code is added. Is it added to WooCommerce, your theme, or a custom plugin? Best regards, |
May 21, 2023 at 10:25 am #13684279 | |
dvirH-2 |
I added this code to the function.php file throw dashboard - appearance - theme file editor. |
May 21, 2023 at 10:26 am #13684281 | |
Osama Mersal Supporter
Languages: English (English ) Arabic (العربية ) Timezone: Africa/Cairo (GMT+02:00) |
Hi, Thanks for your update. Please scan your active theme via WPML-> Theme and Plugin Localization, and check if the strings will appear in String Translation. Best regards, |
May 21, 2023 at 8:21 pm #13685465 | |
dvirH-2 |
Thanks Osama, I found the string as you said. How i can add a link to the "Privacy Policy" page in Hebrew? קראתי והבנתי את תנאי השימוש באתר ואת מדיניות הגנת הפרטיות של החברה והם מקובלים עלי לרבות לגבי דיוור ישיר והזכות לבקש הסרה ממאגר זה. This is the page, and its needs to hyperlink the words "מדיניות הגנת הפרטיות": hidden link Thank you |
May 22, 2023 at 6:47 am #13686461 | |
Osama Mersal Supporter
Languages: English (English ) Arabic (العربية ) Timezone: Africa/Cairo (GMT+02:00) |
Hi, If you can see the string in String Translation, please add the hyperlink in the translation field while translating the string. If that is not the case, please share a screenshot of the string in String Translation. Best regards, |
May 22, 2023 at 7:54 am #13686807 | |
dvirH-2 |
I found the string but I don't know how to add a hyperlink to a value I added to the string. |
May 22, 2023 at 7:58 am #13686845 | |
Osama Mersal Supporter
Languages: English (English ) Arabic (العربية ) Timezone: Africa/Cairo (GMT+02:00) |
Hi, Please wrap the marked sentence between <a> tags. For example: |