Closed voltan closed 11 years ago
And if support in controller is very good for ajax functions and json outputs
I am working on it. Can you give some use cases?
I'll send live pi example here in next two hour after finish server config
I add this line in template ( just for test )
$fmt = new IntlDateFormatter("fa_IR@calendar=persian", IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL);
And use this function for make date
$fmt->format(intval($message['create']));
And template is here : https://github.com/taiwen/voltan/blob/master/usr/module/sms/template/front/list.phtml
I add some changes in date format and get image for result :
$fmt = new IntlDateFormatter("fa_IR@calendar=persian", IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL);
$fmt = new IntlDateFormatter("en_US@calendar=persian", IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL);
$fmt = new IntlDateFormatter("en_US", IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL);
$fmt = new IntlDateFormatter("fa_IR", IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL);
For use cases, it need for all date outputs , I think for each website / language we need some settings. Like :
And mvc plugin / view helper / i18n class, for use it in all controllers / template / other parts
We also need use cases for NumberFormatter
I test this helper in i18n : http://framework.zend.com/manual/2.0/en/modules/zend.i18n.view.helpers.html#numberformat-helper
For Persian / Arabic language it has good support ( here for example : http://www.payamakyab.com/ ), just we need tools for set NumberFormatter and local
Thank you very much, It work for me fine , just two points : 1- It possible to update pi module codes and use _date() functions 2- I am not sure, But perhaps it bug, when I change timetype and datetype its not work, I'll test on other machine
Can we use _date() in Pi modules? Kind of complicated:
A tricky solution is:
if (_intl()) {
// Use _date();
} else {
// Use date();
}
I think we need date standard on all modules, if any one change calendar or date format , if php extensions installed use that. and if not installed use date()
The problem is that arguments are different
Perhaps whit this edit is solve :
/**
* Locale-dependent formatting/parsing of date-time using pattern strings and/or canned patterns
*
* @param array|string|null $locale
* @param int|null $datetype
* @param int|null $timetype
* @param string|null $timezone
* @param int|string|null $calendar
* @param string|null $pattern
* @return string
*/
function _date($value, $locale = null, $datetype = null, $timetype = null, $timezone = null, $calendar = null, $pattern = null)
{
if (!_intl()) {
$pattern = Pi::config('date_pattern', 'intl');
return date($value, $pattern);
}
$formatter = Pi::service('i18n')->getDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
$result = $formatter->format($value);
return $result;
}
Big thanks for add this option, All of our problems for localization solved
Hi
support local calendar is to important for us. and whit php 5.3 and intl its very easy . just need one line code :
But I don't know what is the best way for use it in PI. We need general date manager function for support all languages / calendars. At this moment we use date function for make date. we need change / update it.
And use it all codes for example as i18n/View/Helper/DateFormat.php in templates and rewrite it for support local calendar