
eZ Publish country datatype – multilingual tips
eZ Publish supports a country datatype which is very often used in various forms. I looked what problems users can meet while working with this datatype and multilingual forms. Here is some information that you may find useful.
settings/country.ini file contains a default (English) list of available countries which you can access in template via fetch function “country_list”.
{def $countries=fetch( 'content', 'country_list' )}
The “country_list” function returns a multi-dimensional array with available countries in the same order as they are defined in country.ini (The INI file is read from top to bottom).
There are two possibilities of adding translations for the country datatype:
- override country.ini globally or per siteaccess e.g settings/siteaccess/pol/country.ini.append.php
- add the translation to share/locale/*.ini files
By overriding country.ini globally or per siteaccess you can add the translation directly in country.ini.append.php file by changing the Name variable. You can also control the sort order, by changing the order of the blocks.
The second method is just adding translations directly to the locale INI file e.g share/locale/pol-PL.ini as follows:
[CountryNames] Countries[PL]=Polska Countries[NO]=Norwegia Countries[DE]=Niemcy
Here the key in the Countries[] array refers to the INI block name in country.ini. Using this way you can only add translations but you can't control the order of entries that the fetch function returns.
It is up to you which solution is better for your project.





