Translations / Text Changes

Cooked and Cooked Pro comes with a language file that needs to be translated in order for it to display a different language. The easiest way to translate it is to install a great plugin like Loco Translate and do it via the WordPress admin panel:  http://wordpress.org/plugins/loco-translate/


Full Language Translating

  1. Once you have Loco Translate installed, head over to the main Loco Translate screen by going to Loco Translate > [Plugins] or [Themes] (depending on what you're translating).
  2. Find the theme/plugin in the list and click it, then click the [+ New Language] link above the list.
  3. If you see a "Template Missing" message, simply click "Skip Template".
  4. Choose the language for this translation from the dropdown.
  5. IMPORTANT: Make sure you choose the third radio button (System) in the next section. (languages/plugins or languages/themes) before clicking Start Translating. If you do not, then your translation file will be gone if/when you update the theme or plugin.
  6. Now, on the next page, you can simply go through and add/edit your translations by clicking on each string and adding the translation in the bottom box.
  7. When you're done, simply click "Save".
  8. Be sure that WordPress is set to use the same language you've translated from Settings > General (look for the language dropdown at the bottom).

The POEdit Method

You can use software like POEdit (  http://www.poedit.net/download.php) to translate the *.po file that's included with the theme or plugin. Just remember to put your translated files into the appropriate folder listed above and remember to update your translations when there's an update.

More information on translation can be found here as well: http://codex.wordpress.org/Installing_WordPress_in_Your_Language


Simple Text Changes

Sometimes you just need to change some of the text, from English to English. In this case, you could either create a second "English" translation file following the same directions above, or better yet, just add some custom code to your theme's functions.php file or create a custom single-file plugin that does this for you. In the following example, this code will change the "Find a recipe..." text in the Cooked search bar to say "Search for a recipe..." instead:

add_filter( 'gettext', 'cooked_custom_text_changes', 20, 3 );
function cooked_custom_text_changes( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Find a recipe...' :
            $translated_text = 'Search for a recipe...';
        break;
    }
    return $translated_text;
}

As mentioned, you can open up your theme's functions.php file and add this code. Or a better method would be to create a simple single-file plugin that will allow you to add code like this without messing with the theme files (which might get overwritten when updating). The following is the code needed to create a very simple plugin, along with a download link for your convenience. To create this yourself, go to your /wp-content/plugins/ folder on your server and add a file called cooked-custom-code.php (it can be named whatever you want). Then add the following code to that file:

<?php

/*
Plugin Name: Cooked Customizations
*/

add_filter( 'gettext', 'cooked_custom_text_changes', 20, 3 );
function cooked_custom_text_changes( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Find a recipe...' :
            $translated_text = 'Search for a recipe...';
        break;
    }
    return $translated_text;
}

?>

Save the file, and then go onto your WordPress admin's plugins page. Find the plugin called "Cooked Customizations" and activate it. That's it!

Here's a quick  download link so you can just upload this plugin to your WordPress site, although you would want to make your own changes to it first. Also, to add more than one translation, you can add more case/break statements. Here's what that would look like if you wanted to change "recipes" to "books" in several:

function cooked_custom_text_changes( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Find a recipe...' :
            $translated_text = 'Find a book...';
        break;
	case 'Recipe' :
            $translated_text = 'Book';
        break;
	case 'Recipes' :
            $translated_text = 'Books';
        break;
	case 'recipe' :
            $translated_text = 'book';
        break;
	case 'recipes' :
            $translated_text = 'books';
        break;
    }
    return $translated_text;
}