SlideShare a Scribd company logo
i18n and L10n
in TYPO3 Flow
    Karsten Dambekalns




                         Inspiring people to
                         share
Karsten Dambekalns
co-lead of TYPO3 Neos and Flow
35 years old
lives in Lübeck, Germany
1 wife, 3 sons, 1 espresso machine
likes canoeing and climbing




                                     Inspiring people to
                                     share
Basics
 i18n is the process of making software
 localizable
 L10n means actually

 • formatting dates, numbers, …
 • translating text
 • adjusting other things (images, …)

                                Inspiring people to
                                share
Locale
 Locale instances encapsulate a locale
 identifier
 Locales define the language and formats
 to use
 Locales form a hierarchy

 • en is a parent of en_US which is a
   parent of en_US_POSIX

 • Thus items for the en_US locale that do
                                  Inspiring people to
                                 share
What you need
 A way to translate in templates
 A way to store translations of labels
 Formatters for dates, numbers, …
 An API for use in PHP




                                   Inspiring people to
                                   share
f:translate
     the way of translating you will use most

<f:translate id="my.label.1"/>

{f:translate(id: 'my.label.1')}

     translation by label is possible, but
     discouraged
   • less reliable than id-based translation
                                       Inspiring people to
                                       share
f:translate
<f:translate id="my.label.1"
 source="Registration"
 package="Acme.Demo"/>

<f:translate id="my.label.1"
  arguments="{0: 'hi'}" quantity="2"/>



                                         Inspiring people to
                                         share
f:form.select
    has translation support built in

<f:form.select options="{paymentOptions}"
translate="{by: 'id'}" />

<f:form.select options="{paymentOptions}"
translate="{by: 'id', prefix: 'payment.options.',
package: 'Acme.Demo.Translations'}" />


                                         Inspiring people to
                                         share
Message catalogs
 XML Localisation Interchange File Format
 is the standard we use
 Looked up in well-known location
 Resources/
   Private/
     Translations/
       <locale>/
        <source>.xlf


                                Inspiring people to
                                share
XLIFF basics
 An XLIFF file can hold translations for one
 locale
 It contains one or more <file> elements
 corresponding to a source
 Localizable data is stored in <trans-unit>
 elements which contain a
 <source> element to store the source
 text and a (non-mandatory) <target>


                                 Inspiring people to
                                 share
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
	

 <file original="" product-name="Acme.Demo" source-
language="en" datatype="plaintext">
	

 	

 <body>
                                Text
	

 	

 	

 <trans-unit id="my.label.1" xml:space="preserve">
                                 Text
	

 	

 	

 	

 <source>My Label 1</source>
	

 	

 	

 </trans-unit>
	

 	

 </body>
	

 </file>
</xliff>



                                                   Inspiring people to
                                                   share
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
	

 <file original="" product-name="Acme.Demo" source-
language="en" datatype="plaintext">
	

 	

 <body>
	

 	

 	

 <trans-unit id="my.label.1" xml:space="preserve">
	

 	

 	

 	

 <source>My Label 1</source>
	

 	

 	

 	

 <target>Mein Aufkleber 1</target>
	

 	

 	

 </trans-unit>
	

 	

 </body>
	

 </file>
</xliff>


                                                   Inspiring people to
                                                   share
i18n configuration
       Default locale can be set in Settings.yaml
       Locale fallback rules are configurable

TYPO3:
 Flow:
  i18n:
    defaultLocale: de
    fallbackRule:
      strict: FALSE
      order: [lv, en]


                                        Inspiring people to
                                        share
i18n configuration
       Default locale can be set in Settings.yaml
       Locale fallback rules are configurable

TYPO3:
 Flow:
  i18n:
    defaultLocale: de
    fallbackRule:
      strict: FALSE
      order: [lv, en]


                                        Inspiring people to
                                        share
Placeholder use
$this->view->assign('foo', 'QUUX');
$this->view->assign('bar', 'BAZ');


<f:translate id="my.label.3" arguments="{0: foo, 1: bar}"/>


<trans-unit id="my.label.3" xml:space="preserve">
	

 <source>I have {0} and {1}</source>
	

 <target>{1} habe ich und {0} habe ich auch</target>
</trans-unit>


                                                     Inspiring people to
                                                     share
String placeholders                        * will be available with Flow 2.0



$this->view->assign('foo', 'QUUX');
$this->view->assign('bar', 'BAZ');


<f:translate id="my.label.3" arguments="{'some': foo, 'thing': bar}"/>


<trans-unit id="my.label.3" xml:space="preserve">
	

 <source>I have {some} and {thing}</source>
	

 <target>{thing} habe ich und {some} habe ich auch</target>
</trans-unit>


                                                         Inspiring people to
                                                         share
Using formatters
$this->view->assign('currentDateAndTime', new DateTime());
$this->view->assign('currentCost', 1.25);


<f:translate id="my.label.4" arguments="{
   0: currentDateAndTime, 1: currentCost
}"/>


<source>
  At {0,datetime} it costs {1,number} monetary units
</source>

                                                  Inspiring people to
                                                  share
Plural forms
 The CLDR defines six plural forms

 • zero, one, two, few, many, other
 Different languages use more or less
 forms

 • singular and plurals for English
 • one, few and other for Polish
 • only other for Japanese
                                  Inspiring people to
                                  share
Plural forms
<f:translate id="my.label.6" quantity="{quarks->f:count()}"/>


<group id="my.label.6" restype="x-gettext-plurals">
	

 <trans-unit id="my.label.6[0]" xml:space="preserve">
   	

  <source>There is this quark</source>
	

 </trans-unit>
	

 <trans-unit id="my.label.6[1]" xml:space="preserve">
	

 	

 <source>There are these quarks</source>
	

 </trans-unit>
</group>


                                                    Inspiring people to
                                                    share
L10n of resources
 Resources can be localized as well
 The locale is part of the name

 • Image.png
 • Image.de.png
 • Image.lv.png
 Usable for all resources

 • Images, templates, …
                                  Inspiring people to
                                  share
f:resource
         uses localized resources by default*

     <img src="{f:uri.resource(path: 'Images/Image.png')}"/>

     <img src="../../../../Resources/Public/Images/Image.png"/>




* see Known

                                                  Inspiring people to
                                                  share
i18n in PHP code
 TYPO3FlowI18nTranslator

 • translateById()
 • translateByOriginalLabel()
 TYPO3FlowI18nService

 • getConfiguration()
 • getLocalizedFilename()
 TYPO3FlowI18nFormatter*

                                Inspiring people to
                                share
Setting current locale
/**
   * @param string $locale
   * @return void
   */
public function selectAction($locale = NULL) {
	

 if ($locale !== NULL) {
	

 	

 $this->i18nService->getConfiguration()->setCurrentLocale(
     	

 	

 new TYPO3FlowI18nLocale($locale)
	

 	

 );
	

 }                                             WARN   ING:
	

 $this->forward('index');                        Stupid
}
                                                    ex ample
                                                 Inspiring people to
                                                 share
Tips & Tricks
 Split catalogs at logical points
 Try to use.a.clever.id.system
 Avoid hardcoded labels from the start
 To change "original" labels simply
 translate to "original" language




                                    Inspiring people to
                                    share
Known issues
 L10n support in f:resource VH pending in
 review
 Fallback per label is missing, currently
 only done per catalog
 Overriding parts of catalogs is missing
 Model translation still missing




                                   Inspiring people to
                                   share
Thank You!
 These slides can be found at:
 http://speakerdeck.com/kdambekalns
 http://slideshare.net/kfish
 Give me feedback:
 karsten@typo3.org | karsten@dambekalns.de
 Download Flow: http://flow.typo3.org
 Follow me on twitter: @kdambekalns
 Support me using


                                  Inspiring people to
                                  share
i18n and L10n in TYPO3 Flow

More Related Content

PPTX
Bioinformatics p1-perl-introduction v2013
ODP
Perl Introduction
PPT
LPW: Beginners Perl
PPT
PDF
Perl programming language
KEY
Introduction to Perl Best Practices
PPT
Perl Presentation
PDF
Lecture19-20
Bioinformatics p1-perl-introduction v2013
Perl Introduction
LPW: Beginners Perl
Perl programming language
Introduction to Perl Best Practices
Perl Presentation
Lecture19-20

What's hot (19)

PPT
ODP
perl usage at database applications
PPT
Introduction to perl_ a scripting language
PPT
Introduction To Php For Wit2009
PPTX
PHP Powerpoint -- Teach PHP with this
PPT
Php Simple Xml
PDF
Puppet Camp Berlin 2015: Martin Alfke | The Power of Puppet 4
PPTX
PPT
Perl tutorial
PPT
PHP - Introduction to PHP
PDF
DBIx::Class beginners
PPT
Introduction to php
PDF
Introduction to php
PDF
Was können wir von Rebol lernen?
PDF
DBIx::Class introduction - 2010
PPT
My cool new Slideshow!
PPT
slidesharenew1
perl usage at database applications
Introduction to perl_ a scripting language
Introduction To Php For Wit2009
PHP Powerpoint -- Teach PHP with this
Php Simple Xml
Puppet Camp Berlin 2015: Martin Alfke | The Power of Puppet 4
Perl tutorial
PHP - Introduction to PHP
DBIx::Class beginners
Introduction to php
Introduction to php
Was können wir von Rebol lernen?
DBIx::Class introduction - 2010
My cool new Slideshow!
slidesharenew1
Ad

Viewers also liked (20)

PDF
Emplois du Temps du 2ème semestre 2016-2017
PDF
April 19 social marketing & yr business
PDF
My Works About UT Plan (draft) 2004
PDF
4.3 My Works About Operation
PPT
Presentation
PPTX
GlobalSHIFT 3.0
PDF
A review of Office AutoPilot
PPT
I Jet Exec Sum
PDF
080312 talk about 3D-Internet Overview
PDF
Qwerly GeeknRolla Presentation
PDF
Filosofia da educação uma abordagem sobre fundamentos da educação no brasil
PPT
Hex Colors At A Glance
PDF
What can I do?
PDF
The Augmented Reality industry in 15 min.
PDF
SoftLayerで始めるデジタルマーケティング
PDF
A Content Repository for TYPO3 5.0
PDF
Kcic boot camp oct 2011 idea to implementation 2011
ODP
Gabriela
PDF
Moscow 09 12-11
PPT
Do The Adverts Fool Us
Emplois du Temps du 2ème semestre 2016-2017
April 19 social marketing & yr business
My Works About UT Plan (draft) 2004
4.3 My Works About Operation
Presentation
GlobalSHIFT 3.0
A review of Office AutoPilot
I Jet Exec Sum
080312 talk about 3D-Internet Overview
Qwerly GeeknRolla Presentation
Filosofia da educação uma abordagem sobre fundamentos da educação no brasil
Hex Colors At A Glance
What can I do?
The Augmented Reality industry in 15 min.
SoftLayerで始めるデジタルマーケティング
A Content Repository for TYPO3 5.0
Kcic boot camp oct 2011 idea to implementation 2011
Gabriela
Moscow 09 12-11
Do The Adverts Fool Us
Ad

Similar to i18n and L10n in TYPO3 Flow (20)

PDF
Living in a Multi-lingual World: Internationalization in Web and Desktop Appl...
PDF
WordPress Plugin Localization
PDF
Crossing the border with Qt: the i18n system
PDF
Living in a multiligual world: Internationalization for Web 2.0 Applications
PDF
Learn to Internationalize your Application
PDF
Learn to Internationalize your Applications - Sun Tech Days 2009
PDF
Learn to Internationalize your Applications - Sun Tech Days 2009
PDF
Learn to Internationalize your Applications - Sun Tech Days 2009
KEY
Remixing Confluence With Speakeasy
PDF
How To Build And Launch A Successful Globalized App From Day One Or All The ...
ODP
Internazionalizza le tue applicazioni
PDF
Melody Designer Training
PDF
Internationalization (i18n) Primer
KEY
Beyond Sharing: Open Source Design
PDF
Multi-Language Websites in ExpressionEngine
PPTX
Internationalization
PDF
Parlez-vous zwei-null, señor?
PDF
Internationalization with the symfony framework
KEY
Building Multilanguage (i18n) Flex Applications
PDF
Wordware 2011: Lingoport i18n Planning & Static Analysis
Living in a Multi-lingual World: Internationalization in Web and Desktop Appl...
WordPress Plugin Localization
Crossing the border with Qt: the i18n system
Living in a multiligual world: Internationalization for Web 2.0 Applications
Learn to Internationalize your Application
Learn to Internationalize your Applications - Sun Tech Days 2009
Learn to Internationalize your Applications - Sun Tech Days 2009
Learn to Internationalize your Applications - Sun Tech Days 2009
Remixing Confluence With Speakeasy
How To Build And Launch A Successful Globalized App From Day One Or All The ...
Internazionalizza le tue applicazioni
Melody Designer Training
Internationalization (i18n) Primer
Beyond Sharing: Open Source Design
Multi-Language Websites in ExpressionEngine
Internationalization
Parlez-vous zwei-null, señor?
Internationalization with the symfony framework
Building Multilanguage (i18n) Flex Applications
Wordware 2011: Lingoport i18n Planning & Static Analysis

More from Karsten Dambekalns (20)

PDF
Updating Neos – Why, When and How - 2024 edition
PDF
The Perfect Neos Project Setup
PDF
Sawubona! Content Dimensions with Neos
PDF
Deploying TYPO3 Neos websites using Surf
PDF
Profiling TYPO3 Flow Applications
PDF
Using Document Databases with TYPO3 Flow
PDF
FLOW3-Workshop F3X12
PDF
Doctrine in FLOW3
PDF
How Git and Gerrit make you more productive
PDF
The agile future of a ponderous project
PDF
How Domain-Driven Design helps you to migrate into the future
PDF
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
PDF
Transparent Object Persistence (within FLOW3)
PDF
JavaScript for PHP Developers
PDF
Transparent Object Persistence with FLOW3
PDF
TDD (with FLOW3)
PDF
Implementing a JSR-283 Content Repository in PHP
PDF
Knowledge Management in der TYPO3 Community
PDF
Unicode & PHP6
PDF
Implementing a JSR-283 Content Repository in PHP
Updating Neos – Why, When and How - 2024 edition
The Perfect Neos Project Setup
Sawubona! Content Dimensions with Neos
Deploying TYPO3 Neos websites using Surf
Profiling TYPO3 Flow Applications
Using Document Databases with TYPO3 Flow
FLOW3-Workshop F3X12
Doctrine in FLOW3
How Git and Gerrit make you more productive
The agile future of a ponderous project
How Domain-Driven Design helps you to migrate into the future
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
Transparent Object Persistence (within FLOW3)
JavaScript for PHP Developers
Transparent Object Persistence with FLOW3
TDD (with FLOW3)
Implementing a JSR-283 Content Repository in PHP
Knowledge Management in der TYPO3 Community
Unicode & PHP6
Implementing a JSR-283 Content Repository in PHP

Recently uploaded (20)

PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
August Patch Tuesday
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Hybrid model detection and classification of lung cancer
PDF
Developing a website for English-speaking practice to English as a foreign la...
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
Modernising the Digital Integration Hub
PPT
What is a Computer? Input Devices /output devices
PDF
Architecture types and enterprise applications.pdf
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPT
Module 1.ppt Iot fundamentals and Architecture
A novel scalable deep ensemble learning framework for big data classification...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Getting started with AI Agents and Multi-Agent Systems
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Hindi spoken digit analysis for native and non-native speakers
Group 1 Presentation -Planning and Decision Making .pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
August Patch Tuesday
DP Operators-handbook-extract for the Mautical Institute
Hybrid model detection and classification of lung cancer
Developing a website for English-speaking practice to English as a foreign la...
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Assigned Numbers - 2025 - Bluetooth® Document
Programs and apps: productivity, graphics, security and other tools
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Modernising the Digital Integration Hub
What is a Computer? Input Devices /output devices
Architecture types and enterprise applications.pdf
Final SEM Unit 1 for mit wpu at pune .pptx
Module 1.ppt Iot fundamentals and Architecture

i18n and L10n in TYPO3 Flow

  • 1. i18n and L10n in TYPO3 Flow Karsten Dambekalns Inspiring people to share
  • 2. Karsten Dambekalns co-lead of TYPO3 Neos and Flow 35 years old lives in Lübeck, Germany 1 wife, 3 sons, 1 espresso machine likes canoeing and climbing Inspiring people to share
  • 3. Basics i18n is the process of making software localizable L10n means actually • formatting dates, numbers, … • translating text • adjusting other things (images, …) Inspiring people to share
  • 4. Locale Locale instances encapsulate a locale identifier Locales define the language and formats to use Locales form a hierarchy • en is a parent of en_US which is a parent of en_US_POSIX • Thus items for the en_US locale that do Inspiring people to share
  • 5. What you need A way to translate in templates A way to store translations of labels Formatters for dates, numbers, … An API for use in PHP Inspiring people to share
  • 6. f:translate the way of translating you will use most <f:translate id="my.label.1"/> {f:translate(id: 'my.label.1')} translation by label is possible, but discouraged • less reliable than id-based translation Inspiring people to share
  • 7. f:translate <f:translate id="my.label.1" source="Registration" package="Acme.Demo"/> <f:translate id="my.label.1" arguments="{0: 'hi'}" quantity="2"/> Inspiring people to share
  • 8. f:form.select has translation support built in <f:form.select options="{paymentOptions}" translate="{by: 'id'}" /> <f:form.select options="{paymentOptions}" translate="{by: 'id', prefix: 'payment.options.', package: 'Acme.Demo.Translations'}" /> Inspiring people to share
  • 9. Message catalogs XML Localisation Interchange File Format is the standard we use Looked up in well-known location Resources/ Private/ Translations/ <locale>/ <source>.xlf Inspiring people to share
  • 10. XLIFF basics An XLIFF file can hold translations for one locale It contains one or more <file> elements corresponding to a source Localizable data is stored in <trans-unit> elements which contain a <source> element to store the source text and a (non-mandatory) <target> Inspiring people to share
  • 11. <?xml version="1.0" encoding="UTF-8"?> <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> <file original="" product-name="Acme.Demo" source- language="en" datatype="plaintext"> <body> Text <trans-unit id="my.label.1" xml:space="preserve"> Text <source>My Label 1</source> </trans-unit> </body> </file> </xliff> Inspiring people to share
  • 12. <?xml version="1.0" encoding="UTF-8"?> <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> <file original="" product-name="Acme.Demo" source- language="en" datatype="plaintext"> <body> <trans-unit id="my.label.1" xml:space="preserve"> <source>My Label 1</source> <target>Mein Aufkleber 1</target> </trans-unit> </body> </file> </xliff> Inspiring people to share
  • 13. i18n configuration Default locale can be set in Settings.yaml Locale fallback rules are configurable TYPO3: Flow: i18n: defaultLocale: de fallbackRule: strict: FALSE order: [lv, en] Inspiring people to share
  • 14. i18n configuration Default locale can be set in Settings.yaml Locale fallback rules are configurable TYPO3: Flow: i18n: defaultLocale: de fallbackRule: strict: FALSE order: [lv, en] Inspiring people to share
  • 15. Placeholder use $this->view->assign('foo', 'QUUX'); $this->view->assign('bar', 'BAZ'); <f:translate id="my.label.3" arguments="{0: foo, 1: bar}"/> <trans-unit id="my.label.3" xml:space="preserve"> <source>I have {0} and {1}</source> <target>{1} habe ich und {0} habe ich auch</target> </trans-unit> Inspiring people to share
  • 16. String placeholders * will be available with Flow 2.0 $this->view->assign('foo', 'QUUX'); $this->view->assign('bar', 'BAZ'); <f:translate id="my.label.3" arguments="{'some': foo, 'thing': bar}"/> <trans-unit id="my.label.3" xml:space="preserve"> <source>I have {some} and {thing}</source> <target>{thing} habe ich und {some} habe ich auch</target> </trans-unit> Inspiring people to share
  • 17. Using formatters $this->view->assign('currentDateAndTime', new DateTime()); $this->view->assign('currentCost', 1.25); <f:translate id="my.label.4" arguments="{ 0: currentDateAndTime, 1: currentCost }"/> <source> At {0,datetime} it costs {1,number} monetary units </source> Inspiring people to share
  • 18. Plural forms The CLDR defines six plural forms • zero, one, two, few, many, other Different languages use more or less forms • singular and plurals for English • one, few and other for Polish • only other for Japanese Inspiring people to share
  • 19. Plural forms <f:translate id="my.label.6" quantity="{quarks->f:count()}"/> <group id="my.label.6" restype="x-gettext-plurals"> <trans-unit id="my.label.6[0]" xml:space="preserve"> <source>There is this quark</source> </trans-unit> <trans-unit id="my.label.6[1]" xml:space="preserve"> <source>There are these quarks</source> </trans-unit> </group> Inspiring people to share
  • 20. L10n of resources Resources can be localized as well The locale is part of the name • Image.png • Image.de.png • Image.lv.png Usable for all resources • Images, templates, … Inspiring people to share
  • 21. f:resource uses localized resources by default* <img src="{f:uri.resource(path: 'Images/Image.png')}"/> <img src="../../../../Resources/Public/Images/Image.png"/> * see Known Inspiring people to share
  • 22. i18n in PHP code TYPO3FlowI18nTranslator • translateById() • translateByOriginalLabel() TYPO3FlowI18nService • getConfiguration() • getLocalizedFilename() TYPO3FlowI18nFormatter* Inspiring people to share
  • 23. Setting current locale /** * @param string $locale * @return void */ public function selectAction($locale = NULL) { if ($locale !== NULL) { $this->i18nService->getConfiguration()->setCurrentLocale( new TYPO3FlowI18nLocale($locale) ); } WARN ING: $this->forward('index'); Stupid } ex ample Inspiring people to share
  • 24. Tips & Tricks Split catalogs at logical points Try to use.a.clever.id.system Avoid hardcoded labels from the start To change "original" labels simply translate to "original" language Inspiring people to share
  • 25. Known issues L10n support in f:resource VH pending in review Fallback per label is missing, currently only done per catalog Overriding parts of catalogs is missing Model translation still missing Inspiring people to share
  • 26. Thank You! These slides can be found at: http://speakerdeck.com/kdambekalns http://slideshare.net/kfish Give me feedback: karsten@typo3.org | karsten@dambekalns.de Download Flow: http://flow.typo3.org Follow me on twitter: @kdambekalns Support me using Inspiring people to share

Editor's Notes