Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author thaikolja

    (@thaikolja)

    Since omdbapi.com only provides data from the English imdb.com, I can only output these. But you can translate most of the output yourself: Use the IMDb Connector functions inside WP’s localization functions, for example like this:

    echo __(get_imdb_connector_detail(“Apocalypse Now”, “genre”), “imdb_connector_french”);

    Translating variables doesn’t work, that’s why you have to put some dummy code containing the possible translation strings:

    $imdb_connector_french = array(
    __(“Drama”, “imdb_connector_french”),
    __(“Romance”, “imdb_connector_french”),
    );

    As I said, we won’t use $imdb_connector_french, we just have to insert the string that is supposed to be localized, otherwise PoEdit won’t find it. It’s a bit messy but unfortunately that’s the only way to do it for now.

    Let me know if you need any example codes.

    Thread Starter 7movies

    (@7movies)

    I need some help,

    $genre=get_imdb_connector_movie_detail($title, "genre" );
    $imdb_connector_french = array(
    __("Drama", "DramaFR"),
    __("Romance", "RomanceFR"),
    __("Comedy", "Comedie"),
    );
    
    $genreFR=get_imdb_connector_detail($title, $imdb_connector_french);
    
    content. = $genreFR;

    This dosen’t work for me…

    Plugin Author thaikolja

    (@thaikolja)

    Alright, let me explain it in detail.

    We use the program PoEdit to translate our strings. It’s important to understand that PoEdit only translates the strings that are hardcoded in the code, that means variables like __($detail) won’t be recognized as a string.

    We can fix that by hardcoding our strings manually. The easiest (but not the nicest) way to do this is by opening any any .php file inside the IMDb Connector directory and add the following code anywhere (this is an example for translating the genres):

    $imdb_connector_french = array(
       __("Romance", "imdb_connector"),
       __("Comedy", "imdb_connector"),
       __("Action", "imdb_connector")
    );

    Note that the parameter “imdb_connector” is not the translated string but the textdomain which is like an unique ID that tells IMDb Connector to load its translation file.

    Now, download the French .po project file from Transifex and move it into the plugin’s /languages/ directory. Rename it to “imdb_connector-fr_FR.po”.

    Install PoEdit and open the moved .po file with it. In PoEdit, hit “Refresh” in the toolbar. A window should popup with our added strings in it. Click “OK”.

    Find the strings in the list and translate them. When you’re done, press CTRL + S. This will overwrite the existing .mo translation the plugin will load on startup.

    The last thing we need to do is wrapping our output strings into either __() or _e(). Here’s one example:

    Genre de film: <?php _e(get_imdb_connector_movie_detail("Apocalypse Now", "genre"), "imdb_connector"); ?>

    It’s important to always add the “imdb_connector” textdomain to the two functions, otherwise it won’t be translated. Also, make sure that your WordPress installation must use the same language as the translation you want to output. You can change that in the “Settings” section in the admin interface.

    IMPORTANT: As I said, this is not the best solution because whenever there’s an update for IMDb Connector, your existing translations will be lost. To avoid that, always backup your imdb_connector-fr_FR.po, for example in the /wp-content/languages/ directory so you can always re-compile the translation file (.mo) and replace it with the existing one. Maybe I’ll add the detail strings later on manually to the code to make it easier for others to translate it.

    Thread Starter 7movies

    (@7movies)

    It Works… Very good

    Plugin Author thaikolja

    (@thaikolja)

    Yay ??

    By the way, if you want, you can also translate a few strings from the plugin: https://www.transifex.com/projects/p/imdb-connector/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Details in french’ is closed to new replies.