Support » Plugin: WP Cloudy » Translate week day names reopened

  • Resolved Bernat

    (@theredflea)


    Hello, I open new post because older is closed:

    Hello, I need to translate the days name (Monday… and shortcuts names: Fri, Sat, Sun, Mon, Tue…
    I can’t find where to translate, please can you say me exactly what file to edit?

    I edit the locale.php file to change to:
    // Abbreviations for each day.
    $this->weekday_abbrev[__(‘Sunday’)] = /* translators: three-letter abbreviation of the weekday */ __(‘Dg’);
    $this->weekday_abbrev[__(‘Monday’)] = /* translators: three-letter abbreviation of the weekday */ __(‘Dl’);
    $this->weekday_abbrev[__(‘Tuesday’)] = /* translators: three-letter abbreviation of the weekday */ __(‘Dm’);
    $this->weekday_abbrev[__(‘Wednesday’)] = /* translators: three-letter abbreviation of the weekday */ __(‘Dc’);
    $this->weekday_abbrev[__(‘Thursday’)] = /* translators: three-letter abbreviation of the weekday */ __(‘Dj’);
    $this->weekday_abbrev[__(‘Friday’)] = /* translators: three-letter abbreviation of the weekday */ __(‘Dv’);
    $this->weekday_abbrev[__(‘Saturday’)] = /* translators: three-letter abbreviation of the weekday */ __(‘Ds’);

    but don’t works…

    https://wordpress.org/plugins/wp-cloudy/

Viewing 15 replies - 1 through 15 (of 15 total)
  • Hi Bernat,
    I have exactly the same problem and here is a workaround :

    Day of week are display with strftime() php function.
    By default strftime return english day of week.

    with setlocale() php function, you can translate these days but you need to have the language on the server.

    If you have linux server try local -a on console, here is my output :

    en_GB.utf8
    en_HK.utf8
    en_IE.utf8
    en_IN
    en_IN.utf8
    fr_CA.utf8
    fr_CH.utf8
    fr_FR.utf8
    fr_LU.utf8

    Here is several part of code of wpcloudy.php

    line 2106 to 2222 :

    switch ($wpcloudy_lang) {
    case “fr”:
    $wpcloudy_lang_owm = ‘fr’;
    $wpcloudy_lang_host = ‘fr_FR’;
    $wpcloudy_lang_encoding = ‘ISO-8859-1’;
    break;

    line 2302 :

    setlocale(LC_TIME, “$wpcloudy_lang_host”);

    line 2371 to 2378 :

    while ($i<=13) {
    $forecast_day_feed= strftime(“$wpcloudy_display_length_days_names_php”, strtotime($myweather_sevendays->forecast[0]->time[$i][‘day’]));
    $forecast_day_[$i]= iconv(“$wpcloudy_lang_encoding”, ‘UTF-8’, $forecast_day_feed);
    $forecast_number_[$i]= $myweather_sevendays->forecast[0]->time[$i]->symbol[0][‘number’];
    $forecast_temp_min_[$i]= (round($myweather_sevendays->forecast[0]->time[$i]->temperature[0][‘min’]));
    $forecast_temp_max_[$i]= (round($myweather_sevendays->forecast[0]->time[$i]->temperature[0][‘max’]));
    $i++;
    }

    I would like to use french so if we “simulate” :

    ‘fr’, so $wpcloudy_lang_host = fr_FR and setlocale(LC_TIME, “fr_FR”);

    But i don’t have this language on the server i have only fr_FR.utf8 so it will not work.

    So to conclude, if you want the translation works, you need to install the language you need or like i did, you need to change this line (if you are in the same case like me but maybe you can modify it to match on your case):

    setlocale(LC_TIME, “$wpcloudy_lang_host”); to setlocale(LC_TIME, “$wpcloudy_lang_host.utf8”);

    But be carefull, some other translation like “Now”,”Wind”,”Pressure”,.. are in the language file editable with POEdit in /wp-cloudy/lang/ .

    I hope it can help you.

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    Hi,

    sorry for the slow response time.

    Like Inglebard said it, you need to setup locale on your webhost.
    I don’t have much time right now, to write a guide about that, but your webhost should know how to do that if you contact them.

    Thank you 😉

    Hello,

    Sorry for hijacking the thread but this is related. I’m setting up WP Cloudy on a multilingual site using WPML. I’ve managed to do it for all 5 languages I need by creating a weather forecast page, translated to each language, and one “Weather” post for each language, so that I get five different shortcodes.

    Things are working fine and our translators can translate the PO file using WPML’s string management. However, the names of the days of the week are posing an issue. They’re all in English currently, and if I understand correctly we need to set the locale at the server level? This wouldn’t work with WPML… Is there any other way? Am I missing something obvious? 🙂

    Thanks in advance,
    Marcus

    Hi,

    I don’t know how work WPML, but here is another workaround.

    First of all check the value of $wpcloudy_lang_host in wp-cloudy.php (line change with the last update.)

    With the output you need to verify if the value change for each language.
    If it’s the case, you need to install the missing language on the server. (check my post above (n° of lines are incorrect since the last update))

    If not, it will be more complex. I think you need to change the locale at runtime. Personnaly, I use this to translate backend to my native language but keep the frontend in other language.
    For that you need to create a plugin like this : http://wordpress.stackexchange.com/questions/49451/change-locale-at-runtime

    For my case i use that :

    function wpsx_redefine_locale($locale) {

    if(is_admin())
    {
    $locale = ‘fr_FR’;
    }

    return $locale;
    }
    add_filter(‘locale’,’wpsx_redefine_locale’,10);

    But it not correspond to your case, you need to arrange it to your case.

    In WPML API (http://wpml.org/documentation/support/wpml-coding-api/), you have ICL_LANGUAGE_CODE, to get current WMPL language.

    If you use the plugin maybe with a “switch” you may be able to obtain the expected result.

    Use this solution only if its your last hope 🙂 , because I think it’s not the easiest and the fastest solution and it may fail.

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    Hi there!

    If you have access to ssh, try this (works with Ubuntu server):

    sudo locale-gen en_US en_US.UTF-8 dpkg-reconfigure locales reboot

    You have to change en_US en_US.UTF8 to your own language code.

    More info here:

    https://www.digitalocean.com/community/questions/fixing-the-locale-issue-in-a-clean-digitalocean-droplet

    I have other question – how to translate wind directions ;>

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    Currently, you can’t translate wind directions.
    It’s in the to-do-list 😉

    Hello rainbowgeek!

    Thanks for your reply. We tried installing the locales on our server but it didn’t work; week day names are still being displayed in English on all WPML languages.

    We installed the following locales, but there seems to be no direct effect on weekday names:
    C
    C.UTF-8
    de_DE.utf8
    en_US
    en_US.iso88591
    en_US.utf8
    fi_FI.utf8
    POSIX
    ru_RU.utf8
    sv_FI.utf8
    sv_SE.utf8

    Any ideas?

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    Here is the how to (example with english and french day names):

    1. Create your weather in English
    2. In Multilingual Content Setup metabox, check Make ‘Weather’ translatable.
    3. Check all boxes “translate” and click Apply.
    4. In language metabox, add french translation.
    5. Change Display language option to French (instead of english).
    6. Save weather
    7. Copy and paste the weather shortcode in an english page.
    8. Repeat step 7 with the french weather shortcode in a french page.
    9. You’re done!

    Eg in EN: https://www.wpcloudy.com/test/
    Eg in FR: https://www.wpcloudy.com/fr/test/

    Remember, only English and French are completely translated.
    You have to setup WPML first.
    How to add your language here: https://www.wpcloudy.com/support/guides/translate-wp-cloudy-language/

    Hello,

    Yes, we have set that all up already, and it’s working fine with the different languages – except for the names of the days of the week, as mentioned. We have installed the locales on the server but, like I said, it still isn’t picking them up. Any ideas? 🙁

    Marcus

    Hello again!

    Do you have any ideas on how to solve this?

    Thanks

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    Hi,
    I’m still looking for a more “universal” way that everyone can use without make changes on their web server.

    I’ve installed this plugins, skin by default completly bug with my premium theme… i buy skins… for nothing more !

    And i looking for translate the day (because i can change server langage) and nothing !!! I don’t want recode this plugins (after purchase 10$ for nothing) but one month after, always nothing concerning this translate… why use po file if days is not include (as all plugins finding on web ?)

    seriously… limit a mad joke…

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    We are still looking into that.
    If you have bugs with Skins, please open your own topic.
    Thanks.

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    @all: update to WP Cloudy v3, you can now translate day names with PO/MO files!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Translate week day names reopened’ is closed to new replies.