菜单

Configure TYPO3 for Localized Websites

2010年04月10日 - typo3

A bit older of a multi-lingual setup guide, but the principals are the same.

The information below is over a year old, circa mid-2008. Some of the techniques and settings may have changed for TYPO3 4.2 and TYPO3 4.3. I’ll release an update to this in early 2010.

  1. Website Language Creation
    1. On the TYPO3 Global page via List mode, add a new Website Language. Take note of the uid of that language. To do so, hover over the Website Language icon after saving and closing to see the uid. You’ll need this for the sys_language_uid setting later on.
  2. TypoScript Localization by URL or L Parameter
    1. If you do not have the cbstarter extension installed, put Section A into your main website TypoScript template Setup area. Otherwise, put Section A into your main website TypoScript template Constants area.
    2. Put Section B into your main website TypoScript template Setup area, below Section A.
    3. Based upon the URLs or domain names specific to your website and website languages, edit the Section A and Section B config.baseURL and sys_language_uid entries.
    4. config.locale_all
      1. Configures the locale which influences how some values from PHP is formated in the output, eg. dates formatted using strftime() which will then output month/day names in that language.
      2. Refer to the ICU User guide to format the locale_all entry.
      3. Refer to the ISO 639-2 Code List for the language code.
      4. Refer to ISO 3166 for the country code.
    5. config.language
      1. Configures the system “language key” to be used for the language. This is used to select labels from llXML (locallang-XML) files. Setting this should make frontend plugins respond by showing labels from the correct language (requires installation of the corresponding language packs).
    6. config.htmlTag_langKey
      1. Changes “xml:lang” and “lang” attributes in the <html> element.
  3. UTF-8 Configuration
    1. If you do not have extension cbstarter installed, put Section C into your main website TypoScript template Setup area. Otherwise, put Section C into your main website TypoScript template Constants area.
    2. Put Section D into your typo3conf/localconf.php file.
  4. RealURL Configuration
    1. Edit your realurl configuration to include a preVars > getVars > L entry.
    2. See Section E for a sample.
  5. Click “Clear all caches” for your TYPO3 installation.
  6. Create localized content
    1. Basic process
      1. Create alternative page language record
      2. Via Web > Page (TemplaVoila), click the “Create localized version” link on each content element you desire localization of.
      3. Via Web > Page, click the create new content icon, and set the language drop-down.
    2. Refer to the references for creating content in detail.

Section A – TypoScript Localization by URL

config.baseURL = www.cannonbose.com

# SSL is for cannonbose.com
[globalString = _SERVER|HTTPS=on]
	config.baseURL = https://www.cannonbose.com/
[end]

Section B – TypoScript Localization by URL or L Parameter

config {
	linkVars = L
	uniqueLinkVars = L
	sys_language_mode = content_fallback
	sys_language_overlay = 1
	sys_language_softMergeIfNotBlank = tt_content:image, tt_content:header

	sys_language_uid = 0
	locale_all = en_US
	language = en
	htmlTag_langKey = en-us
}

# French
[globalVar = GP:L = 1]
	config.sys_language_uid = 1
	config.locale_all = fr_FR
	config.language = fr
	config.htmlTag_langKey = fr

# Chinese (Simplified)
[globalVar = GP:L = 2] || [globalString = _SERVER|HTTP_HOST= *.cn]
	config.sys_language_uid = 2
	config.locale_all = zh_CN
	config.language = cn
	config.htmlTag_langKey = zh-cn
	config.baseURL = www.cannonbose.cn

# Chinese (Traditional)
[globalVar = GP:L = 3] || [globalString = _SERVER|HTTP_HOST= *.tw]
	config.sys_language_uid = 3
	config.locale_all = zh_TW
	config.language = tw
	config.htmlTag_langKey = zh-tw
	config.baseURL = www.cannonbose.com.tw
[end]

Section C – TypoScript UTF-8 Configuration

config.renderCharset = utf-8
config.metaCharset = utf-8

Section D – localconf.php UTF-8 Configuration

$TYPO3_CONF_VARS['BE']['forceCharset'] = 'utf-8';

Section E – realurl.php Sample Configuration

$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']['preVars'] = array(
		array(
			'GETvar' => 'L',
			'valueMap' => array(
				// 'english'
				'en' => '0',
				// 'french'
				'fr' => '1',
				// chinese simplified
				'cn' => '2',
				// 'chinese traditional
				'tw' => '3',
			),
			'noMatch' => 'bypass',
		),
	);

http://www.acqal.com/blog/a/article/configure-typo3-for-localized-websites/

发表评论

电子邮件地址不会被公开。 必填项已用*标注