• Resolved m4j4

    (@m4j4)


    Hi,
    Please show me how to make my custom strings translatable in Poedit.

    I’m using Pho theme which is translatable.
    For example in 404.php file there is a line:

    <p><?php _e( 'It looks like nothing was found at this location. Maybe try search?', 'pho' ); ?></p>

    And in pho.pot there is a line:

    It looks like nothing was found at this location. Maybe try search?

    which I can translate into whatever language I need to. For example if I want to translate it into Slovene I create sl_SI.po and sl_Si.mo files. So far so good. It all works fine. I am able to translate a theme!

    But what about if I want to add my own string into the code. For example at some point in my code I need to write Published by and make it translatable.

    I thought that if I simply write

    <p><?php _e( 'Published by:', 'pho' ); ?></p>

    that then Published by will appear in pho-pot from where I will be to translate it. But it does not.

    So how do I get my custom sentences in .pot file? Is there some special trick? I thought that WordPress automatically scans all the code, detects _e() function and places strings in .pot file. But in my case it does not.

    So what should I do?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter m4j4

    (@m4j4)

    I’ve made it.
    Every time you insert a new custom string you need to:

    • Refresh .pot (in my case pho.pot) file by hitting Poedit/Catalogue/Update from sources. By doing this you grab new strings from the code and place them in the .pot file.
    • Plus you need to refresh every single language file (in may case sl_SI.po) by hitting Poedit/Catalogue/Update form POT file (and choosing a corresponding .pot file – in my case pho.pot).By this you grab the new string from .pot file and you can translate it.

    Hi, I’ve got exactely the same problem. I succeed to get my custom strings in the .pot and the .po file, but my german translations are not shown up. P.E.
    In my childtheme’s functions.php I’ve got this code:

    add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
    function woo_rename_tabs( $tabs ) {
    $tabs['description']['title'] = __( 'CARE', 'woocommerce' ); // Rename the description tab
    return $tabs;
    }

    The word CARE is after a refresh listed in my .pot and .po and I can translate it:

    #: ../royalchildtheme/functions.php:255 functions.php:255
    msgid "CARE"
    msgstr "PFLEGE"

    But the backend just shows CARE instead of PFLEGE.
    Any ideas what I’m doing wrong? Any help would be really appreciated, many thanks in advance!

    Thread Starter m4j4

    (@m4j4)

    Hi, hopefully I will be able to help you.

    First: What do you mean by P.E. in your sentence “but my german translations are not shown up. P.E.” ?

    Second: I’ve translated my custom strings entirely with Poedit, while I have a feeling you are translating it with woocommerce_product_tabs – the method I don’t know about.

    Let me know …

    Hi, many thanks fot your sooon reply!
    First: I mean that I try to translate the english custom strings into german, but my backend shows only the english ones.

    Second: I am using Poedit too. The woocommerce_product_tabs code is just a filter to rename a product tab and there I created the custom string __( ‘CARE’, ‘woocommerce’ ) which I am tring to translate into german.
    Do you know what I mean or what my problem is?

    got it, I had to write my themes name instead of woocommerce for my custom string ??

    Thread Starter m4j4

    (@m4j4)

    I’m doing my best to understand.

    So P.E. is Poedit? I could have known :))

    What do you mean when you say “backend”? I really don’t know …

    Thread Starter m4j4

    (@m4j4)

    You say: “got it, I had to write my themes name instead of woocommerce for my custom string :)”

    I say: “I see. The second parameter, right?”

    Good to have solved it out!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to make custom strings translatable with Poedit?’ is closed to new replies.