• Resolved Insomnia88

    (@insomnia88)


    Hi, I just installed this plugin and thought “awesome! exactly what I need”. But unfortunately it doesn’t seem to do what it’s supposed to -> translate.

    I created a template file with a test text, saved it, translated it, saved again (.po/.mo files were created by the plugin) and used
    _e('this is a test message');
    to output my translated test message in a template file.

    Guess what’s showing up? “This is a test message”.

    I googled and re-read your FAQ several times, asked in wordpress IRC chat, no help in sight. While I did this I added different stuff..
    My functions.php contains now
    load_theme_textdomain( 'bla', get_template_directory() . '/languages' )

    and in my template file..

    echo get_locale()
    _e('this is a test message', 'bla');

    get_locale() returns “de_DE” (the language I used for the translation and that is in po/mo file). I called my textdomain ‘bla’

    I tried to rename the files to ‘bla-de_DE’ AND placed them in the global language directory.

    That all didn’t help. Any clues what’s going wrong here?

    https://www.ads-software.com/plugins/loco-translate/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Tim W

    (@timwhitlock)

    it doesn’t seem to do what it’s supposed to -> translate.

    You say PO/MO files were generated, so the plugin has done one of its primary jobs.

    Loading the translations into WordPress is not one of its jobs. However, its second job is to try and “guess” where these files should live so WordPress can find them. This is the most common place for error.

    Is your theme also called “bla”? If not then Loco will need some help. Did you declare these in your theme’s header tags?:

    /*
     Text Domain: bla
     Domain Path: /languages
     */

    That’s just for saving the files automatically. But you say you have manually moved/renamed the files and it’s still not working. That means either (1) the MO file is empty or (2) your files are still in the wrong place.

    (1) If you have a MO file at wp-content/languages/themes/bla-de_DE.mo then WordPress should load this. It will do so without Loco being involved at all. What do you get if you debug WordPress’s load_theme_textdomain function? Try this filter to dump out all the files WordPress is trying.

    (2)
    Can you confirm whether the PO file contains the msgid and msgstr pair for your test message with your German text present? Just open it in a text editor. If it’s in there, then we need to check the MO file is valid. Do you have command line Gettext tools installed?

    Post back here which of these two problems seems to be relevant.

    Thread Starter Insomnia88

    (@insomnia88)

    Hm, I solved it. I renamed the po/mo files back (deleted the “bla-” string out of it) and suddenly its working. Before it hasn’t oO I don’t really know why because all changes I did were before I renamed it (and I am always clearing my cache etc.) but okay.

    Still thanks for your aid.

    Plugin Author Tim W

    (@timwhitlock)

    Inside theme directories MO files don’t include the text domain, only in the global languages directory. Loco Translate will save them this way, but still needs to know where to put them. (hence it’s best to always add those two header tags as they cover both situations)

    I’ve closed this ticket as you say you’ve solved it.

    Thread Starter Insomnia88

    (@insomnia88)

    Damn can you re-open it? I think I find the mistake now. There is something strange. I get the message that the source code was edited and I need to synch it. When I do that I get some translations (from wordpress or plugins) into my *pot. When I delete them and put my own in again, save it and do the translation, it works. But only like 2-3 times. After that I get the same warning again.

    Know what? When I get the warning the problem I described above appears. He is not loading the translation, only the source of it-.-

    Plugin Author Tim W

    (@timwhitlock)

    It’s only warning you that your code was edited more recently than your POT file was. It’s not checking if any strings have changed, that would take too much CPU all the time. So if you know you’ve not changed any source strings, don’t sync.

    Thread Starter Insomnia88

    (@insomnia88)

    But that doesn’t solve my problem because when I don’t sync my translations are all gone. THAT is the strange part about it.. when the warning appears -> translations are ignored. No matter if I save it or leave it.

    Plugin Author Tim W

    (@timwhitlock)

    I’m not following your workflow at all.

    When I do that I get some translations (from wordpress or plugins) into my *pot.

    OK. Loco is rebuilding your POT from your source code…

    When I delete them and put my own in again, save it and do the translation, it works.

    Why are you deleting them? What is wrong with the POT file that is generated?

    But only like 2-3 times. After that I get the same warning again.

    Like I say, the warning will appear as soon as the date of the POT file is behind any source code files.

    When I get the warning the problem I described above appears. He is not loading the translation, only the source of it-.-

    If you’ve changed the strings in your POT file, then all your PO and MO files will also be out of date. They don’t all sync in the background.

    Plugin Author Tim W

    (@timwhitlock)

    * Also the warning will appear when PO files are older than the POT file. That means you need to sync up your translations.

    Thread Starter Insomnia88

    (@insomnia88)

    Ok it seems that I had a caching problem here..
    The problem itself is solved but still. He is not just giving me the warning when I edit the *pot. I recieved the warning in the mp/po editor after synching and (after that) no further editing of the *pot.
    The texts he shows me are all from twentyfifteen. For me it looks like he compares twentyfifteen with my bla.pot and sees that there are different.. then he’s pushing the warning. And that’s the weird behavoir. Sure, I can ignore the warning in the *pot area but I would rather get rid of it.

    I renamed the twentyfifteen mo/po files in the global language directory and hope that this problem won’t occur anymore.. I am not going to set the ticket to “resolved” atm because I want to see if it’s still working when I am finished with the translation, so treat it as “half resolved” ??

    Plugin Author Tim W

    (@timwhitlock)

    For me it looks like he compares twentyfifteen with my bla.pot and sees that there are different.

    Is this a child theme? If so, are you using the same text domain for your custom strings?

    Thread Starter Insomnia88

    (@insomnia88)

    Nope, it’s an own theme but based on twentyfifteen.

    Ok it seems it was all my fault. Sorry. I missinterpreted the use of ‘context’. I thought it’s like a comment – saying where to use the translation. So I put words there describing the context of the text.

    It felt random because sometimes I had a context and sometimes not. I could really bump my face against the next wall now.

    Thanks anway, I think it’s really resolved now ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘only source text, not translated showing up’ is closed to new replies.