Simple Event (months) language

Permalink
Hi folks,

i'm building this site with finnish language and i need to change/translate
those months into finnish language.

How do i do that?

I have installed finnish language package fi_FI into Concrete5 but that did not change anything?

Where does Simple Event get those months name's?

I find en.xml (concrete/libraries/3rdparty/zend/locale/data/en.xml) and there i changed english months into finnish but that did not fix anything..

please help!

/ Mika

 
mlocati replied on at Permalink Reply
mlocati
Do you want to translate just month names or a full date?
Oddmob replied on at Permalink Reply
Hi,

full date would be great!! but month wil be ok too....

I have no glue what to do here....

Just help me!!! :-)


// M
mlocati replied on at Permalink Reply
mlocati
I wrote an how-to about localization and dates: seehttp://www.concrete5.org/documentation/how-tos/developers/internati...
Oddmob replied on at Permalink Reply
Hi,

here's my code so u see yourself what i'm talking about. And i want translate event date in to Finnish...


***
<?php
for($i=0;$i<count($eArray);$i++){
$event = $eArray[$i];
?>
<div class="cpagecal">
<div class="titlehead">

<div class="space">
</div>

<div class="title">
<?php
echo '<a href="'.$event->url.'">'.$event->title.'</a>' ;
?>
</div>

<div class="pvm">    
<?php

echo $event->date.' - '.$event->todate ;

?>
</div>

</div>
</div>
<br class="clearfloat" />
<?php
}
?>
***
mlocati replied on at Permalink Reply
mlocati
It's all described in the howto.

BTW, the code is:
$dh = Loader::helper('date');
...
echo $dh->date(DATE_APP_GENERIC_MDY_FULL, strtotime($event->date));
Oddmob replied on at Permalink Reply
Hi, mlocati.

thx for your help.

Can u give me more help cos i'm not php coder at all..

sincerely,

/ Mika
mlocati replied on at Permalink Reply
mlocati
What kind of help do you need?
Oddmob replied on at Permalink Reply
Hi mlocati,

where is the place in C5 to translate to those months in to finnish by hand..
it that most simplest way to translate months?

/ Mika
mlocati replied on at Permalink Reply
mlocati
There's no simple way to translate months.
concrete5 uses Zend_Date to translate dates.
To translate only a month name first you have to build a Unix timestamp for a date/time that's for the month you want. For instance for August:
$timestamp =  mktime(0, 0, 0, 8, 18, 2014);

Then you can use the concrete5 datehelper (that makes use of ZendFramework 1 Zend_Data):
$dh = Loader::helper('date');
echo $dh->date('F', $timestamp);
Oddmob replied on at Permalink Reply
Hi,

i found file (Zend) where was all the months listed. I just tried to change all the month names in to finnish but that did not work out :-)

What is the first step that i have to do here?

// M
mlocati replied on at Permalink Reply
mlocati
You simply have to copy the PHP code that I wrote above...

Please remark that you need to have the current language set to Finnish (for this please browse the forums).
Oddmob replied on at Permalink Reply
Thx so mush for your help!

I got it allmost working with this code:

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
?>

<!-- Piilotetaan listalta otsikko

<h1>?php echo $rssTitle?></h1>
-->


<?php
for($i=0;$i<count($eArray);$i++){
$event = $eArray[$i];
?>
<div class="cpagecal">
<div class="titlehead">

<div class="space">
</div>

<div class="title">
<?php
echo '<a href="'.$event->url.'">'.$event->title.'</a>' ;
?>
</div>

<div class="pvm">    

<?php
$dh = Loader::helper('date');
echo $dh->date(DATE_APP_GENERIC_MDY_FULL, strtotime($event->date));' - '.$event->todate ;
?>

</div>

</div>
</div>
<br class="clearfloat" />
<?php
}
?>


<?php if($showfeed==1){ ?>
<div class="iCal">
<p><img src="<?php echo $controller->getRssIconUrl() ;?>" width="25" alt="iCal feed" />  
<a href="<?php echo($controller->getiCalUrl());?>?ctID=<?php echo $ctID ;?>&bID=<?php echo $bID ; ?>&ordering=<?php echo $ordering ;?>" id="getFeed">
<?php echo t('get iCal link');?></a></p>
<link href="<?php echo $controller->getiCalUrl();?>" rel="alternate" type="application/rss+xml" title="<?php echo t('RSS');?>" />
</div>
<?php } ?>


<?php
if($isPaged==1){
$controller->showPagination();
}
?>


Only TODATE ($event->todate ; ) is not working..
do i have to do helper for it also?

like this:

$dh = Loader::helper('todate');
and
echo $dh->todate(DATE_APP_GENERIC_MDY_FULL, strtotime($event->todate));'

/ Mika
mlocati replied on at Permalink Reply
mlocati
Instead of
echo $dh->date(DATE_APP_GENERIC_MDY_FULL, strtotime($event->date));' - '.$event->todate ;

You should write
echo $dh->date(DATE_APP_GENERIC_MDY_FULL, strtotime($event->date)).' - '.$dh->date(DATE_APP_GENERIC_MDY_FULL, strtotime($event->todate));
Oddmob replied on at Permalink Reply
Thx for your help.

I just found out that there is more problems in Simple Event with Concrete5 with finnish language on so I was wondering if i'm able to work it out just adding ordinary Content Block content (DATE) before TITLE in Pagelist.

Where user just fills in page blocks and i get this as a result:

> 12.9.2014 - Lorem ipsum (content block - title)
> 10.8.2014 - Lorem ipsum

How do i do this?

/ Mika
Oddmob replied on at Permalink Reply 1 Attachment
HI Mlocati,

how's things?

i have one more question about translating in C5 (ProBlog).
How do i translate only months (see attch file).

My config.php looks like this:

<?php 
define('DB_SERVER', 'xxx');
define('DB_USERNAME', 'xxx');
define('DB_PASSWORD', 'xxx');
define('DB_DATABASE', 'xxx');
define('PASSWORD_SALT', 'xxx');
define('LOCALE', 'fi_FI');
setlocale ('LC_TIME', 'fi_FI');
define('DATE_FORM_HELPER_FORMAT_HOUR','24');
define('DATE_APP_DATE_PICKER', 'dd-mm-yy');
define('DATE_APP_GENERIC_MDYT_FULL', 'j. F Y - G:i');
define('DATE_APP_GENERIC_MDYT', 'j-n-Y - G:i');
define('DATE_APP_GENERIC_MDY', 'j-n-Y');
define('DATE_APP_GENERIC_MDY_FULL', 'j. F Y');
define('DATE_APP_DATE_ATTRIBUTE_TYPE_T', 'G:i:s');


Here is my view.php code:

<?php      
   defined('C5_EXECUTE') or die(_("Access Denied."));
   $textHelper = Loader::helper("text");
   $BASE_URL = BASE_URL;
   $blogify = Loader::helper('blogify','problog');
   $searchID = $blogify->getBlogSettings();
   $searchn= Page::getByID($searchID['search_path']);
   $search= $nh->getLinkToCollection($searchn);
   if($title!=''){
      echo '<h1>'.t($title).'</h1>';
   }
   if (count($cArray) > 0) { ?>
   <div class="ccm-page-list">
   <?php
   for ($i = 0; $i < count($cArray); $i++ ) {


// Mika
mlocati replied on at Permalink Reply
mlocati
You should use the date method of the DateHelper helper.
It's a localized replacement for the standard PHP function date().

In other words:
$dh = Loader::helper('date');
echo $dh->date('F', strtotime('2000-09-01'));


The above would print out the localized month name for Septemper.
Oddmob replied on at Permalink Reply
Thx for your answer..again.. it is so cool that somebody is trying to help...!!

Thing is that page where that month is located is archive kind of page so there will be
more months in that list than just "Septemper"..in the future..

this is the page ->http://testi6.aada.fi/paakirjoitus/2014/...

how would you code in this situation?

// Mika
mlocati replied on at Permalink Reply
mlocati
echo $dh->date('F', strtotime('2000-' . $numberOfTheMonth . '-01'));
Oddmob replied on at Permalink Reply
So you would put that line into this line somehow?

>> echo '<a onClick="$(\'#month_'.$month.$year.'\').toggle(\'fast\')" style="cursor: pointer;">'.date('F',strtotime($year.'-'.$month.'-1')).'</a><br/>';





/ Mika
Oddmob replied on at Permalink Reply
My view.php looks like this:

<?php      
   defined('C5_EXECUTE') or die(_("Access Denied."));
   $textHelper = Loader::helper("text");
   $BASE_URL = BASE_URL;
   $blogify = Loader::helper('blogify','problog');
   $searchID = $blogify->getBlogSettings();
   $searchn= Page::getByID($searchID['search_path']);
   $search= $nh->getLinkToCollection($searchn);
    $dh = Loader::helper('date');
   if($title!=''){
      echo '<h1>'.t($title).'</h1>';
   }
   if (count($cArray) > 0) { ?>
    <div class="ccm-page-list">
   <?php



Now the month list is like this when it should be in finnish???

- January
- January
mlocati replied on at Permalink Reply
mlocati
As I told you, you have to use the date method of the DateTime helper instead of the date function.
Replace
date(...)

with
$dh->date(...)
RadiantWeb replied on at Permalink Reply
RadiantWeb
a more simple way for everyone's benefit is simply
<?php
        /**
    *setlocale(LC_TIME, "de_DE"); //uncomment and set this if not set on server
    */
?>
<?php       echo strftime("%B", $workingDt->getTimestamp()) ?>


ChadStrat
mlocati replied on at Permalink Reply
mlocati
Many server instances don't have set locale configured, so it's not safe to rely on it.
It's far better to use the concrete5 DateHelper
RadiantWeb replied on at Permalink Reply
RadiantWeb
so then that should be the following for this block:
<?php       echo $dh->date('F', $workingDt->getTimestamp() ); ?>


C
Oddmob replied on at Permalink Reply 1 Attachment
Hi C,

how can i translate labels in problog form?


/ Mika
Oddmob replied on at Permalink Reply
Hi mlocati,

thx for your help.

echo '<a onClick="$(\'#month_'.$month.$year.'\').toggle(\'fast\')" style="cursor: pointer;">'.$dh->date('F',strtotime($year.'-'.$month.'-1')).'</a><br/>';


This line works perfectly but only thing is that in finnish language we have in fi.xml
more parameters for months than in english.

Now i got the right months in list :

- Syyskuuta
- Lokakuuta

but i want to take that 'TA' out of months name. How do i do this?

p.s

e.g SYYSKUUTA (means 'of september') when just SYYSKUU means ('september').


// Mika
mlocati replied on at Permalink Reply
mlocati
Aha! Interesting!
In this case you can't use the DateHelper, but you have to access the underlying library that we use to translate dates.

You first need to retrieve the the month names:
Loader::library('3rdparty/Zend/Locale');
$monthNames = Zend_Locale::getTranslationList('month', Localization::activeLocale(), array('gregorian', 'stand-alone', 'wide'));
if($monthNames[1] === '1') {
   $monthNames = Zend_Locale::getTranslationList('month', Localization::activeLocale(), array('gregorian', 'format', 'wide'));
}


Then you can use this new $monthNames variable. In your example you should write:
echo '<a onClick="$(\'#month_'.$month.$year.'\').toggle(\'fast\')" style="cursor: pointer;">'.$monthNames[$month].'</a><br/>';
Oddmob replied on at Permalink Reply
:-)

very interesting..finnish language is...

I tried with this code but then my list just disappears :-)
Is the Loader::Library.. in the right place at all?

<?php      
   defined('C5_EXECUTE') or die(_("Access Denied."));
   $textHelper = Loader::helper("text");
   $BASE_URL = BASE_URL;
   $blogify = Loader::helper('blogify','problog');
   $searchID = $blogify->getBlogSettings();
   $searchn= Page::getByID($searchID['search_path']);
   $search= $nh->getLinkToCollection($searchn);
    $dh = Loader::helper('date');
   Loader::library('3rdparty/Zend/Locale');
    $monthNames = Zend_Locale::getTranslationList('month', Localization::activeLocale(), array('gregorian', 'stand-alone', 'wide'));
    if($monthNames[1] === '1') {
   $monthNames = Zend_Locale::getTranslationList('month', Localization::activeLocale(), array('gregorian', 'format', 'wide'));
    }
   if($title!=''){
mlocati replied on at Permalink Reply
mlocati
You should check the PHP error log
Oddmob replied on at Permalink Reply
wow! interesting!

how i do that?

/ M
mlocati replied on at Permalink Reply
mlocati
Is the whole page blank? Or you just stopped seeing the month names?

In the second case, you could try to see the value of $monthNames, by placing something like the following after the definition of $monthNames:
var_dump($monthNames);
Oddmob replied on at Permalink Reply 1 Attachment
Hi,

thz for your help again.

My code:

echo '<a onClick="$(\'#month_'.$month.$year.'\').toggle(\'fast\')" style="cursor: pointer;">'.var_dump($monthNames);$monthNames[$month].'</a><br/>';


gives me list of all finnish months...but right way as i would like them to be on list.
What is the right place for your (var_dump($monthNames);) code??


// Mika
mlocati replied on at Permalink Reply
mlocati
I suggested you to add that var_dump only to see if it contains the correct values.
Since $monthNames seems correct, we have to look for the problem in another place.

You could try this code:
echo '<a onClick="$(\'#month_'.$month.$year.'\').toggle(\'fast\')" style="cursor: pointer;">'.$monthNames[intval($month)].'</a><br/>';
Oddmob replied on at Permalink Reply
Hi,

thx for so much for your patient and help!!!!
It finally works!!!


// Mika
Oddmob replied on at Permalink Reply
hi,

i do not get any error msg on my page even i have "Show Errors in Page" checked on
Dashboard > System & Settings > Environment > Debug Settings


// Mika