WordPress.org

Ready to get started?Download WordPress

Forums

Weather Forecast - WP Wunderground
Weather Forecast - Wunderground (16 posts)

  1. ibbranco18
    Member
    Posted 3 years ago #

    This plugin is great, many options for displaing the weather, but is only easily available for English. It would be nice to be able to do as per WP Forecast ... hange language in a menu :)

    Well, in order to change the language you have to do some coding ... So, I would like to translate to portuguese and could not do it. Can anyone help me describing the steps ? Or how to do it. I would be very grateful !

  2. spaniole
    Member
    Posted 3 years ago #

    Anything new about translating to another language than English? It could be the top of the plugin to have that opportunity, it is the only thing that is missing, because it is a very good pluging, just missing the opportunity to change to another language. Some advice could be nice. Thanks in advance.

    Best regards
    Spaniole Olsen

  3. lozanno
    Member
    Posted 3 years ago #

    To translate, add to your functions theme file:

    function replace_weather($content) {
        $content = str_replace('Rain', 'Lluvioso', $content);
        $content = str_replace('Storm', 'Tormenta', $content);
        $content = str_replace('Sunny', 'Soleado', $content);
        $content = str_replace('Monday', 'Lunes', $content);
        $content = str_replace('Tuesday', 'Martes', $content);
        return $content;
    }
    add_filter('wp_wunderground_forecast', 'replace_weather');

    As you can notice, I'm using spanish for day names label and the "forecast condition".
    Check the complete wunderground forecast condition labels here and translate to your own language:

    Good luck translating...

  4. spaniole
    Member
    Posted 3 years ago #

    Hello lozanno

    It was indeed what I needed, thank you very much, works as you described. By the way I did a danish translation.

    Best regards
    Spaniole Olsen

  5. Zack Katz
    Member
    Plugin Author

    Posted 3 years ago #

    Hi ibbranco18 and spaniole,
    I've been working on a major upgrade to the plugin, and am planning on language support. Could you both email me your translations to info@katzwebservices.com ?

    Thank you, and thanks lozanno for your helpful response.

  6. nkkhoo
    Member
    Posted 3 years ago #

    Can someone teach me how to add shortcode in the template file?

    This below php code does not work.

    <?php wp_wunderground_forecast(); ?>

    Rgds
    nkkhoo

  7. Zack Katz
    Member
    Plugin Author

    Posted 3 years ago #

    You can use echo do_shortcode('[forecast location="Example"]'); in your template.

  8. psoderlund
    Member
    Posted 3 years ago #

    Hi all,
    I have also translated the names labels but it is showing a strange problem. I have edited my functions.php to look like this (Danish):
    But the Partly Cloudy is beeing tanslated to Partly Overskyet ?
    I dont get it why it doesnt translate the entire sentence.
    See site here: http://www.buresoebanden.dk/
    Any ideas ??

    function replace_weather($content) {
    $content = str_replace('Chance of Flurries', 'Mulighed for Sne', $content);
    $content = str_replace('Chance of Rain', 'Mulighed for Regn', $content);
    $content = str_replace('Chance of Freezing Rain', 'Mulighed for Isslag', $content);
    $content = str_replace('Chance of Sleet', 'Mulighed for Slud', $content);
    $content = str_replace('Chance of Snow', 'Mulighed for Sne', $content);
    $content = str_replace('Chance of Thunderstorms', 'Mulighed for Torden', $content);
    $content = str_replace('Chance of a Thunderstorm', 'Mulighed for Torden', $content);
    $content = str_replace('Clear', 'Klart vejer', $content);
    $content = str_replace('Cloudy', 'Overskyet', $content);
    $content = str_replace('Flurries', 'Sne', $content);
    $content = str_replace('Fog', 'Tåge', $content);
    $content = str_replace('Haze', 'Tåge', $content);
    $content = str_replace('Mostly Cloudy', 'Mest Skyet', $content);
    $content = str_replace('Mostly Sunny', 'Mest Sol', $content);
    $content = str_replace('Partly Cloudy', 'Delvis Skyet', $content);
    $content = str_replace('Partly Sunny', 'Delvis Sol', $content);
    $content = str_replace('Freezing Rain', 'Isslag', $content);
    $content = str_replace('Rain', 'Regn', $content);
    $content = str_replace('Sleet', 'Slud', $content);
    $content = str_replace('Sunny', 'Sol', $content);
    $content = str_replace('Thunderstorms', 'Torden', $content);
    $content = str_replace('Thunderstorm', 'Torden', $content);
    $content = str_replace('Unknown', 'Ukendt', $content);
    $content = str_replace('Overcast', 'Overskyet', $content);
    $content = str_replace('Scattered Clouds', 'Lidt Skyet', $content);
    $content = str_replace('Monday', 'Mandag', $content);
    $content = str_replace('Tuesday', 'Tirsdag', $content);
    $content = str_replace('Wednesday', 'Onsdag', $content);
    $content = str_replace('Thursday', 'Torsdag', $content);
    $content = str_replace('Friday', 'Fredag', $content);
    $content = str_replace('Saturday', 'Lordag', $content);
    $content = str_replace('Sunday', 'Sondag', $content);
    return $content;
    }
    add_filter('wp_wunderground_forecast', 'replace_weather');

  9. Zack Katz
    Member
    Plugin Author

    Posted 3 years ago #

    @psoderlund - You'll want to have the two-word forecasts before the single word forecasts. Move the "Partly Cloudy" line above the "Cloudy" line, for example. "Cloudy" is being replaced with "Overskyet" before "Partly Cloudy" is being processed.

  10. psoderlund
    Member
    Posted 3 years ago #

    Thanks Zack for the quick reply. I made the changes now I just have to whait for the weather to turn something else besides Sunny!!! But I think your fix will do it as some of the other phrases worked fine and they were in the "correct order".
    So thanks.

  11. spaniole
    Member
    Posted 3 years ago #

    Hello psoderlund

    You could easily get the danish characters æ ø å to behave the right way on the hole www with some HTML symbols (I think!), some examples will follow (I have to do spaces between the letters, or else they will become the letters æ and ø and you can't see the right symbols to use, so please remove the spaces before use):

    $content = str_replace('Fog', 'T& a r i n g ;ge', $content);
    $content = str_replace('Haze', 'T& a r i n g ;get', $content);

    $content = str_replace('Saturday', 'L& # 2 4 8 ;rdag', $content);
    $content = str_replace('Sunday', 'S& # 2 4 8 ;ndag', $content);

  12. psoderlund
    Member
    Posted 3 years ago #

    Hi Spaniole,
    I will give your suggestion a try!!
    Very nice if I could get the characters showing. I will post later when I have tested it.

    Thanks guys for helping me out, such a good support community here on WordPress...

    Have a good day.

    Peter :)

  13. fabpicca
    Member
    Posted 2 years ago #

    Italian translation here.

  14. psoderlund
    Member
    Posted 2 years ago #

    Heres the Danish one for all of you...in correct form.

    [Code moderated as per the Forum Rules. Please use the pastebin]

  15. svidakovic
    Member
    Posted 2 years ago #

    Hy

    what if I need translation for 4 languages? In my case it is en, de, it and hr?

    Any advice

    Sasa

  16. svidakovic
    Member
    Posted 2 years ago #

    solved :)

    if(qtrans_getLanguage() == 'it'){
    if (!function_exists('replace_weather')) :
    function replace_weather($content) {
    $content = str_replace('Chance of Flurries', 'possibile tempesta di neve', $content);
    ...
    ...
    }
    add_filter('wp_wunderground_forecast', 'replace_weather');
    endif;
    }
    if(qtrans_getLanguage() == 'de'){
    if (!function_exists('replace_weather')) :
    function replace_weather($content) {
    $content = str_replace('Chance of Flurries', 'Mögliche Schneeschauer', $content);
    ...
    ...
    }
    add_filter('wp_wunderground_forecast', 'replace_weather');
    endif;
    }

    and so on :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic