This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Localization and child theme

  • Creator
    Topic
  • #6840
    mike-se
    Participant

    As it is now the localization jumpstart.po file is in Jump Start/lang. When I create a translation the translated file only work if it is in that same folder, but not if I place it in Childtheme/lang folder. The translation file is then erased as soon as Jump Start gets an update, and needs to be uploaded again via ftp.

    This is a bit of a hassle. Could you please make it so the localization files work from within the child theme structure.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Author
    Replies
  • #6842
    Ervan Erfian
    Participant

    Hi Mike,
    You can search “Load theme text domains” and change “get_template_directory” to “get_stylesheet_directory” for your language http://pastie.org/7121359 at jumpstart/framework/api/helpers.php

    #6843
    mike-se
    Participant

    Hi Ervan, and thanks. Thats all good but unfortunately it still doesn’t solve the issue with Jump Start updates.

    #6846
    karlo
    Participant

    Try also look in themeblvd.php, find

    // Apply initial hooks
    	add_action( 'themeblvd_localize', 'themeblvd_load_theme_textdomain' );

    I have not tested but should mean you can remove_action your way to secure updating of lingo files. With Ervans code as content of new action.

    remove_action( 'themeblvd_localize', 'themeblvd_load_theme_textdomain' );
    add_action ( 'themeblvd_localize', 'themeblvd_load_theme_textdomain_MYWAY' );
    function themeblvd_load_theme_textdomain_MYWAY() {
        load_theme_textdomain( 'themeblvd', get_stylesheet_directory() . '/lang' );
        load_theme_textdomain( 'themeblvd_frontend', get_stylesheet_directory() . '/lang' );
    }

    might work or can be tuned to work.

    Also !function_exists means you can just copy it directly in to functions.php and change code. But I believe the remove/add thing is more correct.

    I am not sure how lingo stuff works with Jump Start, or in general, so hopefully dev. comment.

    #6850
    Ervan Erfian
    Participant

    Yeah.. Karlo right and hooked via functions would be better for updates scenario .

    #6851
    Jason Bobich
    Keymaster

    To accomplish this, there are two things that need to happen.

    1) In you PO file, all of the paths need to reference jumpstart from this new location. When you generate a new project in poEdit, if we were going to save into a directory of the Child theme called “lang” then the filepath would be ../../jumpstart/ — We’re moving up two directories into /wp-content/themes/ and then down into /jumpstart to search for all the translatable strings.

    Here’s the result from doing this: http://themeblvd.com/temp/default.po

    2) As the others were pointing out, you need to now register the theme’s text domain from the proper place. The trick on this is to make sure that this happens (a) before the framework’s API and (b) before the framework registers its localization.

    So put the following snippet before the framework runs in your Child theme’s functions.php:

    function my_load_theme_textdomain() {
        load_theme_textdomain( 'themeblvd', get_stylesheet_directory() . '/lang' );
        load_theme_textdomain( 'themeblvd_frontend', get_stylesheet_directory() . '/lang' );
    }
    add_action ( 'themeblvd_localize', 'my_load_theme_textdomain' );

    This might look something like this in your Child theme’s functions.php.

    Note: The thing here that is sort of unique is that we’re hooking to the framework’s “themeblvd_localize” action. Often themes will hook to “after_setup_theme” as shown in examples in the codex, but this will not work (for everything) in Jump Start because how all the unique API functions work with adding theme options, sliders, builder elements, etc.

    #6873
    mike-se
    Participant

    Thanks all, that solution works nicely. Perhaps you could add this functionality into the next update. I’m pretty sure more people in the future will stumble on this, since your target for Jump Start is the whole wide world 🙂

    Thanks again though, I’m really starting to appreciate your work and great support more and more. Wish all devs were more like you.

    #6877
    Jason Bobich
    Keymaster

    Thanks, Mike!

    I wanted to note here to anyone passing through, also, if you’re just to do a simple translation of the strings on the frontend of your website, you can the Theme Blvd String Swap plugin and avoid localization all together.

    http://wordpress.org/extend/plugins/theme-blvd-string-swap/

    #6969
    karlo
    Participant

    Yeah that is nifty. Cover what matters, 9 out of 10 could not care less for what is not visible, but there is a combo hard to beat – Codestyling Localization http://wordpress.org/extend/plugins/codestyling-localization/ + lingo files in child theme. For the full translation experience 🙂

    Poedit is also ok.

    #7163
    karlo
    Participant

    Since I just wasted half an hour messing with this I will report that just dumping snippet in functions.php does not necessarily work. Must come BEFORE

    require_once( get_template_directory() . '/framework/themeblvd.php' );

    Or like in image posted by Jason. I think I moved it about, heh.

    #7166
    Jason Bobich
    Keymaster

    So, in other words, follow instructions? lol

    #7168
    karlo
    Participant

    Doing byte comparison between Jump Start 1.0.1 and 1.0.2 to find out where you messed up translation never hurt anyone. I was starting to consider the option of corrupted file too. How to check that? Poedit I guess but can give false positives I have heard. This type of activity Is only fun for so long and I will probably go with instructions next time 🙂 May be also start to organize that functions.php file, or better split it up.

    #7189
    karlo
    Participant

    Thread is going in other direction but I might as well add what I forgot. I had to download full version 1.0.2 for my scientific comparison to 1.0.1 so found something weird in 1.0.2.

    May be you should remove github repository from Jump Start 1.0.2 download. I dont think there are any secrets in there, like naked pics. If I am wrong better delete this post too as there is no reason to get people looking.

    Auto update does not add github folder as far as I can tell.

    #7191
    Jason Bobich
    Keymaster

    Oh yeah, if the github hidden directory is in there, it’s just by mistake.

    #7193
    Jason Bobich
    Keymaster

    I’ve updated this. There should be no more hidden .github directory.

    #7194
    karlo
    Participant

    Thanks.

    But jumpstart-boxed has one too. May be others, I only checked that one 🙂

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.