WordPress.org

Support

Support » Plugins and Hacks » How to translate days and months in the calendar ?

How to translate days and months in the calendar ?

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Marcus
    Participant

    @netweblogic

    see wp-fullcalendar.php around lines 86-129

    if you can tell me what’s not being translated (And language) maybe we can look into it for future updates

    mustermann
    Member

    @mustermann

    Hallo Marcus,
    please have a look at “main.js”. There you can find all months, days of the week in long and short-code in english language.

    Ich have translated the content in file main.js with “…” in German Language. Here you will find the result:
    http://oldtimer-veranstaltung.de/kalender/veranstaltungen/kalender/

    The bug “p” and “a” for output “.” is in the file main.js for showing events in the calendar since the last version of WP plug-in wp-fullcalendar.

    Hello Marcus,
    Look here: the names of days and months are not translated (in french for me), but the words Today, Month and Week are ok.
    On the other hand I noted a small translation error in wpfullcalendar.php: week = in french semaine and not semane.

    Christian
    Member

    @yakafaucon

    Hello,

    I found some bugs for french languages or other, and I add some french translations.

    Here the code

    $wp_fullcalendar_languages = array(
    			'es' => array('buttonText' => array('today'=>'hoy','month'=>'mes','week'=>'semana','day'=>'dia')),
    			'pt' => array('buttonText' => array('today'=>'hoje','month'=>'mes','week'=>'semana','day'=>'dia')),
    			'fr' => array('buttonText' => array('today'=>'aujourd\'hui','month'=>'mois','week'=>'semaine','day'=>'jour'),
    						  'titleFormat'=> array('month'=>'MMMM yyyy','week'=>'\'Du\' d[ MMMM][ yyyy] \'au\' {d MMMM[ yyyy]}','day'=>'dddd d MMMM yyyy'),
    						  'columnFormat'=> array('month'=>'ddd','week'=>'ddd d/M','day'=>'dddd d MMMM yyyy'))
    		);
    		$calendar_languages = array_merge($calendar_languages, $wp_fullcalendar_languages);

    I add titleFormat or columnFormat for the french language.
    But there is a bug just after : you use array_merge, but if two or more array elements have the same key, the last one overrides the others. So we lost the first part of the french translation….

    I also fixed “semaine” instead of “semane”

    Just after there is another bug. It should be $js_vars instead of $jsvars.

    if( array_key_exists($locale_code, $calendar_languages) ){
    		    $js_vars['wpfc_locale'] = $calendar_languages[$locale_code];

    Christian

    Christian
    Member

    @yakafaucon

    This fixes the bug

    $wp_fullcalendar_languages = array(
    			'es' => array('buttonText' => array('today'=>'hoy','month'=>'mes','week'=>'semana','day'=>'dia')),
    			'pt' => array('buttonText' => array('today'=>'hoje','month'=>'mes','week'=>'semana','day'=>'dia')),
    			'fr' => array('buttonText' => array('today'=>'aujourd\'hui','month'=>'mois','week'=>'semaine','day'=>'jour'),
    						  'titleFormat'=> array('month'=>'MMMM yyyy','week'=>'\'Du\' d[ MMMM][ yyyy] \'au\' {d MMMM[ yyyy]}','day'=>'dddd d MMMM yyyy'),
    						  'columnFormat'=> array('month'=>'ddd','week'=>'ddd d/M','day'=>'dddd d MMMM yyyy'))
    		);
    		$calendar_languages = array_merge_recursive($calendar_languages, $wp_fullcalendar_languages);

    See it online : http://www.gf38.fr/evenements/

    Salut Christian,
    Merci de cette réponse détaillée, en french en plus. J’ai apporté les modifs que tu indiques et mon problème est résolu. Merci beaucoup !
    J’ai cliqué sur le lien qui mène au Grenoble Foot 38 : super, look vraiment très pro, bravo. Mais je ne comprends pas une chose : sur ton calendrier, je vois que les jours de la semaine sont toujours en anglais. Donc le problème est le même que celui que j’ai décrit plus haut. Ou est-ce que j’ai loupé qqch ?

    Christian
    Member

    @yakafaucon

    merci pour les compliments.

    As I was logged as admin I had no cache so I saw the right site and but it was not your case. I emptied the cache now and all is fine.

    estepix
    Participant

    @estepix

    Hello everyone,

    I have been checking the new translation capabilities for the JS part of the plugin and there’s a problem merging translations from Events Manager 5.2+ (around lines 86-123) and “extra” translations (around lines 124-130).

    The problem is that when array_merge finds a a key in $wp_fullcalendar_languages that already existed in $calendar_languages, it doesn’t merge the values, instead the keys from the latest array substitute those from the first one, i.e., for ‘es’, ‘pt’, ‘fr’ and ‘de’ the only translations we see are those corresponding to “buttonText”.

    I have changed the line:
    $calendar_languages = array_merge($calendar_languages, $wp_fullcalendar_languages);
    to
    $calendar_languages = $calendar_languages + $wp_fullcalendar_languages;

    And the content gets translated properly. @marcus if you think this fix will do, could you please add it to the following release?

    Also, this is a big step forward towards localising the plugin, so many thanks for your hard work!!!! However I miss a filter which would allow us to modify $wp_fullcalendar_languages or even extract the text to the pot file so we can translate the strings the normal way.

    estepix
    Participant

    @estepix

    sorry the fixed I proposed does not work either, actually it works the other way around, the keys from the first array are maintained, those from the second discarded

    estepix
    Participant

    @estepix

    I think I got it right now, changing the line:
    $calendar_languages = array_merge($calendar_languages, $wp_fullcalendar_languages);
    to
    $calendar_languages = array_merge_recursive($calendar_languages, $wp_fullcalendar_languages);

    seems to do the trick. The array is merged along with its child keys contents.

    Christian
    Member

    @yakafaucon

    the solution I’ve posted some line before 😉

    estepix
    Participant

    @estepix

    that’s right @christian! sorry I didn’t read the thread carefully and thought that yours was a French only problem. It would have saved me quite a bit of time

    All credit is yours!!! 😉

    Plugin Author Marcus
    Participant

    @netweblogic

    thanks for the input guys, and props to @christian

    @mustermann I’m not entirely sure what you meant, could you rephrase? maybe the solutions posted after fix your issue as it’s for all languages

    mustermann
    Member

    @mustermann

    Marcus, if I need a translation months, days and other form english language to German Language I must put the translation in your code from wp full calendar. I must put it after every new version from you.

    Thanks for help.

    Jan-Erik
    Member

    @finlander

    Marcus,

    Please add the following Finnish translations to:
    wp-content/plugins/wp-fullcalendar/wp-fullcalendar.php

    ‘fi’=>array(‘closeText’=>’Sulje’,’prevText’=>'<Edel’,’nextText’=>’Seur>’,’currentText’=>’Tänään’,’monthNames’=>array(‘Tammikuu’,’Helmikuu’,’Maaliskuu’,’Huhtikuu’,’Toukokuu’,’Kesäkuu’,’Heinäkuu’,’Elokuu’,’Syyskuu’,’Lokakuu’,’Marraskuu’,’Joulukuu’),’monthNamesShort’=>array(‘Tammi’,’Helmi’,’Maalis’,’Huhti’,’Touko’,’Kesä’,’Heinä’,’Elo’,’Syys’,’Loka’,’Marras’,’Joulu’),’dayNames’=>array(‘Sunnuntai’,’Maanantai’,’Tiistai’,’Keskiviikko’,’Torstai’,’Perjantai’,’Lauantai’),’dayNamesShort’=>array(‘Su’,’Ma’,’Ti’,’Ke’,’To’,’Pe’,’La’),’dayNamesMin’=>array(‘Su’,’Ma’,’Ti’,’Ke’,’To’,’Pe’,’La’),’weekHeader’=>’Sm’,’dateFormat’=>’dd/mm/yy’,’firstDay’=>1,’isRTL’=>false,’showMonthAfterYear’=>false,’yearSuffix’=>”),

    and

    ‘fi’ => array(‘buttonText’ => array(‘today’=>’Tänään’,’month’=>’Kuukausi’,’week’=>’Viikko’,’day’=>’Päivä’)),

    Yours,

    Jan-Erik

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘How to translate days and months in the calendar ?’ is closed to new replies.