SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Downloaden Sie, um offline zu lesen
Backstage with Drupal localization

  Gábor Hojtsy & Jose Reyero
                               26. aug 14:45
                               VPS.NET 18
TRANSLATING
THE BUILT-IN
 INTERFACE
TEXT COMES FROM
  SOURCE CODE
D!"#$% 6 Ch!$for new versions at hojtsy.hu – Freely redistri
                                                                                                                                                          y Gábor Hojtsy –
                                                                                              ion API
                                                                       JavaScript translat                         to the
                                                                                                Translates ‘Home’ ge display.
                  ion API                                                                   e’) language used fo r pa
Core PHP translat                                     to the                  Drupal.t(‘Hom
                                  Translates ‘Home’
                t(‘Home’) requested language.                                                                                   lation            for
                                                                                           Plural Returns the proper trans
                                                                           Drupal.format                                    ral rules in
                                   Returns the proper                                     (count, the text based on plu
         format_plural




                                                                                                                                                                        & '(%$&)*'
                                                          sed                                                           age.
                                    lation for the text ba                         ‘1 comment’, the page’s langu




                                                                                                                                                                          eck
                ($count, trans              les in the                                       ents’)
           ‘1 comment’,
                               on plural ru                                 ‘@count comm
                        ts’) requested
                                           language.                                                                 can be provided,
    ‘@count comm
                     en                                                                             placements array
                                                                                Optional variable realways the page language!
                                                  and                                 language is




                                                                                                                                                                                                                                                               GET THE
                               placements array
           Optional variable re provided in this order.                                                                 acters)
         language code ca
                            n be                                                                    ased on prefix char
                                                                            Repla cement formats (b
                                                                                                                     value escaped with
                    ns using      translation features                                          Replaced with the ut.
  Other PHP functio                                                                  @count check_plain() for outp
               format_date Translates parts
                                            of the




                                                                                                                                                                                                 +,-$& (,--&bu. ble as long as credit is kept.
                                                                                                                                         d
                                                                                                                      value escaped an
              ($tim estamp, date/time formatting.                                                Replaced with the            r (theme
               'medium', ...)                                                                            ted as a placeholde
                                                                                       %size format
                                                  interval in                                           eholder’)).




                                                                                                                                                                                                                                                           CHEAT SHEET
                               Displays the time                                                  (‘plac
                                                 anslates                                                                                  t
                            l
           format_interva human terms.
                                              Tr                                                                       value as is, withou
                            )                   gments.                                            Replaced with the ting. Insecure! Only
          ($ timestamp, ... names of the se                                                                  ional format
                                                                                        !html any additu already sanitized your text.
                                                    provided                                            use if yo
                                Formats a file size e MB,                                                                         y(
                                     tes. Translates th                                                            irectory’, arra
                     ize, ...) in by                                                                me moved to @d
      format_size($s                                                                Example: t(‘%na                  y’ => $dirnam
                                                                                                                                   e);




                                                                                                                                                                                                                            ta
                                                     .
                                KB and byte labels                                                    me, ‘@director




                                                                                                                                                                                                                              1.1 - '*.-/0
                                                                                   ‘%na me’ => $filena
                                                    e code at   the end.




                                                                                                                                                                                                                                                                 FROM
                                an optional languag
         All functions accept                                                                         the installer
                                                                               Translating text in
                                            ed later                                                                       y as t(), but
                         translation and us                                                          Works the same wa ckend. Use
      Text extracted for                                                                                               ory ba
                                                         e;
                                     Module/theme nam name.                                          uses a file+mem
                                                                                                                           and in install
                       .info files description; package                                    st(‘Home’) only in the installer
                                                                                                                         support.
                                                                                                     profiles. No plural
                                                         names,
                                      Literal permission       ard
                  hook_p    erm() when provided with stand                                                                     ll files and any




                                                                                                                                                                                                                                            -! 15. 2007.
                                                                                                                                                                                                                                                             HOJTSY.HU
                                 ns array syntax.                                                       Use get_t() in .insta
              implementatio                                                                                                  could run in the
                                                                                                        other code which s ‘t’ or ‘st’
                                                                                          $t = get_t(); installer too. It retu nction to be
                                                               d                                                              rn
                                           Menu item ‘title’ an en                                                            fu
                   hook_menu() ‘description’ keys
                                                   , wh                                    $t (‘Home’); depending on the
                                                   l strings.                                                                   t.
                impl ementations provided as litera                                                      used at the momen
                                                      sage,
                                   Log type and mes ral                                                                                                       ur
                                                                                                                                           use translation, yo le
                                         provided as lite                                                             ll file and need to
                                   when                                              Remember: if   you have an .insta running in the installer if your modu
                               u’, strings. Third parameter                                               easily end up                         e get_t()!
                watchdog(‘men                                                        function calls could core module in an install profile. Us
                             calls specifies the replacements                                become   sa
              ‘Items saved’)                           pport.
                                    array. No plural su

                                                                                                                                         bal context,
                               mistakes                                                                             Usage of t() in a glo ST’, t(‘...’)). The
          The most common                                                    e message eg. for                      such as define(  ‘CON
                                                type).    Reuse of the sam                                                               t yet initialized at
                              lues, such as t($                                       t_message()                   locale system is no e is incorrect
           Using dynamic va                                        g() and drupal_se
                                          strings to call watchdo               allows t(), the later                                     ag
                                 dynamic
           Whenever you use make sure that all                                                                      that time, so this us




                                                                                                                                                                                                                                                               ALSO SEE
                                  ,                       calls. The former dis t possible.                                       ds to nasty perform
                                                                                                                                                          ance
           the above functions eady in the code                                is no
                                                          requires t(), so this e API functions                      and also lea
                                                                                                                                            it.
           po ssible values are alr using the API.         Always  call the abov                                     problems. Never do
                                l form                                       indirection.
            elsewhere in litera       ovided content.      directly, without
                                 user pr
            Do not translate
                                                                                                                         pport, so
                                                 e API properly                                     r module plugin su
             Tools to verify you
                                 are using th                               er versions have code ws. Also feel free to export a
                                                       Drupal 6.x-2 or lat                        revie
                                                                             e API is reported in                       ings appear.
                                                        improper use of th ule/theme and check whether all str


                                                                                                                                                                                                                                                            D.O/NODE/322729
                                      rg/proje ct/potx                        od
                      http://drupal.o                   template for your m                                              use t() or some
                                                                                                    when you forgot to
                                                                               nnot find mistakes e localization client has a
                                                         The potx module ca late your output. Th
                                                                               ns                                       ge. If certain
                                                         other function to tra to translate text displayed on the pa the API.
                                rg/project/l10n
                                                _client convenient interface                           , you forgot to use
                http://drupal.o                                                 ing up for translation
                                                          str ings are not show
TEXT IS FOUND
 AND REPLACED
RUNTIME, WHEN
     USED
TRANSLATIONS
   ARE STORED
IN THE DATABASE
Running
source code
Running
source code
               Found text
              stored in DB
Running
source code
                 Found text
                stored in DB


               User interface
              to translate text,
                stored in DB
Running
 source code
                      Found text
                     stored in DB


Text replaced on    User interface
     output        to translate text,
                     stored in DB
Static
source code
Static
source code


 Gettext
.pot (CVS)
Static
source code


 Gettext
.pot (CVS)
Static
source code


 Gettext
.pot (CVS)


Translated
 .po (CVS)
Static
source code


 Gettext
.pot (CVS)


Translated
 .po (CVS)
Static
source code


 Gettext
.pot (CVS)


Translated
 .po (CVS)
Static
source code


 Gettext
 Database
.pot (CVS)


Translated
 .po (CVS)
Static
source code
  Automation


 Gettext
 Database
.pot (CVS)


Translated
 .po (CVS)
Static
source code
  Automation


 Gettext
 Database
.pot (CVS)
   Web UI




Translated
 .po (CVS)
Static
source code
  Automation


 Gettext
 Database
.pot (CVS)
   Web UI




Translated
 .po (CVS)
      (FTP)
Static
source code
  Automation


 Gettext
 Database
.pot (CVS)
   Web UI

  Automation


Translated
 .po (CVS)
      (FTP)
Static
        source code
              Automation


              Gettext
              Database
             .pot (CVS)
                Web UI

Contribute
              Automation


         Translated
          .po (CVS)
               (FTP)
Static
         source code
              Automation


              Gettext
              Database
             .pot (CVS)
                Web UI

Contribute
              Automation


         Translated
  Pull    .po (CVS)
               (FTP)
over             almost


6700             14000
projects known   releases parsed
over


219000
 strings to translate
219000
LIKE TRANSLATING
 DRUPAL 34 TIMES
71
TRANSLATION
   TEAMS
OVER

 1700
CONTRIBUTORS
http://cph2010.drupal.org/node/8808

Weitere ähnliche Inhalte

Mehr von Gábor Hojtsy

Doing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon LondonDoing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon London
Gábor Hojtsy
 

Mehr von Gábor Hojtsy (17)

Open source project management at scale
 Open source project management at scale Open source project management at scale
Open source project management at scale
 
Drupal 8.3.0: the features are ready, are you?
Drupal 8.3.0: the features are ready, are you?Drupal 8.3.0: the features are ready, are you?
Drupal 8.3.0: the features are ready, are you?
 
Drupal 8 multilingual APIs
Drupal 8 multilingual APIsDrupal 8 multilingual APIs
Drupal 8 multilingual APIs
 
A Drupal 8 jövője és az oda vezető út
A Drupal 8 jövője és az oda vezető útA Drupal 8 jövője és az oda vezető út
A Drupal 8 jövője és az oda vezető út
 
Everything multilingual in Drupal 8
Everything multilingual in Drupal 8Everything multilingual in Drupal 8
Everything multilingual in Drupal 8
 
Everything multilingual in Drupal 8 (2015 November)
Everything multilingual in Drupal 8 (2015 November)Everything multilingual in Drupal 8 (2015 November)
Everything multilingual in Drupal 8 (2015 November)
 
All the language support in Drupal 8 - At Drupalaton 2014
All the language support in Drupal 8 - At Drupalaton 2014All the language support in Drupal 8 - At Drupalaton 2014
All the language support in Drupal 8 - At Drupalaton 2014
 
Drupal 8 Multilingual - what to look forward to
Drupal 8 Multilingual - what to look forward toDrupal 8 Multilingual - what to look forward to
Drupal 8 Multilingual - what to look forward to
 
Doing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon LondonDoing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon London
 
Multilingual Drupal
Multilingual DrupalMultilingual Drupal
Multilingual Drupal
 
Doing Drupal security right
Doing Drupal security rightDoing Drupal security right
Doing Drupal security right
 
Come for the software, stay for the community
Come for the software, stay for the communityCome for the software, stay for the community
Come for the software, stay for the community
 
Come for the software, stay for the community - How Drupal improves and evolves
Come for the software, stay for the community - How Drupal improves and evolvesCome for the software, stay for the community - How Drupal improves and evolves
Come for the software, stay for the community - How Drupal improves and evolves
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp Bratislava
 
Drupal Security from Drupalcamp Cologne 2009
Drupal Security from Drupalcamp Cologne 2009Drupal Security from Drupalcamp Cologne 2009
Drupal Security from Drupalcamp Cologne 2009
 
What's up with Drupal 7?
What's up with Drupal 7?What's up with Drupal 7?
What's up with Drupal 7?
 
Multilingual Drupal presentation from "Do it With Drupal"
Multilingual Drupal presentation from "Do it With Drupal"Multilingual Drupal presentation from "Do it With Drupal"
Multilingual Drupal presentation from "Do it With Drupal"
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Backstage with Drupal localization - Part 1

  • 1. Backstage with Drupal localization Gábor Hojtsy & Jose Reyero 26. aug 14:45 VPS.NET 18
  • 3. TEXT COMES FROM SOURCE CODE
  • 4. D!"#$% 6 Ch!$for new versions at hojtsy.hu – Freely redistri y Gábor Hojtsy – ion API JavaScript translat to the Translates ‘Home’ ge display. ion API e’) language used fo r pa Core PHP translat to the Drupal.t(‘Hom Translates ‘Home’ t(‘Home’) requested language. lation for Plural Returns the proper trans Drupal.format ral rules in Returns the proper (count, the text based on plu format_plural & '(%$&)*' sed age. lation for the text ba ‘1 comment’, the page’s langu eck ($count, trans les in the ents’) ‘1 comment’, on plural ru ‘@count comm ts’) requested language. can be provided, ‘@count comm en placements array Optional variable realways the page language! and language is GET THE placements array Optional variable re provided in this order. acters) language code ca n be ased on prefix char Repla cement formats (b value escaped with ns using translation features Replaced with the ut. Other PHP functio @count check_plain() for outp format_date Translates parts of the +,-$& (,--&bu. ble as long as credit is kept. d value escaped an ($tim estamp, date/time formatting. Replaced with the r (theme 'medium', ...) ted as a placeholde %size format interval in eholder’)). CHEAT SHEET Displays the time (‘plac anslates t l format_interva human terms. Tr value as is, withou ) gments. Replaced with the ting. Insecure! Only ($ timestamp, ... names of the se ional format !html any additu already sanitized your text. provided use if yo Formats a file size e MB, y( tes. Translates th irectory’, arra ize, ...) in by me moved to @d format_size($s Example: t(‘%na y’ => $dirnam e); ta . KB and byte labels me, ‘@director 1.1 - '*.-/0 ‘%na me’ => $filena e code at the end. FROM an optional languag All functions accept the installer Translating text in ed later y as t(), but translation and us Works the same wa ckend. Use Text extracted for ory ba e; Module/theme nam name. uses a file+mem and in install .info files description; package st(‘Home’) only in the installer support. profiles. No plural names, Literal permission ard hook_p erm() when provided with stand ll files and any -! 15. 2007. HOJTSY.HU ns array syntax. Use get_t() in .insta implementatio could run in the other code which s ‘t’ or ‘st’ $t = get_t(); installer too. It retu nction to be d rn Menu item ‘title’ an en fu hook_menu() ‘description’ keys , wh $t (‘Home’); depending on the l strings. t. impl ementations provided as litera used at the momen sage, Log type and mes ral ur use translation, yo le provided as lite ll file and need to when Remember: if you have an .insta running in the installer if your modu u’, strings. Third parameter easily end up e get_t()! watchdog(‘men function calls could core module in an install profile. Us calls specifies the replacements become sa ‘Items saved’) pport. array. No plural su bal context, mistakes Usage of t() in a glo ST’, t(‘...’)). The The most common e message eg. for such as define( ‘CON type). Reuse of the sam t yet initialized at lues, such as t($ t_message() locale system is no e is incorrect Using dynamic va g() and drupal_se strings to call watchdo allows t(), the later ag dynamic Whenever you use make sure that all that time, so this us ALSO SEE , calls. The former dis t possible. ds to nasty perform ance the above functions eady in the code is no requires t(), so this e API functions and also lea it. po ssible values are alr using the API. Always call the abov problems. Never do l form indirection. elsewhere in litera ovided content. directly, without user pr Do not translate pport, so e API properly r module plugin su Tools to verify you are using th er versions have code ws. Also feel free to export a Drupal 6.x-2 or lat revie e API is reported in ings appear. improper use of th ule/theme and check whether all str D.O/NODE/322729 rg/proje ct/potx od http://drupal.o template for your m use t() or some when you forgot to nnot find mistakes e localization client has a The potx module ca late your output. Th ns ge. If certain other function to tra to translate text displayed on the pa the API. rg/project/l10n _client convenient interface , you forgot to use http://drupal.o ing up for translation str ings are not show
  • 5. TEXT IS FOUND AND REPLACED RUNTIME, WHEN USED
  • 6. TRANSLATIONS ARE STORED IN THE DATABASE
  • 8. Running source code Found text stored in DB
  • 9. Running source code Found text stored in DB User interface to translate text, stored in DB
  • 10. Running source code Found text stored in DB Text replaced on User interface output to translate text, stored in DB
  • 11.
  • 15. Static source code Gettext .pot (CVS) Translated .po (CVS)
  • 16. Static source code Gettext .pot (CVS) Translated .po (CVS)
  • 17. Static source code Gettext .pot (CVS) Translated .po (CVS)
  • 18. Static source code Gettext Database .pot (CVS) Translated .po (CVS)
  • 19. Static source code Automation Gettext Database .pot (CVS) Translated .po (CVS)
  • 20. Static source code Automation Gettext Database .pot (CVS) Web UI Translated .po (CVS)
  • 21. Static source code Automation Gettext Database .pot (CVS) Web UI Translated .po (CVS) (FTP)
  • 22. Static source code Automation Gettext Database .pot (CVS) Web UI Automation Translated .po (CVS) (FTP)
  • 23. Static source code Automation Gettext Database .pot (CVS) Web UI Contribute Automation Translated .po (CVS) (FTP)
  • 24. Static source code Automation Gettext Database .pot (CVS) Web UI Contribute Automation Translated Pull .po (CVS) (FTP)
  • 25. over almost 6700 14000 projects known releases parsed
  • 28. 71 TRANSLATION TEAMS