• Resolved notthatugly

    (@notthatugly)


    There’s an old theme I wrote right at the start of the 1.5 era when I was still hung up on doing things properly and did not yet know that nobody else cared about plugin hooks or localization ?? Well, to my astonishment somebody is now actually attempting a translation. So, since there are __ and _es in all the right places I successfully extracted a .po file for her to work with. So far, so simple.

    Trouble is, now we have no idea how to get the theme to use the translated strings. As usual, the Codex is no help. I found this tutorial, but it says I’d need to go through all my strings adding a textdomain to them. Is this really necessary? In the absence of any docs I used Classic as a model, and that just uses __ and _e with no other parameters.

    Sigh. Stuff like this reminds me why I gave up theming in the first place.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter notthatugly

    (@notthatugly)

    Is 22 hours an acceptable time to leave before bumping? Regardless. Bump.

    Hi.

    You have two ways to do it:

    1. using a new textdomain as the ZyBlog tutorial says (this allow you to use your own theme’s POT with personalized strings);
    2. using exactly the same strings that WP Classic Theme uses because those strings ARE on the WordPress default textdomain POT. (ex: you MUST use <?php _e("Filed under:"); ?> before your post categories listing.)

    In addition to the last option, you can “tweak” the thing (if you will NOT use the blog theme in english) changing the strings in english for the string that you really need in the translation. (ex: you won’t use the string “Filed under:” but you need one that says -after translation- “Mis fotos” -My Photos, in english- so you won’t use <?php _e("Filed under:"); ?> before a list of post categories but between <h3> as the title of your Flickr photos plugin.)

    I don’t recommend the tweaks while they are not essential.

    If you plan to release your i18n Theme I don’t recommend neither the second option (no so bad at all) or its tweaks (no, don’t do it… evil, evil evil). The correct one is only the first option.

    Greetings!

    n!

    BTW, you can hardcode the strings in the theme as the WP Default Theme does, or copy & paste all your theme .po (translated) after the original WP .po and compile the default textdomain .mo including your strings.

    Good luck!

    Thread Starter notthatugly

    (@notthatugly)

    Thank you! If only somebody had bothered to document this in the Codex back when i18n support was first introduced, it would have saved me a lot of time and confusion.

    Where can I get a Version (possible german) of alex kings textdomain he try to use in “Share-This”?

    if (function_exists(‘load_plugin_textdomain’)) {
    load_plugin_textdomain(‘alexking.org’);
    }

    Thanks, Alex

    You cannot get a “textdomain”…
    That’s the code to call the plugin’s translation – if exist.
    see more: https://boren.nu/archives/2004/11/01/localizing-plugins-and-themes/

    So I have to generate a “.mo” by myselfe?

    Basically, yes. A POT > a .po > a .mo file.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Theme localization’ is closed to new replies.