SlideShare una empresa de Scribd logo
1 de 37
Descargar para leer sin conexión
Internationalization
Thomas Rabaix – Soleoweb SARL




                                Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Thomas Rabaix

•  freelance

•  symfony fan
   –  Conference #sflive09
   –  Book : more with symfony
   –  Plugins
      •  swFunctionalTestGenerationPlugin : generate ready-to-be-customized
         test skeletons in a matter of minutes
      •  swCrossLinkApplicationPlugin : add cross application link in your project
      •  sfSolrPlugin : integrates Solr into symfony framework.
      •  Many more



                                           Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
What is internationalization and localization ?




•  Internationalization



•  Localization




                               Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Culture ?


•  Culture is the addition of

   –  Language + Region

      •    fr : french
      •    fr_FR : french from France
      •    fr_BE : french from Belgium
      •    en_UK : english from United-Kingdom
      •    en_US : english from United-States




                                          Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
What elements can be i18n and l10n ?


•  Internationalization
   –  url : routing
   –  Model : doctrine + propel
   –  form : sfForm framework


•  Localization
   –  number
   –  currency
   –  date / time



                                  Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Internationalization


•  most of the i18n code is based on the Prado framework
•  ICU data has been updated on sf1.3 and sf1.4



•  edit your settings.yml and enable i18n options




                               Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Culture detection




                    Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Update culture




•  sfContext::getInstance()->getUser()->setCulture(‘fr’)



•  Notify the user.change_culture (does not change user’s
   culture)




                                Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Culture in URL


•  This is a feature built in the sfRouting class and
   symfony uses the value to update the user current
   culture.




•  example : /en/recipes/search => sf_culture = en




                               Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Creating i18n url


•  example
   –  /recettes/recherche
   –  /recipes/search


•  This is not a built in feature, however plugins or code
   can help you to create translated url.




                                 Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Solution 1 : ysfDimensionPlugin


•  You can create custom configuration files per dimension,
   –  a culture dimension with 'fr' or 'en'


•  then you just have to create :
   –  SF_APP_FOLDER/config/en/routing.yml
   –  SF_APP_FOLDER/config/fr/routing.yml


•  con: duplicate routes configurations on each routing.yml
   files and can be tricky to setup
•  pro : no performances overhead

                                              Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Solution 2 : custom code

•  Create a custom sfRouting class




•  Usage



                              Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Model definition


•  Propel and Doctrine both have built in feature to handle
   translation version

       Doctrine                                Propel




                                Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Model and culture


•  The default model culture value can be accessed
   through :
   –  sfDoctrineRecord::getDefaultCulture()
   –  sfPropel::getDefaultCulture()


•  The default model culture value can be updated
   through :
   –  sfDoctrineRecord::setDefaultCulture()
   –  sfPropel::setDefaultCulture()



                                    Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Model i18n properties

•  Accessing i18n property :
   –  always uses the default culture


•  Doctrine




•  Propel




                                        Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Model : query


•  ORM never automatically left join the translation table


•  Doctrine



•  Propel




                                Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Helpers – localization


•  NumberHelper:
  –  format_currency




  –  format_number




                         Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Helpers - DateHelper


•  format_date helper and format_datetime helper
  –  Output format (culture = en)



                                                           the	
  format_date	
  and	
  
                                                           date.me	
  helpers	
  
                                                           automa.cally	
  localize	
  
                                                           and	
  translate	
  date	
  
                                                           using	
  ICU	
  data	
  




                                    Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Helpers – DateHelper

•  format_daterange helper




•  distance_of_time_in_words helper




                             Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Helpers – I18n

•  __() helper



•  format_number_choice helper




                          Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Behind helpers



•  Helpers are just shortcut functions to internal class
   –  sfNumberFormat and sfDateFormat
   –  sfI18n




•  You can use these classes in your actions or custom lib
   –  Check out the symfony API




                                  Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
sfForm – i18n friendly widgets

•    the sfForm framework provides with many i18n widget :

      –    sfWidgetFormI18nChoiceCountry
      –    sfWidgetFormI18nChoiceCurrency
      –    sfWidgetFormI18nChoiceLanguage
      –    sfWidgetFormI18nChoiceTimezone
      –    sfWidgetFormI18nDate
      –    sfWidgetFormI18nDateTime
      –    sfWidgetFormI18nTime

•    And the related validator :
                                                                                                                                           zh	
  
      –  sfValidatorI18nChoiceTimezone
      –  sfValidatorI18nChoiceLanguage
      –  sfValidatorI18nChoiceCountry

                           All	
  these	
  widgets	
  accept	
  a	
  
                           culture	
  op.on	
  
                                                                                                                                          en	
  
                                                                   Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
sfForm - swCultureDemoForm




                                                                 Culture	
  is	
  set	
  in	
  
                                                                  the	
  controller	
  




                                                                    DO	
  NOT	
  USE	
  
                                                               sfContext::getInstance()	
  




                      Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
sfForm – elements translation


•  The sfForm has a translation callback function through the
   sfWidgetFormSchemaFormatter class



•  Label, error message, help messages are translated by
   using the callable method

•  warning : with sf1.3 and sf1.4 "choice" widgets which
   extends the sfWidgetFormChoiceBase class automatically
   translates choices provided when the widget is rendered.


                                  Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
sfForm + ORM


•  symfony provides an unified API between both ORM to
   handle i18n model.

•  If you need to build a form to edit translation from a
   model, you can use the `embedI18n` method
   –  method declared in the sfFromDoctrine and sfFormPropel




                                  Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
sfForm – backend form


•  Create a custom BaseForm[Doctrine|Propel] class in
   the backend/lib/form folder.




                              Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Translation management …


•  Sources available
   –  Gettext
   –  MySQL
   –  SQLite
   –  XLIFF


•  Not really user friendly




                              Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
… an alternative



•  mgI18nPlugin : interactive GUI to translate webpage

•  Open sourced by menugourmet.com : online quality
   recipes




                              Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
Menugourmet.com




                  Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
example




          Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
mgI18nPlugin - parameters


•  The plugin detects parameters in your translated
   message




                               Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
mgI18nPlugin


•  Display a popup to translate all messages used in the
   current page

•  Parse lib and actions to find message (handle
   catalogue)

•  All messages are stored in database




                               Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
mgI18nPlugin - tips


•  Cache is a key/value, so do not use a full text message.
   –  Smaller is your cache, quicker it will be loaded
   –  Use catalogue

•  Code message :
   –  The awesome recipes list => title_recipes


•  Always use a prefix :
   –  btn : btn_submit
   –  label : label_name
   –  link : link_to_homepage


                                         Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
mgI18nPlugin – configuration


•  read the famous README file

•  Tweak security




                            Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
mgI18nPlugin – tools

•  Import xliff into the database



•  unreachable messages




                                    Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
mgI18nPlugin – ROADMAP


•  Complete export database to xliff files

•  Remove Doctrine dependency, full PDO support

•  Simplify GUI




                                 Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  
QUESTIONS	
  ?	
  
                                                              Thomas	
  Rabaix	
  
                                                         hGp://www.soleoweb.com	
  




Images	
  references	
  	
  
	
  	
  -­‐	
  hGp://www.flickr.com/photos/photonoob/2164014945/	
  	
  
	
  	
  -­‐	
  hGp://www.flickr.com/photos/vermininc/2389710332/	
  
	
  	
  -­‐	
  hGp://www.flickr.com/photos/16175430@N02/3490488907/	
  
	
  	
  -­‐	
  hGp://www.flickr.com/photos/urville_djasim/2643449676/	
  
                                                                           Internationalization|	
  Thomas	
  Rabaix	
  –	
  h-p://www.soleoweb.com	
  

Más contenido relacionado

Destacado

Internationalization Process
Internationalization ProcessInternationalization Process
Internationalization ProcessLervin de la Rosa
 
International Entrepreneurship - Internationalization theories
International Entrepreneurship - Internationalization theoriesInternational Entrepreneurship - Internationalization theories
International Entrepreneurship - Internationalization theoriesSenthilKumar Mukund
 
Internationalisation ppt [repaired 2]
Internationalisation ppt [repaired 2]Internationalisation ppt [repaired 2]
Internationalisation ppt [repaired 2]Subhi Pradhan
 
Creating master and work repository
Creating master and work repositoryCreating master and work repository
Creating master and work repositoryRavi Kumar Lanke
 
Ncip Information
Ncip InformationNcip Information
Ncip InformationSue Bennett
 
Managing The Multi Sector Workforce
Managing The Multi Sector WorkforceManaging The Multi Sector Workforce
Managing The Multi Sector Workforceguest163bca0
 
W.K. Kellogg Foundation - Workforce Composition (2010)
W.K. Kellogg Foundation - Workforce Composition  (2010)W.K. Kellogg Foundation - Workforce Composition  (2010)
W.K. Kellogg Foundation - Workforce Composition (2010)W.K. Kellogg Foundation
 
小企業におけるSBS2003の活用
小企業におけるSBS2003の活用小企業におけるSBS2003の活用
小企業におけるSBS2003の活用Masaya Sawada
 
【デブサミ秋S8】データを活用したコンテンツ最適化のいろは
【デブサミ秋S8】データを活用したコンテンツ最適化のいろは【デブサミ秋S8】データを活用したコンテンツ最適化のいろは
【デブサミ秋S8】データを活用したコンテンツ最適化のいろはDevelopers Summit
 
Reference Letters
Reference LettersReference Letters
Reference Lettershenryremiz
 
Go Beyond STATisfaction
Go Beyond STATisfactionGo Beyond STATisfaction
Go Beyond STATisfactionkelleyaranda
 
Water Resources In The Usa
Water Resources In The UsaWater Resources In The Usa
Water Resources In The UsaAnoudAlThani
 
Как работать с маркетинговыми кейсами
Как работать с маркетинговыми кейсамиКак работать с маркетинговыми кейсами
Как работать с маркетинговыми кейсамиSegrey Nikishov - @n_grey
 

Destacado (20)

Ppt on online voting
Ppt on online votingPpt on online voting
Ppt on online voting
 
Internationalisation process in developed and developing countries
Internationalisation process in developed and developing countriesInternationalisation process in developed and developing countries
Internationalisation process in developed and developing countries
 
Internationalization Process
Internationalization ProcessInternationalization Process
Internationalization Process
 
International Entrepreneurship - Internationalization theories
International Entrepreneurship - Internationalization theoriesInternational Entrepreneurship - Internationalization theories
International Entrepreneurship - Internationalization theories
 
Internationalisation ppt [repaired 2]
Internationalisation ppt [repaired 2]Internationalisation ppt [repaired 2]
Internationalisation ppt [repaired 2]
 
Creating master and work repository
Creating master and work repositoryCreating master and work repository
Creating master and work repository
 
Endocrine System
Endocrine  SystemEndocrine  System
Endocrine System
 
Ncip Information
Ncip InformationNcip Information
Ncip Information
 
Track & Field
Track & FieldTrack & Field
Track & Field
 
Managing The Multi Sector Workforce
Managing The Multi Sector WorkforceManaging The Multi Sector Workforce
Managing The Multi Sector Workforce
 
W.K. Kellogg Foundation - Workforce Composition (2010)
W.K. Kellogg Foundation - Workforce Composition  (2010)W.K. Kellogg Foundation - Workforce Composition  (2010)
W.K. Kellogg Foundation - Workforce Composition (2010)
 
小企業におけるSBS2003の活用
小企業におけるSBS2003の活用小企業におけるSBS2003の活用
小企業におけるSBS2003の活用
 
【デブサミ秋S8】データを活用したコンテンツ最適化のいろは
【デブサミ秋S8】データを活用したコンテンツ最適化のいろは【デブサミ秋S8】データを活用したコンテンツ最適化のいろは
【デブサミ秋S8】データを活用したコンテンツ最適化のいろは
 
Fiturtech.2011
Fiturtech.2011Fiturtech.2011
Fiturtech.2011
 
Wat kan Agentschap NL de Rgd bieden in gesprek met de klant
Wat kan Agentschap NL de Rgd bieden in gesprek met de klantWat kan Agentschap NL de Rgd bieden in gesprek met de klant
Wat kan Agentschap NL de Rgd bieden in gesprek met de klant
 
Anwb en duurzame huisvesting
Anwb en duurzame huisvestingAnwb en duurzame huisvesting
Anwb en duurzame huisvesting
 
Reference Letters
Reference LettersReference Letters
Reference Letters
 
Go Beyond STATisfaction
Go Beyond STATisfactionGo Beyond STATisfaction
Go Beyond STATisfaction
 
Water Resources In The Usa
Water Resources In The UsaWater Resources In The Usa
Water Resources In The Usa
 
Как работать с маркетинговыми кейсами
Как работать с маркетинговыми кейсамиКак работать с маркетинговыми кейсами
Как работать с маркетинговыми кейсами
 

Similar a Internationalization with the symfony framework

Integrating the Solr search engine
Integrating the Solr search engineIntegrating the Solr search engine
Integrating the Solr search engineth0masr
 
Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3Fabien Potencier
 
Using VIM for PHP/Symfony development
Using VIM for PHP/Symfony developmentUsing VIM for PHP/Symfony development
Using VIM for PHP/Symfony developmentCarlos Mafla
 
Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Fabien Potencier
 
Phil Ritchie | Putting Standards into Action: Multilingual and Semantic Enric...
Phil Ritchie | Putting Standards into Action: Multilingual and Semantic Enric...Phil Ritchie | Putting Standards into Action: Multilingual and Semantic Enric...
Phil Ritchie | Putting Standards into Action: Multilingual and Semantic Enric...semanticsconference
 
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!ifPeople
 
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Mark Hamstra
 
DDAY2014 - Localizing Drupal Commerce
DDAY2014 - Localizing Drupal CommerceDDAY2014 - Localizing Drupal Commerce
DDAY2014 - Localizing Drupal CommerceDrupalDay
 
Lean and Collaborative Content - Workshop
Lean and Collaborative Content - WorkshopLean and Collaborative Content - Workshop
Lean and Collaborative Content - WorkshopIXIASOFT
 
SCAPE Webinar: Tools for uncovering preservation risks in large repositories
SCAPE Webinar: Tools for uncovering preservation risks in large repositoriesSCAPE Webinar: Tools for uncovering preservation risks in large repositories
SCAPE Webinar: Tools for uncovering preservation risks in large repositoriesSCAPE Project
 
FuelPHP - a PHP HMVC Framework by silicongulf.com
FuelPHP - a PHP HMVC Framework by silicongulf.comFuelPHP - a PHP HMVC Framework by silicongulf.com
FuelPHP - a PHP HMVC Framework by silicongulf.comChristopher Cubos
 
How to start developing your own ExpressionEngine addons
How to start developing your own ExpressionEngine addonsHow to start developing your own ExpressionEngine addons
How to start developing your own ExpressionEngine addonsLeevi Graham
 
Automation with phing
Automation with phingAutomation with phing
Automation with phingJoey Rivera
 
Python the lingua franca of FEWS
Python the lingua franca of FEWSPython the lingua franca of FEWS
Python the lingua franca of FEWSLindsay Millard
 
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiSymfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiMichele Orselli
 
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiSymfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiManuel Baldassarri
 
Composer - The missing package manager for PHP
Composer - The missing package manager for PHPComposer - The missing package manager for PHP
Composer - The missing package manager for PHPTareq Hasan
 

Similar a Internationalization with the symfony framework (20)

Integrating the Solr search engine
Integrating the Solr search engineIntegrating the Solr search engine
Integrating the Solr search engine
 
Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3
 
Using VIM for PHP/Symfony development
Using VIM for PHP/Symfony developmentUsing VIM for PHP/Symfony development
Using VIM for PHP/Symfony development
 
Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009
 
OAI9 OMP workshop
OAI9 OMP workshopOAI9 OMP workshop
OAI9 OMP workshop
 
Phil Ritchie | Putting Standards into Action: Multilingual and Semantic Enric...
Phil Ritchie | Putting Standards into Action: Multilingual and Semantic Enric...Phil Ritchie | Putting Standards into Action: Multilingual and Semantic Enric...
Phil Ritchie | Putting Standards into Action: Multilingual and Semantic Enric...
 
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!
 
Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3
 
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
 
DDAY2014 - Localizing Drupal Commerce
DDAY2014 - Localizing Drupal CommerceDDAY2014 - Localizing Drupal Commerce
DDAY2014 - Localizing Drupal Commerce
 
Lean and Collaborative Content - Workshop
Lean and Collaborative Content - WorkshopLean and Collaborative Content - Workshop
Lean and Collaborative Content - Workshop
 
SCAPE Webinar: Tools for uncovering preservation risks in large repositories
SCAPE Webinar: Tools for uncovering preservation risks in large repositoriesSCAPE Webinar: Tools for uncovering preservation risks in large repositories
SCAPE Webinar: Tools for uncovering preservation risks in large repositories
 
FuelPHP - a PHP HMVC Framework by silicongulf.com
FuelPHP - a PHP HMVC Framework by silicongulf.comFuelPHP - a PHP HMVC Framework by silicongulf.com
FuelPHP - a PHP HMVC Framework by silicongulf.com
 
How to start developing your own ExpressionEngine addons
How to start developing your own ExpressionEngine addonsHow to start developing your own ExpressionEngine addons
How to start developing your own ExpressionEngine addons
 
Automation with phing
Automation with phingAutomation with phing
Automation with phing
 
Python the lingua franca of FEWS
Python the lingua franca of FEWSPython the lingua franca of FEWS
Python the lingua franca of FEWS
 
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiSymfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
 
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiSymfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
 
Composer - The missing package manager for PHP
Composer - The missing package manager for PHPComposer - The missing package manager for PHP
Composer - The missing package manager for PHP
 
Publishing Linked Data from RDB
Publishing Linked Data from RDBPublishing Linked Data from RDB
Publishing Linked Data from RDB
 

Último

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 

Último (20)

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 

Internationalization with the symfony framework

  • 1. Internationalization Thomas Rabaix – Soleoweb SARL Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 2. Thomas Rabaix •  freelance •  symfony fan –  Conference #sflive09 –  Book : more with symfony –  Plugins •  swFunctionalTestGenerationPlugin : generate ready-to-be-customized test skeletons in a matter of minutes •  swCrossLinkApplicationPlugin : add cross application link in your project •  sfSolrPlugin : integrates Solr into symfony framework. •  Many more Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 3. What is internationalization and localization ? •  Internationalization •  Localization Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 4. Culture ? •  Culture is the addition of –  Language + Region •  fr : french •  fr_FR : french from France •  fr_BE : french from Belgium •  en_UK : english from United-Kingdom •  en_US : english from United-States Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 5. What elements can be i18n and l10n ? •  Internationalization –  url : routing –  Model : doctrine + propel –  form : sfForm framework •  Localization –  number –  currency –  date / time Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 6. Internationalization •  most of the i18n code is based on the Prado framework •  ICU data has been updated on sf1.3 and sf1.4 •  edit your settings.yml and enable i18n options Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 7. Culture detection Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 8. Update culture •  sfContext::getInstance()->getUser()->setCulture(‘fr’) •  Notify the user.change_culture (does not change user’s culture) Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 9. Culture in URL •  This is a feature built in the sfRouting class and symfony uses the value to update the user current culture. •  example : /en/recipes/search => sf_culture = en Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 10. Creating i18n url •  example –  /recettes/recherche –  /recipes/search •  This is not a built in feature, however plugins or code can help you to create translated url. Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 11. Solution 1 : ysfDimensionPlugin •  You can create custom configuration files per dimension, –  a culture dimension with 'fr' or 'en' •  then you just have to create : –  SF_APP_FOLDER/config/en/routing.yml –  SF_APP_FOLDER/config/fr/routing.yml •  con: duplicate routes configurations on each routing.yml files and can be tricky to setup •  pro : no performances overhead Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 12. Solution 2 : custom code •  Create a custom sfRouting class •  Usage Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 13. Model definition •  Propel and Doctrine both have built in feature to handle translation version Doctrine Propel Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 14. Model and culture •  The default model culture value can be accessed through : –  sfDoctrineRecord::getDefaultCulture() –  sfPropel::getDefaultCulture() •  The default model culture value can be updated through : –  sfDoctrineRecord::setDefaultCulture() –  sfPropel::setDefaultCulture() Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 15. Model i18n properties •  Accessing i18n property : –  always uses the default culture •  Doctrine •  Propel Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 16. Model : query •  ORM never automatically left join the translation table •  Doctrine •  Propel Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 17. Helpers – localization •  NumberHelper: –  format_currency –  format_number Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 18. Helpers - DateHelper •  format_date helper and format_datetime helper –  Output format (culture = en) the  format_date  and   date.me  helpers   automa.cally  localize   and  translate  date   using  ICU  data   Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 19. Helpers – DateHelper •  format_daterange helper •  distance_of_time_in_words helper Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 20. Helpers – I18n •  __() helper •  format_number_choice helper Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 21. Behind helpers •  Helpers are just shortcut functions to internal class –  sfNumberFormat and sfDateFormat –  sfI18n •  You can use these classes in your actions or custom lib –  Check out the symfony API Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 22. sfForm – i18n friendly widgets •  the sfForm framework provides with many i18n widget : –  sfWidgetFormI18nChoiceCountry –  sfWidgetFormI18nChoiceCurrency –  sfWidgetFormI18nChoiceLanguage –  sfWidgetFormI18nChoiceTimezone –  sfWidgetFormI18nDate –  sfWidgetFormI18nDateTime –  sfWidgetFormI18nTime •  And the related validator : zh   –  sfValidatorI18nChoiceTimezone –  sfValidatorI18nChoiceLanguage –  sfValidatorI18nChoiceCountry All  these  widgets  accept  a   culture  op.on   en   Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 23. sfForm - swCultureDemoForm Culture  is  set  in   the  controller   DO  NOT  USE   sfContext::getInstance()   Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 24. sfForm – elements translation •  The sfForm has a translation callback function through the sfWidgetFormSchemaFormatter class •  Label, error message, help messages are translated by using the callable method •  warning : with sf1.3 and sf1.4 "choice" widgets which extends the sfWidgetFormChoiceBase class automatically translates choices provided when the widget is rendered. Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 25. sfForm + ORM •  symfony provides an unified API between both ORM to handle i18n model. •  If you need to build a form to edit translation from a model, you can use the `embedI18n` method –  method declared in the sfFromDoctrine and sfFormPropel Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 26. sfForm – backend form •  Create a custom BaseForm[Doctrine|Propel] class in the backend/lib/form folder. Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 27. Translation management … •  Sources available –  Gettext –  MySQL –  SQLite –  XLIFF •  Not really user friendly Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 28. … an alternative •  mgI18nPlugin : interactive GUI to translate webpage •  Open sourced by menugourmet.com : online quality recipes Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 29. Menugourmet.com Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 30. example Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 31. mgI18nPlugin - parameters •  The plugin detects parameters in your translated message Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 32. mgI18nPlugin •  Display a popup to translate all messages used in the current page •  Parse lib and actions to find message (handle catalogue) •  All messages are stored in database Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 33. mgI18nPlugin - tips •  Cache is a key/value, so do not use a full text message. –  Smaller is your cache, quicker it will be loaded –  Use catalogue •  Code message : –  The awesome recipes list => title_recipes •  Always use a prefix : –  btn : btn_submit –  label : label_name –  link : link_to_homepage Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 34. mgI18nPlugin – configuration •  read the famous README file •  Tweak security Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 35. mgI18nPlugin – tools •  Import xliff into the database •  unreachable messages Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 36. mgI18nPlugin – ROADMAP •  Complete export database to xliff files •  Remove Doctrine dependency, full PDO support •  Simplify GUI Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com  
  • 37. QUESTIONS  ?   Thomas  Rabaix   hGp://www.soleoweb.com   Images  references        -­‐  hGp://www.flickr.com/photos/photonoob/2164014945/        -­‐  hGp://www.flickr.com/photos/vermininc/2389710332/      -­‐  hGp://www.flickr.com/photos/16175430@N02/3490488907/      -­‐  hGp://www.flickr.com/photos/urville_djasim/2643449676/   Internationalization|  Thomas  Rabaix  –  h-p://www.soleoweb.com