Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #6527

    Federico H
    Participant

    Hi.

    Just purchased the X theme today and am very impressed with its capabilities and how well it functions. However, I am having an issue that I’m hoping you can help me with.

    My website (http://puromac.com) is a Spanish-language blog for a podcast. We have the language set as es_ES and it works correctly in the admin screen as well as previous themes we’ve used.

    I noticed that, even without creating my own es_ES.po file for the X theme, many terms were translated. The translated terms appear to come from the WP core translation file.

    Because I expected to make many changes, I created a child theme, and mirrored the path /framework/lang in the child theme directory. Then I copied the default.po file from the main theme directory into the child mirrored path, changed the name to es_ES.po and set about to translate the strings. What I wanted to do specifically is translate the string “Home”, in order to change how it appears in the breadcrumbs.

    However, creating the language file doesn’t change any of the strings that I want to affect. Any thoughts on what I might be doing wrong?

    Incidentally, there is at least one string that isn’t wrapped with a _e() or __() call, and so it will never get translated. The first one I can ran across is the string “Read more” which appears under blog excerpts. To translate it, I had to overwrite two functions from miscellaneous.php (x_excerpt_string and x_content_string).

    Thanks.

    #6553

    Kory
    Keymaster

    Hey Federico,

    Thanks for writing in and for your kind words! We always appreciate hearing that around here.

    Regarding the Read More strings for the excerpt and content, we have corrected this and it will be available as a native fix in the coming update. Thank you for bringing this to our attention. It’s easy for little strings like that to fly under the radar sometime, so we’re always grateful to have a little assistance in pointing out areas that we have overlooked.

    As for the language file issue, I’m going to have another member of our staff look into this for you as soon as he is available as he is much more experienced at translation situations like this. I will make sure that he is aware of this thread and he will respond to you as soon as possible.

    Thanks!

    #6631

    Federico H
    Participant

    Thanks. Glad to hear you’ve caught the Read More bug.

    I forgot to mention that I also duplicated the default.po and default.mo files into the child theme lang directory. Not sure if that was needed, but thought it might help when I wasn’t seeing my translation come through.

    I’ll wait to hear back on the language issue.

    #6705

    Rubin
    Keymaster

    Hey Federico,

    what plugin are you using for translation your site? WPML? You normally should not need the default.po file after you’ve created a translation of that template file to your own native language. So you only use it as a blueprint to translate all the values into your language and then you use a plugin like WPML to utilize it. What surprises me is that you’ve said that it got translated automatic because normally you have to translate all the strings on your own. Let me know what you’ve did exactly so I can recreate your steps and look into it. Thanks!

    #6740

    Federico H
    Participant

    Hi.

    Thanks for getting back to me.

    Regarding the automatic translation, what I mean is that a few places look like they are using WP’s translation file. For example, the dates which appear at the top of posts are in Spanish, as is the text in the comments area which normally reads “Leave a comment” (on my site it reads ‘Deja un comentario’). However, most strings are not being translated, such as the word “Home” in the breadcrumbs and “Search” in the search widget.

    I’m not using a plugin at all. Perhaps that’s my problem. 🙂

    I thought that, as with my previous themes, I could just place corresponding po and mo files in the theme’s language directory, name them correctly, and provide my translation by updating the message string (ex: msgid “Search” msgstr “Buscar”). Do child themes work differently and require a language plugin?

    In the meantime, I’ll remove the default files from my child theme directory.

    #6743

    Rubin
    Keymaster

    Hey Federico,

    since we are not providing a spanish translation out of the box you have to use the default.po and translate it yourself into spanish and then use it. The best thing to start is getting poEdit or a similar program that can open .po files. Then you open our default.po file and start translating it into your own language. Once you’ve done that you save it as es_ES.po in the same folder /framework/lang/.

    Once you’ve done that you open your wp-config.php file in your WordPress root folder and look for:

    define('WPLANG', '');>

    and replace it with:

    define('WPLANG', 'es_ES');

    Now your theme should be fully translated.

    #6751

    Federico H
    Participant

    Hi.

    Thank you for your help. With your message as a guide, I figured out what was wrong with my set up. To help other developers with the same issue, I’ll summarize what I did.

    1. We already had WPLANG set to es_ES, which is why the admin interface and other parts of the site appeared in Spanish, so that wasn’t part of the problem.
    2. I duplicated default.po and renamed the file es_ES.po.
    3. Then I used poEdit to edit the file. I had tried this before, but the latest version of poEdit (1.6) was unusable on my Mac because it crashed when I tried to open any file. So, I got version 1.5.7 and that worked without crashing.
      • By the way, .po files are just text files so you could use a regular text editor to translate them. However, .mo files seem to have special characters in them and are built differently. poEdit properly creates a matching .mo file. I read an incorrect blog post that said I could just duplicate the .po file and rename it with a “.mo” extesion. I’m sure this was the reason my translation wasn’t working.
    4. I placed the new es_ES.po and es_ES.mo files in the parent’s /framework/lang directory. When my translation wasn’t working, I mistakenly thought that I needed to mirror the lang directory under the child theme.
    #6756

    Rubin
    Keymaster

    Hey Federico,

    thanks for that explanation and great that everything seems to work now! If you need anything else let me know!

    #15179

    Thomas S
    Participant

    For those who like to have the localized .po file in their child-theme directory:

    1. create your localized .po and .mo files and save them in: child-theme-dir/lang/de_DE.po
    2. edit the child-theme´s function.php file and add the following lines at the beginning:

    add_action( 'after_setup_theme', 'my_child_theme_setup' );
    function my_child_theme_setup() {
        load_child_theme_textdomain( '__x__', get_stylesheet_directory() . '/lang' );
    }

    That´s the recommend way by the wordpress codex.

    Hope that helps.
    Thomas

    #15193

    Christian
    Moderator

    Thank you for the tip Thomas. 🙂

    #22127

    Kiljan
    Participant

    Its not working for me.
    I only wish to translate certain word on my site.
    I have made an edited copy of the default.po and .mo
    I have placed them in directory (im using renew) x_child-renew/lang/

    and change the functions.php file according to “Thomas S” earlier post.
    Im I supposed to change the code that Thomas wrote? for example replace “my_child_theme” with “x-child-renew”

    Also, im a complete newbie at php, should I place the code in the beginning, before or after the tag?

    this is my site

    I have changed all places in the default.po where it would say “read more” to swedish translation. But its now working

    #22269

    Thomas S
    Participant

    Hi Kilijan,

    did you rename your .po files according to the language? In my case I made a copy of the default.po file, renamed it “de_DE.po”, saved in the “/lang” folder of the child theme directory and edited the functions.php. If you´ve done exactly the same then you don´t have to modify the php code of the function posted above. Simply copy&paste.

    Also, take a look at your config.php in the root directory of the wordpress installation. Search for “WPLANG”. Is this variable set correctly? In my case it looks like this:
    define('WPLANG', 'de_DE');
    This line changes your wordpress blog to the desired language (if there is a suitable language file).

    Hope this helps.
    Thomas

    #22436

    Kiljan
    Participant

    This is confusing 🙂

    This is what Ive done so far:

    Ive taken the default.po and default.mo
    made a copy, that I have edited. Ive edited a selections of words like “comments” “home” etc. i have not edited anything that was under /admin which I like to keep in english.
    I´ve named the edited copies sv_SE.po and sv_SE.mo and placed them in the new directory:

    “x_child.renew/lang”

    I have now changed the config.php to

    define(‘WPLANG’, ‘sv_SE’);

    and I have tried with and without editing the function.php

    I have also checked that there is no old sv_SE.po and .mo files in the wordpress installation.

    Here is a LINK
    to a blogpost. If everything was correct the in the breadcrumps it should now say “hem” and not “home”
    it should also say “kommentarer” and not “comments”

    A huge thank you for taking your time to help out.

    #22612

    Thomas S
    Participant

    How did you edit the .po file? Did you use Poedit(http://www.poedit.net)? Or have you opened the po file in a text editor and replaced some words?

    I highly recommend using Poedit, which gives you a clean .po and .mo file! It might not work if you accidentally messed up the po file by manually editing it.
    Thomas

    #22613

    Christian
    Moderator

    Hey Kiljan,

    You can change “Home” in breadcrumbs.php in framework\functions\global and “Comments” in integrity.php in framework\functions.

    If you using a child theme, replicate those paths in the child theme folder then copy and paste the php files in there respective directories and modify them there.

    Hope that helps. 🙂