PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Language files in wp-content/languages

  1. Jan Egbert
    Member

    Would it be possible to let the Gravity Forms plugin look for language files in wp-content/lanuages/? It's really annoying to update all of the instances of the plugin by hand.

    Posted 14 years ago on Tuesday November 2, 2010 | Permalink
  2. Jan Egbert
    Member

    Does anyone have an idea? Maybe a snippet for functions.php?

    Posted 14 years ago on Wednesday November 3, 2010 | Permalink
  3. A huge +1 for this request. This might not by high on your (as in GF) priority list, but for us international guys this would be a major time saver. I maintain more than 80 sites for clients and having to manually upload the translation files every time a GF update comes along is a pain ...

    Posted 14 years ago on Tuesday November 9, 2010 | Permalink
  4. Wouldn't adding another define to gravityforms.php do the trick?

    if(!defined("GRAVITY_LANGUAGES_URL"))<br />
        define("GRAVITY_LANGUAGES_URL", "http://path-to-translationfi.le/");

    and using that url in line 50 load_plugin_textdomain( 'gravityforms', FALSE, 'GRAVITY_LANGUAGES_URL' );

    That would allow us to add a define to for instance a functions.php file ..

    Posted 14 years ago on Tuesday November 9, 2010 | Permalink
  5. Looks great Remkus. Thanks!
    I will add that into 1.5. Keep posted for the next beta in a week or two.

    Posted 14 years ago on Tuesday November 9, 2010 | Permalink
  6. w00t!

    Posted 14 years ago on Tuesday November 9, 2010 | Permalink
  7. I was in the process of adding the setting and I noticed that WordPress has a hook that allows you to change the path of the MO files, so I thought it would more "proper" to use that hook instead. Here is a code snippet to change the location to a languages folder in the root of the website

    add_filter('load_textdomain_mofile', 'change_mo_file_location', 10, 2);
    function change_mo_file_location($mofile, $domain){
    
        //remove the following two lines if you would like to set the path for all MO files
        if($domain != "gravityforms")
            return $mofile;
    
        $pathinfo = pathinfo($mofile);
        return ABSPATH . "/languages/" . $pathinfo["basename"];
    }
    Posted 14 years ago on Tuesday November 9, 2010 | Permalink
  8. I was not aware of that filter, thanks! I personally do have slight preference my version, but this works fine too, I guess.

    Thanks again Alex!

    Posted 14 years ago on Wednesday November 10, 2010 | Permalink