SlideShare a Scribd company logo
1 of 27
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

What's hot

perl usage at database applications
perl usage at database applicationsperl usage at database applications
perl usage at database applications
Joe Jiang
 
Php Simple Xml
Php Simple XmlPhp Simple Xml
Php Simple Xml
mussawir20
 

What's hot (19)

PHP
PHP PHP
PHP
 
perl usage at database applications
perl usage at database applicationsperl usage at database applications
perl usage at database applications
 
Introduction to perl_ a scripting language
Introduction to perl_ a scripting languageIntroduction to perl_ a scripting language
Introduction to perl_ a scripting language
 
Introduction To Php For Wit2009
Introduction To Php For Wit2009Introduction To Php For Wit2009
Introduction To Php For Wit2009
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Php Simple Xml
Php Simple XmlPhp Simple Xml
Php Simple Xml
 
Puppet Camp Berlin 2015: Martin Alfke | The Power of Puppet 4
Puppet Camp Berlin 2015: Martin Alfke | The Power of Puppet 4Puppet Camp Berlin 2015: Martin Alfke | The Power of Puppet 4
Puppet Camp Berlin 2015: Martin Alfke | The Power of Puppet 4
 
Perl
PerlPerl
Perl
 
Perl tutorial
Perl tutorialPerl tutorial
Perl tutorial
 
PHP - Introduction to PHP
PHP -  Introduction to PHPPHP -  Introduction to PHP
PHP - Introduction to PHP
 
DBIx::Class beginners
DBIx::Class beginnersDBIx::Class beginners
DBIx::Class beginners
 
Further Php
Further PhpFurther Php
Further Php
 
Perl
PerlPerl
Perl
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Was können wir von Rebol lernen?
Was können wir von Rebol lernen?Was können wir von Rebol lernen?
Was können wir von Rebol lernen?
 
DBIx::Class introduction - 2010
DBIx::Class introduction - 2010DBIx::Class introduction - 2010
DBIx::Class introduction - 2010
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
 
slidesharenew1
slidesharenew1slidesharenew1
slidesharenew1
 

Viewers also liked

April 19 social marketing & yr business
April 19 social marketing & yr businessApril 19 social marketing & yr business
April 19 social marketing & yr business
Hack the Hood
 
My Works About UT Plan (draft) 2004
My Works About UT Plan (draft) 2004My Works About UT Plan (draft) 2004
My Works About UT Plan (draft) 2004
Ruby Kuo
 
4.3 My Works About Operation
4.3 My Works About Operation4.3 My Works About Operation
4.3 My Works About Operation
Ruby Kuo
 
Hex Colors At A Glance
Hex Colors At A GlanceHex Colors At A Glance
Hex Colors At A Glance
Dino Baskovic
 
Do The Adverts Fool Us
Do The Adverts Fool UsDo The Adverts Fool Us
Do The Adverts Fool Us
jordi
 

Viewers also liked (20)

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

Similar to i18n and L10n in TYPO3 Flow

Advanced Internationalization with Rails
Advanced Internationalization with RailsAdvanced Internationalization with Rails
Advanced Internationalization with Rails
Clinton Dreisbach
 
Tml for Laravel
Tml for LaravelTml for Laravel
Tml for Laravel
Michael Berkovich
 
Solr Application Development Tutorial
Solr Application Development TutorialSolr Application Development Tutorial
Solr Application Development Tutorial
Erik Hatcher
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
pooja bhandari
 

Similar to i18n and L10n in TYPO3 Flow (20)

Schulung Fluid Templating
Schulung Fluid TemplatingSchulung Fluid Templating
Schulung Fluid Templating
 
Python master class part 1
Python master class part 1Python master class part 1
Python master class part 1
 
Filesystems Lisbon 2018
Filesystems Lisbon 2018Filesystems Lisbon 2018
Filesystems Lisbon 2018
 
Bioinformatica p6-bioperl
Bioinformatica p6-bioperlBioinformatica p6-bioperl
Bioinformatica p6-bioperl
 
How to make multilingual plugins and themes
How to make multilingual plugins and themesHow to make multilingual plugins and themes
How to make multilingual plugins and themes
 
Advanced Internationalization with Rails
Advanced Internationalization with RailsAdvanced Internationalization with Rails
Advanced Internationalization with Rails
 
Bioinformatics p5-bioperl v2013-wim_vancriekinge
Bioinformatics p5-bioperl v2013-wim_vancriekingeBioinformatics p5-bioperl v2013-wim_vancriekinge
Bioinformatics p5-bioperl v2013-wim_vancriekinge
 
WordPress Plugin Localization
WordPress Plugin LocalizationWordPress Plugin Localization
WordPress Plugin Localization
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
Tml for Laravel
Tml for LaravelTml for Laravel
Tml for Laravel
 
TYPO3 meets XLIFF + reST
TYPO3 meets XLIFF + reSTTYPO3 meets XLIFF + reST
TYPO3 meets XLIFF + reST
 
Solr Application Development Tutorial
Solr Application Development TutorialSolr Application Development Tutorial
Solr Application Development Tutorial
 
Fluent Development with FLOW3
Fluent Development with FLOW3Fluent Development with FLOW3
Fluent Development with FLOW3
 
Nessus and Reporting Karma
Nessus and Reporting KarmaNessus and Reporting Karma
Nessus and Reporting Karma
 
Aidan's PhD Viva
Aidan's PhD VivaAidan's PhD Viva
Aidan's PhD Viva
 
php fundamental
php fundamentalphp fundamental
php fundamental
 
php
phpphp
php
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
 
Tricks in natural language processing
Tricks in natural language processingTricks in natural language processing
Tricks in natural language processing
 
Spsl by sasidhar 3 unit
Spsl by sasidhar  3 unitSpsl by sasidhar  3 unit
Spsl by sasidhar 3 unit
 

More from Karsten Dambekalns

The agile future of a ponderous project
The agile future of a ponderous projectThe agile future of a ponderous project
The agile future of a ponderous project
Karsten Dambekalns
 
How Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the futureHow Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the future
Karsten Dambekalns
 
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 PhoenixContent Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
Karsten Dambekalns
 

More from Karsten Dambekalns (20)

The Perfect Neos Project Setup
The Perfect Neos Project SetupThe Perfect Neos Project Setup
The Perfect Neos Project Setup
 
Sawubona! Content Dimensions with Neos
Sawubona! Content Dimensions with NeosSawubona! Content Dimensions with Neos
Sawubona! Content Dimensions with Neos
 
Deploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using SurfDeploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using Surf
 
Profiling TYPO3 Flow Applications
Profiling TYPO3 Flow ApplicationsProfiling TYPO3 Flow Applications
Profiling TYPO3 Flow Applications
 
Using Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 FlowUsing Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 Flow
 
FLOW3-Workshop F3X12
FLOW3-Workshop F3X12FLOW3-Workshop F3X12
FLOW3-Workshop F3X12
 
Doctrine in FLOW3
Doctrine in FLOW3Doctrine in FLOW3
Doctrine in FLOW3
 
How Git and Gerrit make you more productive
How Git and Gerrit make you more productiveHow Git and Gerrit make you more productive
How Git and Gerrit make you more productive
 
The agile future of a ponderous project
The agile future of a ponderous projectThe agile future of a ponderous project
The agile future of a ponderous project
 
How Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the futureHow Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the future
 
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 PhoenixContent Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
 
Transparent Object Persistence (within FLOW3)
Transparent Object Persistence (within FLOW3)Transparent Object Persistence (within FLOW3)
Transparent Object Persistence (within FLOW3)
 
JavaScript for PHP Developers
JavaScript for PHP DevelopersJavaScript for PHP Developers
JavaScript for PHP Developers
 
Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3
 
TDD (with FLOW3)
TDD (with FLOW3)TDD (with FLOW3)
TDD (with FLOW3)
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHP
 
Knowledge Management in der TYPO3 Community
Knowledge Management in der TYPO3 CommunityKnowledge Management in der TYPO3 Community
Knowledge Management in der TYPO3 Community
 
Unicode & PHP6
Unicode & PHP6Unicode & PHP6
Unicode & PHP6
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHP
 
Introduction to Source Code Management
Introduction to Source Code ManagementIntroduction to Source Code Management
Introduction to Source Code Management
 

Recently uploaded

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Recently uploaded (20)

WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 

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

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n