Merge pull request #1342 from chillu/pulls/i18n-common-languages

API i18n::$common_languages and i18n::$common_locales converted to Confi...
This commit is contained in:
Ingo Schommer 2013-04-02 02:44:06 -07:00
commit 47e02216fa

View File

@ -67,14 +67,35 @@ Formats can be set globally in the i18n class. These settings are currently only
to write your own logic for any frontend output. to write your own logic for any frontend output.
:::php :::php
i18n::set_date_format('dd.MM.YYYY'); Config::inst()->update('i18n', 'date_format', 'dd.MM.YYYY');
i18n::set_time_format('HH:mm'); Config::inst()->update('i18n', 'time_format', 'HH:mm');
Most localization routines in SilverStripe use the [Zend_Date API](http://framework.zend.com/manual/en/zend.date.html). Most localization routines in SilverStripe use the [Zend_Date API](http://framework.zend.com/manual/en/zend.date.html).
This means all formats are defined in This means all formats are defined in
[ISO date format](http://framework.zend.com/manual/en/zend.date.constants.html#zend.date.constants.selfdefinedformats), [ISO date format](http://framework.zend.com/manual/en/zend.date.constants.html#zend.date.constants.selfdefinedformats),
not PHP's built-in [date()](http://nz.php.net/manual/en/function.date.php). not PHP's built-in [date()](http://nz.php.net/manual/en/function.date.php).
### Language Names
SilverStripe comes with a built-in list of common languages, listed by locale and region.
They can be accessed via the `i18n.common_languages` and `i18n.common_locales` [config setting](/topics/configuratio).
In order to add a value, add the following to your `config.yml`:
:::yml
i18n:
common_languages:
de_CGN:
name: German (Cologne)
native: Kölsch
Similarly, to change an existing existing language label, you can overwrite one of these keys:
i18n:
common_languages:
en_NZ:
native: Niu Zillund
### i18n in URLs ### i18n in URLs
By default, URLs for pages in SilverStripe (the `SiteTree->URLSegment` property) By default, URLs for pages in SilverStripe (the `SiteTree->URLSegment` property)