I have a site where I need to translate the "Search" text.

Hello!

I have a site where I need to translate the "Search" text. I usually do this with Codestyling Localization, but this is a multilingual site so I'm using WPML and I'm unable to find where can I translate this, can you help?

Thanks a lot!

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hiya, Jorge!

    I would very much like to be in that spa right now!

    Okay, I think I see what you're talking about here, the part that says "Start Typing" after you hit the search magnifying glass, correct? That's a really cool search tool, I've never seen anything quite like it, but that means I'm not sure where it's coming from.

    Was it built into your theme? Did you add a custom search plugin? Once we can track down what's generating it, it will be easier to find where that text is coming from.

    Thanks, Jorge!

  • Jorge Castro
    • The Incredible Code Injector

    Hi Michelle!

    I know! jaja me too :slight_smile:

    That search is on the theme, actually I can see the string in the Codestlying plugin, but I believe that since I'm using WPML it doesn't takes effect.

    Thanks a lot Michelle! :slight_smile:

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hey, Jorge!

    I'd like to take a closer look at your theme, if you don't mind. If that's okay, can you send me the following via the contact form?

    Subject: "Attn: Michelle Shull"
    -WordPress admin username
    -WordPress admin password
    -login url
    -FTP credentials (host/username/password)
    -link back to this thread for reference
    -any other relevant urls

    Select "I have a different question" for your topic - this and the subject line ensure that it gets assigned to me :slight_smile:

    https://premium.wpmudev.org/contact/

    Before you do that, however, have you tried our Ultimate Branding plugin to translate this bit of text?

    Thanks, Jorge!

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hello, Jorge!

    I also sent this by email. : )

    I found the text! It was hiding on us.

    /wp-content/themes/salient/includes/header-search.php on line 19.

    <input type="text" name="s" <?php if($ajax_search == 'yes') { echo 'id="s"'; } ?> value="<?php echo __('Start Typing...', NECTAR_THEME_NAME); ?>" data-placeholder="<?php echo __('Start Typing...', NECTAR_THEME_NAME); ?>" />

    You can open and edit that file by using your FTP client and a text editor. Just translate the Start Typing... (leave the 's) right there in the file, both places it appears. Write down the file path, and the edit you make, so the next time the theme updates, it's easy and quick to change it again.

    Take care!

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hi again, Jorge!

    Okay, I did some digging, and I think what we need to do is wrap the text in a call that makes it able to be translated, as described here:

    http://wpml.org/2009/05/wordpress-theme-localization/

    I believe this is that part that applies to your situation:

    Translation without echo

    When you don’t need to echo the string (for example, when it’s the argument of a function), you should use the __() call. This is similar to _e(), but doesn’t echo the translation. For example, in the comment number display, we use:

    Original:

    <?php comments_number('No Responses', 'One Response', '% Responses');?>

    After using the GetText call:

    <?php comments_number(__( 'No Responses', 'wpml_theme'), __('One Response', 'wpml_theme'), __('% Responses', 'wpml_theme'));?>

    The second argument in both these calls is the text domain. This allows texts to be translated in their correct context. If plugins or even WordPress itself includes the same strings, used in a different context, GetText will still provide the correct translation, because we’ve provided our own text domain (wpml_theme).

    <?php echo __('Start Typing...', 'wpml_theme', NECTAR_THEME_NAME); ?>" /

    Should do just that, which would then allow that string to show in WPML.

    Hope this helps!

  • Jorge Castro
    • The Incredible Code Injector

    Hello Michelle!

    Thanks a lot for all the help and the time you have invested in this :slight_smile: Really appreciated.

    I dig into the file and I see that you already did the changes :slight_smile:

    But this doesn't allow that string to be translated in WPML: http://cl.ly/image/3y2Q2d1P2d3E Can't find it.

    And now I have to translate some other things...I was able to translate them using Codestyling, but as expected, they only work on spanish website and not on english..and wasn't able to find those strings neither in WPML...

    Thanks a lot for all the help Michelle! :slight_smile:

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hola, Jorge!

    Well this is certainly being a pickle, isn't it?

    I've still got your login details from the email you sent earlier, I'm going to do a quick audit of your theme just to double check that it's set up to be translated properly.

    Meanwhile, I don't recall if you have a caching plugin installed (like total cache, rocket cache, or super cache.) Can you check to see if you do, and if so, let's try temporarily disabling it. We could still be seeing a cached page from before you successfully translated the theme.

    Thanks, Jorge!

  • Michelle Shull
    • DEV MAN’s Apprentice

    I'm not seeing anything in your theme that's setting off alarms for me, I'm going to add a second flag for second level support, since we seem to be going in circles.

    Where did you get your theme? Have you had any luck talking to the theme developer about this stubborn bit of text?

    Thanks, Jorge!

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hello, Jorge!

    Well that's no good! Things have been pretty busy around here, and I know second level is juggling a lot of threads right now, but we should be able to get someone in here sooner than later.

    Thanks for being so awesome and cheerful, even in the middle of a tricky issue like this one. Members like you are why I love this job so much. Giving you rep points for your patience. : )

  • Jose
    • Bruno Diaz

    Hey there Jorge,

    Hope you are doing great!

    The issue here is that you are not using any .po/.mo files for es_ES language in your theme.

    If you want to avoid editing those files by hand and just use the WPML interface, then you need to enable the option "Traducir por medio de WPML" (Translate via WPML) under WPML->Themes and Plugins Localization. (see image 01).

    Once you enable this feature, WPML will scan your theme and provide you a new set of Strings for translation, under the specific context of your theme -in this case, called "theme salient"-. (see images 02 and 03).

    I have translated only the String "Start Typing...". You will need to translate the rest.

    Now, if you (or any other member) want to use .mo files directly, then the option "Traducir utilizando archivos .mo." (Translate using .mo files) should be enabled, and the specific theme domain should be entered. (see image 04).
    With this configuration, the system will look for one of the following files:
    - your_theme_directory/es_ES.mo
    - wp-content/languages/themes/salient-es_ES.mo

    Hope this helps to clarify. :slight_smile:

    Please let me know if everything works fine now.

    Cheers,
    Jose

  • Jorge Castro
    • The Incredible Code Injector

    WOW!

    Thanks a lot!! We finally got it :slight_smile:

    I'm just missing this translations that I couldn't find in the string translations:

    http://prntscr.com/52snhm

    Where I need to change it both in English and Spanish, because I don't want the "Related products" to be that, and more something like: "Treat yourself". That's on any product page.

    And this one, on a blog post: http://prntscr.com/52so2i I wasn't able to translate the "More posts by" part

    Thanks a lot you both for the help! I really appreciated. I have this problem with other website and I hope I can do it all by myself this time! :slight_smile:

  • Jose
    • Bruno Diaz

    Hey Jorge,

    Glad to hear that it worked :slight_smile:

    The "More posts by" text is located in your theme, in the file ../salient/single.php line 161:

    <?php if(!empty($options['theme-skin']) && $options['theme-skin'] == 'ascend'){ echo '<a href="'. get_author_posts_url(get_the_author_meta( 'ID' )).'" data-hover-text-color-override="#fff" data-hover-color-override="false" data-color-override="#000000" class="nectar-button see-through-2 large"> More posts by '.get_the_author().' </a>'; } ?>

    You will need to change the plain text:
    More posts by
    into a localized text:
    __('More posts by', NECTAR_THEME_NAME)

    Once you make these changes, the new string should showup in the WPML translator. (you may need to re-scan the context).

    Regarding the "Related Products" and "Category" texts, I'm seeing those translated just fine to spanish.
    If you want to change the text for english also, then you will need to create a translation file for en_EN language as you did for spanish here:
    ../wp-content/languages/plugins/woocommerce-es_ES.po

    Please don't hesitate to ask if you have further questions.

    Cheers,
    Jose

  • Jorge Castro
    • The Incredible Code Injector

    Hi Jose!

    Thanks a lot for finding the line! :slight_smile: I made the change but when I did it, the post page stopped working...I just selected the tez
    More posts by
    and replaced with the line you told me, but I believe I'm not escaping the php correctly, so it is detecting the line as HTML and not letting the page function correctly...

    What do you think?

    Thanks a lot!

  • Jose
    • Bruno Diaz

    Done!,

    Your are good to go now.

    I translated "More posts by" as "Otras publicaciones de". You probably would want to change it.

    For the records, this is how the modified line should look:

    <?php if(!empty($options['theme-skin']) && $options['theme-skin'] == 'ascend'){ echo '<a href="'. get_author_posts_url(get_the_author_meta( 'ID' )).'" data-hover-text-color-override="#fff" data-hover-color-override="false" data-color-override="#000000" class="nectar-button see-through-2 large"> '. __('More posts by', NECTAR_THEME_NAME) . ' ' . get_the_author() .' </a>'; } ?>

    Cheers,
    Jose

  • Jorge Castro
    • The Incredible Code Injector

    Thanks a lot José! Almost done! :slight_smile:

    I found the translations here: ../wp-content/languages/plugins/woocommerce-es_ES.po

    And I used the .pot file to create an english translation file in that same location (en_EN) but even tough I made the translation, it doesn't take place.

    Thanks for the help!

    Best, Jorge

  • Jorge Castro
    • The Incredible Code Injector

    Hello @aristath

    That did the trick! :slight_smile: Thanks a lot @Michelle Shull @Jose @aristath @Timothy Bowers @Tyler Postle I really appreciate all the time you all took to solve this, this is awesome support! :slight_smile:

    Have an excellent week! Good wishes to all of you from Cancun!

    Ps. I've never been more happy to mark a ticket as resolved!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.