官术网_书友最值得收藏!

Creating multilingual siteaccesses

As we saw, eZ Publish created a siteaccess for every language that we enabled in the first chapter. If we'd like to add more languages for our site, we need to create a new siteaccess folder and configure the language settings inside it.

Let's create, for example, a German siteaccess. This task can be summarized in the following three steps:

  1. Create a new folder called de, inside settings/siteaccess/.
  2. Copy the files or create the appropriate symbolic links as per the eng siteaccess, inside the de folder.
  3. Configure the siteaccess .ini configuration files for the language.

Copying the configuration file

We need to create all of the .ini files from the main language siteaccess in the new language folder (de). To do this, we need to create a symbolic link for all the files, except the site.ini.append.php, that are to be copied into the new folder.

Editing ini files for locale components

Configure all of the site.ini.append.php files for all of the languages siteaccesses, to enable the new German language.

To do this we will edit the files, adding the highlighted code:

# vi settings/siteaccess/eng/site.ini.append.php
[RegionalSettings]
Locale=eng-GB
ContentObjectLocale=eng-GB
ShowUntranslatedObjects=enabled
SiteLanguageList[]=eng-GB
SiteLanguageList[]=ita-IT
SiteLanguageList[]=fre-FR
SiteLanguageList[]=de-DE
TextTranslation=disabled

Do the same for the site.ini.append.php files in the fre folder and the ita folder.

After that, we need to copy the eng/site.ini.append.php to our new folder, de, and edit it as follows:

[RegionalSettings] Locale=de-DE ContentObjectLocale=de-DE ShowUntranslatedObjects=enabled SiteLanguageList[]=de-DE
SiteLanguageList[]=eng-GB
SiteLanguageList[]=ita-IT
SiteLanguageList[]=fre-FR
TextTranslation=enabled

The directive SiteLanguageList tells us the order in which the system will show the content for our objects. If the content isn't translated into German, eZ will show the English version; if the English version is unavailable than it will show the Italian one, and so on.

The last step is to add the new languages inside the settings/override/site.ini.append.php, as we did for the dev and staging siteaccesses:

[SiteSettings]
..
SiteList[]=fre
SiteList[]=ita
SiteList[]=eng
SiteList[]=de
[SiteAccessSettings]
..
AvailableSiteAccessList[]=fre
AvailableSiteAccessList[]=eng
AvailableSiteAccessList[]=ita
AvailableSiteAccessList[]=de
..
RelatedSiteAccessList[]=fre
RelatedSiteAccessList[]=eng
RelatedSiteAccessList[]=ita
RelatedSiteAccessList[]=de
主站蜘蛛池模板: 绥棱县| 阿合奇县| 从化市| 拉孜县| 衢州市| 阿合奇县| 石首市| 大同市| 柘荣县| 天门市| 铜陵市| 平潭县| 娄底市| 深圳市| 石棉县| 稻城县| 和田县| 来宾市| 宜黄县| 康马县| 缙云县| 梅州市| 喀喇| 都匀市| 建宁县| 金华市| 河北区| 景洪市| 邻水| 天门市| 黔西| 芜湖市| 湟源县| 漳浦县| 石门县| 呼伦贝尔市| 永顺县| 望城县| 祁阳县| 万载县| 武鸣县|