This page is still a beta!

1.3. Tutorial

Requirements

Tables

We need tables with localization and language overlay.

The extension tt_news is a good example:

  1. tt_news is a localized table with the fields:

    Illustration 2: The table tt_news in phpMyAdmin with localization fields.

    1. sys_language_uid

    2. l18n_parent

    3. l18n_diffsource

  1. tt_news_cat is a table with a language overlay field:

    Illustration 3: Table tt_news_cat in phpMyAdmin with the language overlay field.

    1. title_lang_ol

TYPO3 Languages

Extend your TYPO3 installation with languages.

Illustration 4: TYPO3 installation with two language records.

In our example above we have

  1. a default language (there is no record in the table "Website Language"). The default is German and has the uid 0.

  2. Englisch (uid 1) and

  3. Französisch (uid 2)

Translated Page with the Browser plugin

Create a page and add the plugin Browser. Translate the page to English and French.

You need a translated page, if you want to display Browser results in a non default language.

You need a translated plugin Browser only, if you like to use a different header in a non default language.

Illustration 5: The page "Nachrichten" is translated into English and French. Every translated page contains the Browser plugin.

The starting point of the plugin Browser is the folder with your news.

Translated Sysfolder

The sysfolder with your records (in this case: news) has to be translated too. Otherwise you can't store a record in another language than the default language.

Illustration 6: The sysfolder "Nachrichten" is translated into English and French.

Localized Local Table

The illustration below displays a localized local table: tt_news has translated records.

Illustration 7: Sysfolder with the records in the list view.

The content of your sysfolder should be look like the illustration above.

  1. The alternative page language records.

  2. The first news is translated into English but not into French.

  3. You can translate (localize) the news into French by clicking the French icon.

  4. The second news isn't translated in any language.

Foreign Table with Language Overlay

The illustration below displays the foreign table with a language overload field: tt_news_cat has translated categories.

Illustration 8: Sysfolder with the categories in the list view.

Please note:

The Browser enables language overlay phrases with a language prefix like

  1. en:Lead Story|fr:Accroche

This is an enhancement of the common language overlay phrases without an language prefix.

If you like to use the common way without language prefixes please configure:

plugin.tx_browser_pi1.advanced.localization.TCA.value.langPrefix = 0

TypoScript

Copy the Code

You find the whole TypoScript code in

  1. res/setup.txt

You can copy it into your page template.

What do you need

  1. The page with the browser plugin needs an TypoScript template.

  2. Include the include static template from the browser.

  3. Configure in the field [setup] the:

    1. language configuration

    2. a language menu

    3. the Browser configuration

Language configuration

If your are uisng more than the default language, you have to configure the behavior of each language.

config {

  linkVars             = L

  metaCharset          = UTF-8

  sys_language_uid     = 0

  sys_language_mode    = strict

  sys_language_overlay = 0

  language             = de

  locale_all           = de_DE

  htmlTag_langKey      = de

}

[globalVar = GP:L = 1]

  config {

    sys_language_uid     = 1

    sys_language_mode    = content_fallback

    sys_language_overlay = 1

    language             = en

    locale_all           = en_GB

    htmlTag_langKey      = en

  }

[global]

[globalVar = GP:L = 2]

  config {

    sys_language_uid     = 2

    sys_language_mode    = strict

    sys_language_overlay = hideNonTranslated

    language             = fr

    locale_all           = fr_FR

    htmlTag_langKey      = fr

  }

[global]

Language Menu

The code

// If we have single view, the menu should have the record uid

temp.addParams = COA

temp.addParams {

  10 = TEXT

  10 {                tx_browser_pi1[showUid]

    dataWrap        = &tx_browser_pi1[showUid]={GPvar:tx_browser_pi1|showUid}

    if.isTrue.data  = GPvar:tx_browser_pi1|showUid

  }

}

// The language menu

temp.nav_language = HMENU

temp.nav_language {

  special = language

  special.value = 0,1,2

  special.normalWhenNoLanguage = 1

  1 = TMENU

  1{

    NO {

      linkWrap = <span> | </span> || <span class="last"> | </span>

      linkWrap = <li class="no">|</li>||<li class="no">|</li>||<li class="no last">|</li>

      stdWrap.override = Deutsch || English || Französisch

      additionalParams {

        cObject < temp.addParams

      }

    }

    ACT = 1

    ACT {

      doNotLinkIt = 1

      linkWrap = <span class="act"> | </span> || <span class="act last"> | </span>

      linkWrap = <li class="act">|</li>||<li class="act">|</li>||<li class="act last">|</li>

      stdWrap.override = Deutsch || English || Französisch

    }

    wrap = <ul class="navi-ul">|</ul>

  }

}

// Add the language menu to your page object

  // Adapt this to your page object

page.10.subparts.navi {

  10 < temp.nav_language

  22 >

}

  // Adapt this to your page object

Browser

// Two list views and two single views

plugin.tx_browser_pi1. views {

  list.1.select   = tt_news.title, tt_news_cat.title

  list.1.select   = tt_news.title, tt_news.image

  single.1.select = tt_news.title, tt_news.author, tt_news_cat.title, tt_news.short, \                    tt_news.datetime

  single.1.select = tt_news.title, tt_news.bodytext, tt_news.image, tt_news.imagecaption, \                    tt_news.imagealttext, tt_news.imagetitletext, tt_news_cat.title

  marker.my_title {

    value   = My News List

    lang.de = Meine Nachrichten Liste

    lang.fr = Nouvelles Tableau

    wrap    = <h2>|</h2>

  }

}

Backend Illustration

Illustration 9: Page "Nachrichten" in the Backend.

Page

The page "Nachrichten" with

  1. three Browser plugins,

  2. two alternative page language records and

  3. the template.

We call the template in the syntax:

  1. type_page-name_template-uid

  2. example: +page_nachrichten_382

Template with Setup

Illustration 10: Template with the code in the setup field.

 

Illustration 11: Include static template from the Browser.

Frontend Illustration

We have different results in the frontend - depending on the language configuration.

Illustration 12: List View in German

Illustration 13: List View in Englisch

Illustration 14: List View in French

 

German (default language)

All records are in German.

English

Records are displayed, which are translated into English. If they aren't translated, they are displayed in the default language German.

French

Records are displayed only, if they are translated into French.

 

TypoScript

config {

  sys_language_uid     = 0

  sys_language_mode    =

  strict

  sys_language_overlay = 0

  language             = de

  locale_all           = de_DE

  htmlTag_langKey      = de

}

TypoScript

config {

  sys_language_uid     = 1

  sys_language_mode    = \    content_fallback

  sys_language_overlay = 1

  language             = en

  locale_all           = en_GB

  htmlTag_langKey      = en

}

TypoScript

config {

  sys_language_uid     = 2

  sys_language_mode    = strict

  sys_language_overlay = \    hideNonTranslated

  language             = fr

  locale_all           = fr_FR

  htmlTag_langKey      = fr

}

 

If you want to know more about

  1. sys_language_uid

  2. sys_language_mode

  3. sys_language_overlay

please read the section "What's the definition off?" in the FAQ below.