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.
This topic contains 3 replies, has 2 voices.
Last updated by rinkd 1 year, 11 months ago.
Assisted by: Nicolas V..
Author | Posts |
---|---|
January 27, 2023 at 1:37 pm #12904185 | |
rinkd |
Dear sir/madam, In my child theme, I have made a modification to my menu/header.php from my theme. The only thing I have done is insert a specific link in a button. This works great on my main website. However, since the link is 'hard', pressing the button on my translated/WPML website leads to to the main/untranslated domain. The String Translation --> Admin settings can't find the link. I have done some research here on the forum and read that I need to create a gettext function. However, I am not sure how to do this with a link. If it helps, a piece of code is below (with 'LINKHERE' where the link is). <span class="link_content"> Could someone help me out or point me in the right direction? Thank you for your time and efforts. Best regards, |
January 27, 2023 at 2:06 pm #12904463 | |
Nicolas V. Supporter
Languages: English (English ) French (Français ) Timezone: America/Lima (GMT-05:00) |
Hello, Welcome to the WPML support forum. My name is Nicolas and I will be happy to help you today. That's correct, you should use gettext, we have a full documentation about this: As you will see you can do the following to make the link translatable: $url = __( 'LINKHERE', 'textdomain_here' ); Nico |
January 27, 2023 at 3:02 pm #12904909 | |
rinkd |
Thank you for the fast response Nicolas. I have read the instruction, and have made the URL show up in string translation (it was not in the admin section at the bottom, but it immediately showed up in the string translation section). However, translating the URL to a different URL does not work. It still leads me to the old/untranslated URL. Could you share your expertise what might go wrong? I have changed this: <li id="mh-submit-button"> <span class="item_link"> <span class="link_content"> <a id="myhome-submit-property" href="<em><u>hidden link</u></em>" title="<?php esc_attr_e( 'Submit property', 'myhome' ); ?>" > <?php esc_html_e( 'Submit property', 'myhome' ); ?> <i class="fa fa-plus-circle" aria-hidden="true"></i> </a> </span> </span> </li> to this, which led it to be shown and translatable in String Translation. <li id="mh-submit-button"> <span class="item_link"> <span class="link_content"> <?php $url = esc_url(__('<em><u>hidden link</u></em>', 'myhome')); do_action( 'wpml_register_single_string', 'myhome', 'Submit property URL', $url ); ?> <a id="myhome-submit-property" href="<?php echo $url; ?>" title="<?php esc_attr_e( 'Submit property', 'myhome' ); ?>"> <?php esc_html_e( 'Submit property', 'myhome' ); ?> <i class="fa fa-plus-circle" aria-hidden="true"></i> </a> </span> </span> </li> Which is all done in the child theme's php file, not the functions.php file. Thank you for your time and efforts. |