Step 1: Your default language
Define which language will be the default language. All pages will primarily be created in this language. The page titles in the page tree will also be shown in this language in the backend.
In the testsite example, english is the default language.
Step 2: Your alternative languages
You define alternative languages for your site by creating each language as a “Website Language” in the root of the page tree. These languages will be globally available in the system!
In the testsite example, Danish and German is created as default languages. They are technically identified by their “uid” numbers.
Step 3: Create an “Alternative Page Language” record
In step 2 you defined an alternative language which would now be available for use. But you must still for each page provide a translation (of course…). The point is that all pages have content in the default language (here English) but if the website user has chosen German as his preference, then the german page content will be shown if there exist german content for the page! If no german translation exist the page content will be shown in the default language instead.
This is what you do; Go to the Web>Page module, click the page you want to translate in the page tree, finally select the “Languages” function in the function menu:
As you see the columns on the page in the default language is shown here.
Now make a new translation of this page into german:
… and then you see this form:
Here you are about to create an “Alternative Page Language” record which - as you should be able to recognize - contains fields perfectly similar to those (content oriented fields) of the actual page record of the page. The secret is that the content here will override the default content of the page record when the alternative language is shown!
Step 4: Create page content in the new language
Back in the Web>Page module you can now create content for the new language in any of the columns.
Technical note: With the appearance of this multi language approach the content element table has got yet a field to select for - the sys_language field. So now content elements are selected based on their column and their language:
.. and as you can see in the static_templates, the TypoScript for selecting content elements has been updated as well:
Step 5: A language selector on the website
If you take a look at the page “Backend user” for which you have just created the german language version, you’ll see that the language selector menu in the bottom of the page displays the german flag (the danish is still dimmed):
Clicking the german flag, you’ll get the page in german (or whatever I tried to write in german :-):
And this menu is inserted in the TypoScript template (”+ext: Language settings”) like this:
So just dive into the php script “media/scripts/example_languageMenu.php” and check out how I did it!
Step 6: Configure your TypoScript template to select the language
Now that you have studied the menu you have found that I use the variable “L” to indicate the language to show. At least look in the URL:
(The number “2″ refers back to the uid number of the german “Website Language” record we created in step 2.)
The final thing to do now is to configure TypoScript to enable the language set by L. This is also shown in the extension template “+ext: Language settings” on the testsite:
(Remember to put in a line with “[GLOBAL]” after these two conditions in TypoScript to return to the global scope of TypoScript parsing.)
It’s very important that you do it like this, because then all the caching of templates, pages etc. will still work.
The really important setting here is “config.sys_language_uid” (Please look it up in TSref). When this is set then by total automation all system calls that select page records will automatically override the default field content with that of any present Alternative Page Language record for the given language on the page. And bang - you’ve got the page header, the menu etc. shown in the right language:
Which concept to choose?
This will be your job to determine from this article. I believe it depends on how close you expect the languages to be woven into the pages; The two-tree concept offers freedom, but “loose control”. This approach is great if you wish to put up a downscaled version of your main website in another language. The one-tree solution integrates translations seemlessly in the same pages keeping the page ids the same etc. However I believe this concept demands a pretty consistent practice of translation throughout the site to become a success.
[taken from typo3.org]



Recent Comments