SlideShare a Scribd company logo
1 of 79
Download to read offline
Designing Multilingual Applications
                       International PHP Conference – Spring Edition


                                Kore Nordmann <kore@qafoo.com>


                                         May 30, 2011




Designing Multilingual Applications                                    1 / 35
About me



            Degree in computer sience
            More than 10 years of       Qafoo
                                        passion for software quality
            professional PHP
            Open source enthusiasts
            Contributing to various
            FLOSS projects




Designing Multilingual Applications                                    2 / 35
About me



            Degree in computer sience
            More than 10 years of       Qafoo
                                        passion for software quality
            professional PHP
            Open source enthusiasts
            Contributing to various
            FLOSS projects




Designing Multilingual Applications                                    2 / 35
About me



            Degree in computer sience
            More than 10 years of       Qafoo
                                        passion for software quality
            professional PHP
            Open source enthusiasts
            Contributing to various
            FLOSS projects




Designing Multilingual Applications                                    2 / 35
About me


                                        Co-founder of
            Degree in computer sience
            More than 10 years of       Qafoo
                                        passion for software quality
            professional PHP
            Open source enthusiasts
            Contributing to various
            FLOSS projects




Designing Multilingual Applications                                    2 / 35
About me


                                              Co-founder of
            Degree in computer sience
            More than 10 years of             Qafoo
                                              passion for software quality
            professional PHP
            Open source enthusiasts     We help people to create
            Contributing to various        high quality PHP
            FLOSS projects                    applications.




Designing Multilingual Applications                                          2 / 35
About me


                                              Co-founder of
            Degree in computer sience
            More than 10 years of             Qafoo
                                              passion for software quality
            professional PHP
            Open source enthusiasts     We help people to create
            Contributing to various        high quality PHP
            FLOSS projects                    applications.

                                           http://qafoo.com



Designing Multilingual Applications                                          2 / 35
Motivation




              Multilingual / Multicultural applications can be hard
              Different types of applications:
                      Single fixed language
                      Consistent language per installation
                      Multilingual content




Designing Multilingual Applications                                   3 / 35
Motivation




              Multilingual / Multicultural applications can be hard
              Different types of applications:
                      Single fixed language
                      Consistent language per installation
                      Multilingual content




Designing Multilingual Applications                                   3 / 35
Motivation




              Multilingual / Multicultural applications can be hard
              Different types of applications:
                      Single fixed language
                      Consistent language per installation
                      Multilingual content




Designing Multilingual Applications                                   3 / 35
Motivation




              Multilingual / Multicultural applications can be hard
              Different types of applications:
                      Single fixed language
                      Consistent language per installation
                      Multilingual content




Designing Multilingual Applications                                   3 / 35
Where are the problems?




                                      View     Model




                                 Dispatcher   Controller




Designing Multilingual Applications                        4 / 35
Outline


      The Dispatcher

      The Model

      The View

      Conclusion




Designing Multilingual Applications   5 / 35
Locate your user



              Parsing accept headers is not hard
                      Possbile to do by regular expression
              Never use geolocation for language selection
                      Or I’ll get back at you!
              Result: de , en GB , cs CZ.UTF-8 , de AU@euro , . . .
                      Format: langauge[ territory][.codeset][@modifier]




Designing Multilingual Applications                                       6 / 35
Locate your user



              Parsing accept headers is not hard
                      Possbile to do by regular expression
              Never use geolocation for language selection
                      Or I’ll get back at you!
              Result: de , en GB , cs CZ.UTF-8 , de AU@euro , . . .
                      Format: langauge[ territory][.codeset][@modifier]




Designing Multilingual Applications                                       6 / 35
Locate your user



              Parsing accept headers is not hard
                      Possbile to do by regular expression
              Never use geolocation for language selection
                      Or I’ll get back at you!
              Result: de , en GB , cs CZ.UTF-8 , de AU@euro , . . .
                      Format: langauge[ territory][.codeset][@modifier]




Designing Multilingual Applications                                       6 / 35
Locate your user



              Parsing accept headers is not hard
                      Possbile to do by regular expression
              Never use geolocation for language selection
                      Or I’ll get back at you!
              Result: de , en GB , cs CZ.UTF-8 , de AU@euro , . . .
                      Format: langauge[ territory][.codeset][@modifier]




Designing Multilingual Applications                                       6 / 35
Outline


      The Dispatcher

      The Model

      The View

      Conclusion




Designing Multilingual Applications   7 / 35
The Model




              Translation of “user”-provided contents
                      News, Articles, Products, Comments, . . .




Designing Multilingual Applications                               8 / 35
Outline




      The Model
         Model persistance
         Domain-Problems




Designing Multilingual Applications   9 / 35
One multilingual table


                    id           language      state                 title   ...
              42                de          published   Dies ist ein Titel
              42                en          published   This is a title

             ...




              Dublication of non-translated items
              De-normalized



Designing Multilingual Applications                                                10 / 35
One multilingual table


                    id           language      state                 title   ...
              42                de          published   Dies ist ein Titel
              42                en          published   This is a title

             ...




              Dublication of non-translated items
              De-normalized



Designing Multilingual Applications                                                10 / 35
Multiple columns


                    id                state           title_1               title_2   ...
              42                published     Dies ist ein Titel   This is a title

             ...




              Limited number of translations




Designing Multilingual Applications                                                         11 / 35
Multiple columns


                    id                state           title_1               title_2   ...
              42                published     Dies ist ein Titel   This is a title

             ...




              Limited number of translations




Designing Multilingual Applications                                                         11 / 35
Multiple tables


                    id                state   ...
              42                published
             ...
                    id           language                  title   ...
              42                de            Dies ist ein Titel
              42                en            This is a title
              ...


              More complex queries




Designing Multilingual Applications                                      12 / 35
Multiple tables


                    id                state   ...
              42                published
             ...
                    id           language                  title   ...
              42                de            Dies ist ein Titel
              42                en            This is a title
              ...


              More complex queries




Designing Multilingual Applications                                      12 / 35
Full mapping
                  Content class               Instance               Metadata
                                         content_object
               content_class             id
               id                        content_class_id
               name                      name



               content_class_attribute   content_object_version
               id                        content_object_version   status
               content_class_id          content_object_id
               attribute_type_id                                  id
                                         language_id
               name                                               name
                                         status_id
               description                                        description
                                         creator
               configuration              created
               default_value
                                                                  language
                                                                  id
                                         content_object_data
               attribute_type                                     short
                                         content_object_version   name
               id                        content_object_id
               name                      language_id
               description               attribute_id
               configuration              data




Designing Multilingual Applications                                             13 / 35
Outline




      The Model
         Model persistance
         Domain-Problems




Designing Multilingual Applications   14 / 35
The Model


              There is a bunch of domain-specific problems
                      CMS
                              Different contents
                      Shop
                              Tax calculation
                              Legal requirements
                              Currency conversions
                      Others
                              Recipe aggregation




Designing Multilingual Applications                         15 / 35
The Model


              There is a bunch of domain-specific problems
                      CMS
                              Different contents
                      Shop
                              Tax calculation
                              Legal requirements
                              Currency conversions
                      Others
                              Recipe aggregation




Designing Multilingual Applications                         15 / 35
The Model


              There is a bunch of domain-specific problems
                      CMS
                              Different contents
                      Shop
                              Tax calculation
                              Legal requirements
                              Currency conversions
                      Others
                              Recipe aggregation




Designing Multilingual Applications                         15 / 35
The Model


              There is a bunch of domain-specific problems
                      CMS
                              Different contents
                      Shop
                              Tax calculation
                              Legal requirements
                              Currency conversions
                      Others
                              Recipe aggregation




Designing Multilingual Applications                         15 / 35
Content (CMS)




              Structure of content tree
                      Each item is translated into all languages
                      Fallback language
                      Display sub-tree for non-main languages
                      Different contents per language




Designing Multilingual Applications                                16 / 35
Content (CMS)




              Structure of content tree
                      Each item is translated into all languages
                      Fallback language
                      Display sub-tree for non-main languages
                      Different contents per language




Designing Multilingual Applications                                16 / 35
Content (CMS)




              Structure of content tree
                      Each item is translated into all languages
                      Fallback language
                      Display sub-tree for non-main languages
                      Different contents per language




Designing Multilingual Applications                                16 / 35
Content (CMS)




              Structure of content tree
                      Each item is translated into all languages
                      Fallback language
                      Display sub-tree for non-main languages
                      Different contents per language




Designing Multilingual Applications                                16 / 35
Calculations (Shop)



              Rule based systems
                      Select calculation rules based on language / country
                      IF (@COUNTRY = "us" AND @STATE = "New York") @TAX
                      = 23.43
                      IF (@COUNTRY = "de" AND @TYPE = "BOOK") @TAX =
                      7.00
                      DEFAULT: @TAX = 19.00




Designing Multilingual Applications                                          17 / 35
Calculations (Shop)



              Rule based systems
                      Select calculation rules based on language / country
                      IF (@COUNTRY = "us" AND @STATE = "New York") @TAX
                      = 23.43
                      IF (@COUNTRY = "de" AND @TYPE = "BOOK") @TAX =
                      7.00
                      DEFAULT: @TAX = 19.00




Designing Multilingual Applications                                          17 / 35
Calculations (Shop)



              Rule based systems
                      Select calculation rules based on language / country
                      IF (@COUNTRY = "us" AND @STATE = "New York") @TAX
                      = 23.43
                      IF (@COUNTRY = "de" AND @TYPE = "BOOK") @TAX =
                      7.00
                      DEFAULT: @TAX = 19.00




Designing Multilingual Applications                                          17 / 35
Calculations (Shop)



              Rule based systems
                      Select calculation rules based on language / country
                      IF (@COUNTRY = "us" AND @STATE = "New York") @TAX
                      = 23.43
                      IF (@COUNTRY = "de" AND @TYPE = "BOOK") @TAX =
                      7.00
                      DEFAULT: @TAX = 19.00




Designing Multilingual Applications                                          17 / 35
Outline


      The Dispatcher

      The Model

      The View

      Conclusion




Designing Multilingual Applications   18 / 35
Translating strings


              gettext()
                      Depends on setlocale() , which is not thread-safe
              QT Linguist
                      XML based format used in QT
              PHP Arrays
              PHP Constants
              PHP implementation for gettext files
                      Should not depend on setlocale()
                      Will be slower




Designing Multilingual Applications                                       19 / 35
Plural forms




              Most libraries somehow support plural forms
                      Support         singular
                      Support         simple plural forms
                      Support         different plural forms depending on number
                      Support         multiple words with plural forms in one sentence




Designing Multilingual Applications                                                      20 / 35
Plural forms




              Most libraries somehow support plural forms
                      Support         singular
                      Support         simple plural forms
                      Support         different plural forms depending on number
                      Support         multiple words with plural forms in one sentence




Designing Multilingual Applications                                                      20 / 35
Plural forms




              Most libraries somehow support plural forms
                      Support         singular
                      Support         simple plural forms
                      Support         different plural forms depending on number
                      Support         multiple words with plural forms in one sentence




Designing Multilingual Applications                                                      20 / 35
Plural forms




              Most libraries somehow support plural forms
                      Support         singular
                      Support         simple plural forms
                      Support         different plural forms depending on number
                      Support         multiple words with plural forms in one sentence




Designing Multilingual Applications                                                      20 / 35
Finding strings


              Locating untranslated strings
                      Plain strings are “trivial” to find
                      Parameterized strings are possible to find
                      Error messages created in applications are impossible to find
              Handling untranslated strings
                      Use proper message as identifier (not MY FOO ERRORMSG1 )
                              Add “context”
                      Append strings to storage as “untranslated”




Designing Multilingual Applications                                                  21 / 35
Finding strings


              Locating untranslated strings
                      Plain strings are “trivial” to find
                      Parameterized strings are possible to find
                      Error messages created in applications are impossible to find
              Handling untranslated strings
                      Use proper message as identifier (not MY FOO ERRORMSG1 )
                              Add “context”
                      Append strings to storage as “untranslated”




Designing Multilingual Applications                                                  21 / 35
Finding strings


              Locating untranslated strings
                      Plain strings are “trivial” to find
                      Parameterized strings are possible to find
                      Error messages created in applications are impossible to find
              Handling untranslated strings
                      Use proper message as identifier (not MY FOO ERRORMSG1 )
                              Add “context”
                      Append strings to storage as “untranslated”




Designing Multilingual Applications                                                  21 / 35
Finding strings


              Locating untranslated strings
                      Plain strings are “trivial” to find
                      Parameterized strings are possible to find
                      Error messages created in applications are impossible to find
              Handling untranslated strings
                      Use proper message as identifier (not MY FOO ERRORMSG1 )
                              Add “context”
                      Append strings to storage as “untranslated”




Designing Multilingual Applications                                                  21 / 35
Translations




              Standardized formats help Translators
                      Make it easy for them
                      There are various websites which make collaboration easy
                              Commonly support QT Linguist and gettext
                      There is a GUI for QT Linguist translations




Designing Multilingual Applications                                              22 / 35
Example: crowdin.net




              http://crowdin.net

Designing Multilingual Applications   23 / 35
Example: QT3 Linguist




Designing Multilingual Applications   24 / 35
Outline




      The View
         Data handling




Designing Multilingual Applications   25 / 35
Number formatting




 1   <?php
 2
 3    var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 ) ) ;
 4    // s t r i n g ( 9 ) ” 4 2 , 0 0 0 . 2 3 ”
 5
 6    var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 , ’ , ’ , ’ . ’ ) ) ;
 7    // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ”




Designing Multilingual Applications                                                    26 / 35
Number formatting




 1   <?php
 2
 3    var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 ) ) ;
 4    // s t r i n g ( 9 ) ” 4 2 , 0 0 0 . 2 3 ”
 5
 6    var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 , ’ , ’ , ’ . ’ ) ) ;
 7    // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ”




Designing Multilingual Applications                                                    26 / 35
Number formatting




 1   <?php
 2
 3    var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 ) ) ;
 4    // s t r i n g ( 9 ) ” 4 2 , 0 0 0 . 2 3 ”
 5
 6    var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 , ’ , ’ , ’ . ’ ) ) ;
 7    // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ”




Designing Multilingual Applications                                                    26 / 35
Number formatting




 1   <?php
 2
 3    var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 ) ) ;
 4    // s t r i n g ( 9 ) ” 4 2 , 0 0 0 . 2 3 ”
 5
 6    var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 , ’ , ’ , ’ . ’ ) ) ;
 7    // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ”




Designing Multilingual Applications                                                    26 / 35
Number formatting (Intl)



 1   <?php
 2
 3    $ f o r m a t t e r = new NumberFormatter ( ’ de DE ’ , NumberFormatter : : DECIMAL ) ;
 4    var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ;
                                          >f
 5    // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ”
 6
 7    $ f o r m a t t e r = new NumberFormatter ( ’ en US ’ , NumberFormatter : : SPELLOUT ) ;
 8    var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ;
                                          >f
 9    // s t r i n g ( 3 4 ) ” f o r t y −two t h o u s a n d p o i n t two t h r e e ”




Designing Multilingual Applications                                                              27 / 35
Number formatting (Intl)



 1   <?php
 2
 3    $ f o r m a t t e r = new NumberFormatter ( ’ de DE ’ , NumberFormatter : : DECIMAL ) ;
 4    var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ;
                                          >f
 5    // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ”
 6
 7    $ f o r m a t t e r = new NumberFormatter ( ’ en US ’ , NumberFormatter : : SPELLOUT ) ;
 8    var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ;
                                          >f
 9    // s t r i n g ( 3 4 ) ” f o r t y −two t h o u s a n d p o i n t two t h r e e ”




Designing Multilingual Applications                                                              27 / 35
Number formatting (Intl)



 1   <?php
 2
 3    $ f o r m a t t e r = new NumberFormatter ( ’ de DE ’ , NumberFormatter : : DECIMAL ) ;
 4    var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ;
                                          >f
 5    // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ”
 6
 7    $ f o r m a t t e r = new NumberFormatter ( ’ en US ’ , NumberFormatter : : SPELLOUT ) ;
 8    var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ;
                                          >f
 9    // s t r i n g ( 3 4 ) ” f o r t y −two t h o u s a n d p o i n t two t h r e e ”




Designing Multilingual Applications                                                              27 / 35
Number formatting (Intl)



 1   <?php
 2
 3    $ f o r m a t t e r = new NumberFormatter ( ’ de DE ’ , NumberFormatter : : DECIMAL ) ;
 4    var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ;
                                          >f
 5    // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ”
 6
 7    $ f o r m a t t e r = new NumberFormatter ( ’ en US ’ , NumberFormatter : : SPELLOUT ) ;
 8    var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ;
                                          >f
 9    // s t r i n g ( 3 4 ) ” f o r t y −two t h o u s a n d p o i n t two t h r e e ”




Designing Multilingual Applications                                                              27 / 35
Date formatting



 1   <?php
 2
 3    $time = 1234567890;
 4
 5    var dump ( s t r f t i m e ( ’%A , %e . %B %G − %I :%M %P ’ , $ t i m e ) ) ;
 6    // s t r i n g ( 3 8 ) ” S a t u r d a y , 1 4 . F e b r u a r y 2009 − 1 2 : 3 1 am”
 7
 8    s e t l o c a l e ( LC TIME , ’ de ’ , ’ de DE ’ , ’ de DE . UTF−8 ’ , ’ deu ’ ) ;
 9    var dump ( s t r f t i m e ( ’%A , %e . %B %G − %H:%M’ , $ t i m e ) ) ;
10    // s t r i n g ( 3 3 ) ” Samstag , 1 4 . F e b r u a r 2009 − 0 0 : 3 1 ”




Designing Multilingual Applications                                                           28 / 35
Date formatting



 1   <?php
 2
 3    $time = 1234567890;
 4
 5    var dump ( s t r f t i m e ( ’%A , %e . %B %G − %I :%M %P ’ , $ t i m e ) ) ;
 6    // s t r i n g ( 3 8 ) ” S a t u r d a y , 1 4 . F e b r u a r y 2009 − 1 2 : 3 1 am”
 7
 8    s e t l o c a l e ( LC TIME , ’ de ’ , ’ de DE ’ , ’ de DE . UTF−8 ’ , ’ deu ’ ) ;
 9    var dump ( s t r f t i m e ( ’%A , %e . %B %G − %H:%M’ , $ t i m e ) ) ;
10    // s t r i n g ( 3 3 ) ” Samstag , 1 4 . F e b r u a r 2009 − 0 0 : 3 1 ”




Designing Multilingual Applications                                                           28 / 35
Date formatting



 1   <?php
 2
 3    $time = 1234567890;
 4
 5    var dump ( s t r f t i m e ( ’%A , %e . %B %G − %I :%M %P ’ , $ t i m e ) ) ;
 6    // s t r i n g ( 3 8 ) ” S a t u r d a y , 1 4 . F e b r u a r y 2009 − 1 2 : 3 1 am”
 7
 8    s e t l o c a l e ( LC TIME , ’ de ’ , ’ de DE ’ , ’ de DE . UTF−8 ’ , ’ deu ’ ) ;
 9    var dump ( s t r f t i m e ( ’%A , %e . %B %G − %H:%M’ , $ t i m e ) ) ;
10    // s t r i n g ( 3 3 ) ” Samstag , 1 4 . F e b r u a r 2009 − 0 0 : 3 1 ”




Designing Multilingual Applications                                                           28 / 35
Date formatting



 1   <?php
 2
 3    $time = 1234567890;
 4
 5    var dump ( s t r f t i m e ( ’%A , %e . %B %G − %I :%M %P ’ , $ t i m e ) ) ;
 6    // s t r i n g ( 3 8 ) ” S a t u r d a y , 1 4 . F e b r u a r y 2009 − 1 2 : 3 1 am”
 7
 8    s e t l o c a l e ( LC TIME , ’ de ’ , ’ de DE ’ , ’ de DE . UTF−8 ’ , ’ deu ’ ) ;
 9    var dump ( s t r f t i m e ( ’%A , %e . %B %G − %H:%M’ , $ t i m e ) ) ;
10    // s t r i n g ( 3 3 ) ” Samstag , 1 4 . F e b r u a r 2009 − 0 0 : 3 1 ”




Designing Multilingual Applications                                                           28 / 35
Date formatting (Intl)

 1   <?php
 2
 3    $time = 1234567890;
 4
 5    $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r (
 6            ’ en ’ ,
 7            I n t l D a t e F o r m a t t e r : : FULL , // d a t e
 8            I n t l D a t e F o r m a t t e r : : SHORT // t i m e
 9    );
10    var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ;
                                               >f
11    // s t r i n g ( 3 6 ) ” S a t u r d a y , F e b r u a r y 1 4 , 2009 1 2 : 3 1 AM”
12
13    $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r (
14            ’ de DE ’ ,
15            I n t l D a t e F o r m a t t e r : : FULL , // d a t e
16            I n t l D a t e F o r m a t t e r : : SHORT // t i m e
17    );
18    var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ;
                                               >f
19    // s t r i n g ( 3 1 ) ” Samstag , 1 4 . F e b r u a r 2009 0 0 : 3 1 ”




Designing Multilingual Applications                                                         29 / 35
Date formatting (Intl)

 1   <?php
 2
 3    $time = 1234567890;
 4
 5    $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r (
 6            ’ en ’ ,
 7            I n t l D a t e F o r m a t t e r : : FULL , // d a t e
 8            I n t l D a t e F o r m a t t e r : : SHORT // t i m e
 9    );
10    var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ;
                                               >f
11    // s t r i n g ( 3 6 ) ” S a t u r d a y , F e b r u a r y 1 4 , 2009 1 2 : 3 1 AM”
12
13    $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r (
14            ’ de DE ’ ,
15            I n t l D a t e F o r m a t t e r : : FULL , // d a t e
16            I n t l D a t e F o r m a t t e r : : SHORT // t i m e
17    );
18    var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ;
                                               >f
19    // s t r i n g ( 3 1 ) ” Samstag , 1 4 . F e b r u a r 2009 0 0 : 3 1 ”




Designing Multilingual Applications                                                         29 / 35
Date formatting (Intl)

 1   <?php
 2
 3    $time = 1234567890;
 4
 5    $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r (
 6            ’ en ’ ,
 7            I n t l D a t e F o r m a t t e r : : FULL , // d a t e
 8            I n t l D a t e F o r m a t t e r : : SHORT // t i m e
 9    );
10    var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ;
                                               >f
11    // s t r i n g ( 3 6 ) ” S a t u r d a y , F e b r u a r y 1 4 , 2009 1 2 : 3 1 AM”
12
13    $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r (
14            ’ de DE ’ ,
15            I n t l D a t e F o r m a t t e r : : FULL , // d a t e
16            I n t l D a t e F o r m a t t e r : : SHORT // t i m e
17    );
18    var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ;
                                               >f
19    // s t r i n g ( 3 1 ) ” Samstag , 1 4 . F e b r u a r 2009 0 0 : 3 1 ”




Designing Multilingual Applications                                                         29 / 35
Date formatting (Intl)

 1   <?php
 2
 3    $time = 1234567890;
 4
 5    $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r (
 6            ’ en ’ ,
 7            I n t l D a t e F o r m a t t e r : : FULL , // d a t e
 8            I n t l D a t e F o r m a t t e r : : SHORT // t i m e
 9    );
10    var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ;
                                               >f
11    // s t r i n g ( 3 6 ) ” S a t u r d a y , F e b r u a r y 1 4 , 2009 1 2 : 3 1 AM”
12
13    $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r (
14            ’ de DE ’ ,
15            I n t l D a t e F o r m a t t e r : : FULL , // d a t e
16            I n t l D a t e F o r m a t t e r : : SHORT // t i m e
17    );
18    var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ;
                                               >f
19    // s t r i n g ( 3 1 ) ” Samstag , 1 4 . F e b r u a r 2009 0 0 : 3 1 ”




Designing Multilingual Applications                                                         29 / 35
Alternatives




              Zend Date
              Symfony
              arbitDateFormatter




Designing Multilingual Applications   30 / 35
Intl gems



              Collator
              Normalizer
              Locale
              MessageFormatter
              NumberFormatter
              IntlDateFormatter




Designing Multilingual Applications   31 / 35
Charsets & Encodings




              Use UTF-8
              Also see: http://www.kore-nordmann.de/blog/php_
              charset_encoding_FAQ.html




Designing Multilingual Applications                             32 / 35
Charsets & Encodings




              Use UTF-8
              Also see: http://www.kore-nordmann.de/blog/php_
              charset_encoding_FAQ.html




Designing Multilingual Applications                             32 / 35
Outline


      The Dispatcher

      The Model

      The View

      Conclusion




Designing Multilingual Applications   33 / 35
Conclusion




              There are really tricky domain specific problems
              Use solutions not depending on setlocale()
              Use intl extension if possible




Designing Multilingual Applications                             34 / 35
Thanks for listening

                                        Please rate this talk at
                                      http://joind.in/3491
                           and (optionally) give us some feedback right now




Designing Multilingual Applications                                           35 / 35
Thanks for listening

                                          Please rate this talk at
                                      http://joind.in/3491
                           and (optionally) give us some feedback right now

                                      This is very important for . . .

              Speakers
              Organizers
              You!




Designing Multilingual Applications                                           35 / 35
Thanks for listening

                                         Please rate this talk at
                                      http://joind.in/3491
                           and (optionally) give us some feedback right now

                                           Stay in touch

              Kore Nordmann
              kore@qafoo.com
              @koredn / @qafoo

                                      Rent a PHP quality expert:
                                          http://qafoo.com


Designing Multilingual Applications                                           35 / 35

More Related Content

What's hot

Introduction to C Language
Introduction to C LanguageIntroduction to C Language
Introduction to C LanguageTarun Sharma
 
Programming languages
Programming languagesProgramming languages
Programming languagesSimon Mui
 
Object oriented slides
Object oriented slidesObject oriented slides
Object oriented slidesahad nadeem
 
Unveiling the Origins, Myths, Use and Benefits of Dynamic Languages
Unveiling the Origins, Myths, Use and Benefits of Dynamic LanguagesUnveiling the Origins, Myths, Use and Benefits of Dynamic Languages
Unveiling the Origins, Myths, Use and Benefits of Dynamic LanguagesActiveState
 
Delphi unicode-migration
Delphi unicode-migrationDelphi unicode-migration
Delphi unicode-migrationzevin
 
From Programming to Modeling And Back Again
From Programming to Modeling And Back AgainFrom Programming to Modeling And Back Again
From Programming to Modeling And Back AgainMarkus Voelter
 
Getting it right_english
Getting it right_englishGetting it right_english
Getting it right_englishjohn rogan
 
Translation non commodity
Translation non commodityTranslation non commodity
Translation non commodityjohn rogan
 
The Ring programming language version 1.9 book - Part 97 of 210
The Ring programming language version 1.9 book - Part 97 of 210The Ring programming language version 1.9 book - Part 97 of 210
The Ring programming language version 1.9 book - Part 97 of 210Mahmoud Samir Fayed
 
Programing fundamentals with C++
Programing fundamentals with C++Programing fundamentals with C++
Programing fundamentals with C++farooq2016
 
Which programming language should you learn next?
Which programming language should you learn next? Which programming language should you learn next?
Which programming language should you learn next? Ganesh Samarthyam
 
Lessons learned on localization testing
Lessons learned on localization testingLessons learned on localization testing
Lessons learned on localization testinggaoliang641
 
Introduction to C Language
Introduction to C LanguageIntroduction to C Language
Introduction to C LanguageKamal Acharya
 
Creating a textual domain specific language
Creating a textual domain specific languageCreating a textual domain specific language
Creating a textual domain specific languageVicente García Díaz
 

What's hot (20)

Introduction to C Language
Introduction to C LanguageIntroduction to C Language
Introduction to C Language
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Speaking in Tongues
Speaking in TonguesSpeaking in Tongues
Speaking in Tongues
 
Object oriented slides
Object oriented slidesObject oriented slides
Object oriented slides
 
Lecture 11
Lecture 11Lecture 11
Lecture 11
 
Delphi Unicode Migration for Mere Mortals
Delphi Unicode Migration for Mere MortalsDelphi Unicode Migration for Mere Mortals
Delphi Unicode Migration for Mere Mortals
 
Unveiling the Origins, Myths, Use and Benefits of Dynamic Languages
Unveiling the Origins, Myths, Use and Benefits of Dynamic LanguagesUnveiling the Origins, Myths, Use and Benefits of Dynamic Languages
Unveiling the Origins, Myths, Use and Benefits of Dynamic Languages
 
Dry
DryDry
Dry
 
Delphi unicode-migration
Delphi unicode-migrationDelphi unicode-migration
Delphi unicode-migration
 
From Programming to Modeling And Back Again
From Programming to Modeling And Back AgainFrom Programming to Modeling And Back Again
From Programming to Modeling And Back Again
 
Itc chapter # 8
Itc   chapter # 8Itc   chapter # 8
Itc chapter # 8
 
Getting it right_english
Getting it right_englishGetting it right_english
Getting it right_english
 
Translation non commodity
Translation non commodityTranslation non commodity
Translation non commodity
 
The Ring programming language version 1.9 book - Part 97 of 210
The Ring programming language version 1.9 book - Part 97 of 210The Ring programming language version 1.9 book - Part 97 of 210
The Ring programming language version 1.9 book - Part 97 of 210
 
Programing fundamentals with C++
Programing fundamentals with C++Programing fundamentals with C++
Programing fundamentals with C++
 
Which programming language should you learn next?
Which programming language should you learn next? Which programming language should you learn next?
Which programming language should you learn next?
 
Lessons learned on localization testing
Lessons learned on localization testingLessons learned on localization testing
Lessons learned on localization testing
 
Programming
ProgrammingProgramming
Programming
 
Introduction to C Language
Introduction to C LanguageIntroduction to C Language
Introduction to C Language
 
Creating a textual domain specific language
Creating a textual domain specific languageCreating a textual domain specific language
Creating a textual domain specific language
 

Viewers also liked

international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretssmueller_sandsmedia
 
international PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPinternational PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPsmueller_sandsmedia
 
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"smueller_sandsmedia
 
international PHP2011_Bastian Hofmann_Mashing up java script
international PHP2011_Bastian Hofmann_Mashing up java scriptinternational PHP2011_Bastian Hofmann_Mashing up java script
international PHP2011_Bastian Hofmann_Mashing up java scriptsmueller_sandsmedia
 
international PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Resetinternational PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Resetsmueller_sandsmedia
 
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitsmueller_sandsmedia
 
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnen
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnenwebinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnen
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnensmueller_sandsmedia
 

Viewers also liked (8)

international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
Golf
GolfGolf
Golf
 
international PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPinternational PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHP
 
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"
 
international PHP2011_Bastian Hofmann_Mashing up java script
international PHP2011_Bastian Hofmann_Mashing up java scriptinternational PHP2011_Bastian Hofmann_Mashing up java script
international PHP2011_Bastian Hofmann_Mashing up java script
 
international PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Resetinternational PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Reset
 
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
 
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnen
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnenwebinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnen
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnen
 

Similar to international PHP2011_Kore Nordmann_Designing multilingual applications

Laura Dent: Single-Source and Localization
Laura Dent: Single-Source and LocalizationLaura Dent: Single-Source and Localization
Laura Dent: Single-Source and LocalizationJack Molisani
 
Java-centered Translator-based Multi-paradigm Software Development Environment
Java-centered Translator-based Multi-paradigm Software Development EnvironmentJava-centered Translator-based Multi-paradigm Software Development Environment
Java-centered Translator-based Multi-paradigm Software Development EnvironmentWaqas Tariq
 
English de lenguaje de programacion
English de lenguaje de programacionEnglish de lenguaje de programacion
English de lenguaje de programacionVillalba Griselda
 
Language translator
Language translatorLanguage translator
Language translatorSumitSumit26
 
MVP Virtual Conference - Americas 2015 - Cross platform localization for mobi...
MVP Virtual Conference - Americas 2015 - Cross platform localization for mobi...MVP Virtual Conference - Americas 2015 - Cross platform localization for mobi...
MVP Virtual Conference - Americas 2015 - Cross platform localization for mobi...Christopher Miller
 
GDSC career guide presentation.pptx
GDSC career guide presentation.pptxGDSC career guide presentation.pptx
GDSC career guide presentation.pptxAryanSharma853911
 
GDSC career guide presentation.pptx
GDSC career guide presentation.pptxGDSC career guide presentation.pptx
GDSC career guide presentation.pptxDishaSharma737984
 
languagetranslator-211028085026.pptx
languagetranslator-211028085026.pptxlanguagetranslator-211028085026.pptx
languagetranslator-211028085026.pptxMDASIFALI32
 
The Ring programming language version 1.4 book - Part 2 of 30
The Ring programming language version 1.4 book - Part 2 of 30The Ring programming language version 1.4 book - Part 2 of 30
The Ring programming language version 1.4 book - Part 2 of 30Mahmoud Samir Fayed
 
Introduction Programming Languages
Introduction Programming LanguagesIntroduction Programming Languages
Introduction Programming LanguagesManish Kharotia
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languagesVarun Garg
 
Programming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharProgramming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharVivek Parihar
 
Introduction to Globalization Testing with Acclaro
Introduction to Globalization Testing with AcclaroIntroduction to Globalization Testing with Acclaro
Introduction to Globalization Testing with AcclaroAcclaro
 
LRC XIII Localisation Conference - Using community feedback to improve social...
LRC XIII Localisation Conference - Using community feedback to improve social...LRC XIII Localisation Conference - Using community feedback to improve social...
LRC XIII Localisation Conference - Using community feedback to improve social...sarni
 
The Ring programming language version 1.4.1 book - Part 2 of 31
The Ring programming language version 1.4.1 book - Part 2 of 31The Ring programming language version 1.4.1 book - Part 2 of 31
The Ring programming language version 1.4.1 book - Part 2 of 31Mahmoud Samir Fayed
 
Overview new programming languages
Overview new programming languagesOverview new programming languages
Overview new programming languagesumoren
 
Envisioning the Future of Language Workbenches
Envisioning the Future of Language WorkbenchesEnvisioning the Future of Language Workbenches
Envisioning the Future of Language WorkbenchesMarkus Voelter
 
What are the advantages of using a compiled language over an interpr.pdf
What are the advantages of using a compiled language over an interpr.pdfWhat are the advantages of using a compiled language over an interpr.pdf
What are the advantages of using a compiled language over an interpr.pdfsantanadenisesarin13
 

Similar to international PHP2011_Kore Nordmann_Designing multilingual applications (20)

Intermediate Languages
Intermediate LanguagesIntermediate Languages
Intermediate Languages
 
Laura Dent: Single-Source and Localization
Laura Dent: Single-Source and LocalizationLaura Dent: Single-Source and Localization
Laura Dent: Single-Source and Localization
 
Java-centered Translator-based Multi-paradigm Software Development Environment
Java-centered Translator-based Multi-paradigm Software Development EnvironmentJava-centered Translator-based Multi-paradigm Software Development Environment
Java-centered Translator-based Multi-paradigm Software Development Environment
 
English de lenguaje de programacion
English de lenguaje de programacionEnglish de lenguaje de programacion
English de lenguaje de programacion
 
Language translator
Language translatorLanguage translator
Language translator
 
MVP Virtual Conference - Americas 2015 - Cross platform localization for mobi...
MVP Virtual Conference - Americas 2015 - Cross platform localization for mobi...MVP Virtual Conference - Americas 2015 - Cross platform localization for mobi...
MVP Virtual Conference - Americas 2015 - Cross platform localization for mobi...
 
GDSC career guide presentation.pptx
GDSC career guide presentation.pptxGDSC career guide presentation.pptx
GDSC career guide presentation.pptx
 
GDSC career guide presentation.pptx
GDSC career guide presentation.pptxGDSC career guide presentation.pptx
GDSC career guide presentation.pptx
 
languagetranslator-211028085026.pptx
languagetranslator-211028085026.pptxlanguagetranslator-211028085026.pptx
languagetranslator-211028085026.pptx
 
The Ring programming language version 1.4 book - Part 2 of 30
The Ring programming language version 1.4 book - Part 2 of 30The Ring programming language version 1.4 book - Part 2 of 30
The Ring programming language version 1.4 book - Part 2 of 30
 
Introduction Programming Languages
Introduction Programming LanguagesIntroduction Programming Languages
Introduction Programming Languages
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
Programming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharProgramming languages and concepts by vivek parihar
Programming languages and concepts by vivek parihar
 
[EN] Multilingual Document Management Systems | AIIM Show 1997
[EN] Multilingual Document Management Systems | AIIM Show 1997[EN] Multilingual Document Management Systems | AIIM Show 1997
[EN] Multilingual Document Management Systems | AIIM Show 1997
 
Introduction to Globalization Testing with Acclaro
Introduction to Globalization Testing with AcclaroIntroduction to Globalization Testing with Acclaro
Introduction to Globalization Testing with Acclaro
 
LRC XIII Localisation Conference - Using community feedback to improve social...
LRC XIII Localisation Conference - Using community feedback to improve social...LRC XIII Localisation Conference - Using community feedback to improve social...
LRC XIII Localisation Conference - Using community feedback to improve social...
 
The Ring programming language version 1.4.1 book - Part 2 of 31
The Ring programming language version 1.4.1 book - Part 2 of 31The Ring programming language version 1.4.1 book - Part 2 of 31
The Ring programming language version 1.4.1 book - Part 2 of 31
 
Overview new programming languages
Overview new programming languagesOverview new programming languages
Overview new programming languages
 
Envisioning the Future of Language Workbenches
Envisioning the Future of Language WorkbenchesEnvisioning the Future of Language Workbenches
Envisioning the Future of Language Workbenches
 
What are the advantages of using a compiled language over an interpr.pdf
What are the advantages of using a compiled language over an interpr.pdfWhat are the advantages of using a compiled language over an interpr.pdf
What are the advantages of using a compiled language over an interpr.pdf
 

More from smueller_sandsmedia

webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...
webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...
webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...smueller_sandsmedia
 
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekten
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekteninternational PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekten
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projektensmueller_sandsmedia
 
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...smueller_sandsmedia
 
webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5smueller_sandsmedia
 
international PHP2011_J.Hartmann_DevOps für PHP
international PHP2011_J.Hartmann_DevOps für PHPinternational PHP2011_J.Hartmann_DevOps für PHP
international PHP2011_J.Hartmann_DevOps für PHPsmueller_sandsmedia
 
webinale2011_Daniel Höpfner_Förderprogramme für dummies
webinale2011_Daniel Höpfner_Förderprogramme für dummieswebinale2011_Daniel Höpfner_Förderprogramme für dummies
webinale2011_Daniel Höpfner_Förderprogramme für dummiessmueller_sandsmedia
 

More from smueller_sandsmedia (6)

webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...
webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...
webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...
 
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekten
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekteninternational PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekten
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekten
 
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...
 
webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5
 
international PHP2011_J.Hartmann_DevOps für PHP
international PHP2011_J.Hartmann_DevOps für PHPinternational PHP2011_J.Hartmann_DevOps für PHP
international PHP2011_J.Hartmann_DevOps für PHP
 
webinale2011_Daniel Höpfner_Förderprogramme für dummies
webinale2011_Daniel Höpfner_Förderprogramme für dummieswebinale2011_Daniel Höpfner_Förderprogramme für dummies
webinale2011_Daniel Höpfner_Förderprogramme für dummies
 

Recently uploaded

What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge
 
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 2024Patrick Viafore
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
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.pdfFIDO Alliance
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...FIDO Alliance
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimaginedpanagenda
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfUK Journal
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
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 StrategyUXDXConf
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FIDO Alliance
 
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)Julian Hyde
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024Stephen Perrenod
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 

Recently uploaded (20)

What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
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
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
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
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
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
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
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)
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 

international PHP2011_Kore Nordmann_Designing multilingual applications

  • 1. Designing Multilingual Applications International PHP Conference – Spring Edition Kore Nordmann <kore@qafoo.com> May 30, 2011 Designing Multilingual Applications 1 / 35
  • 2. About me Degree in computer sience More than 10 years of Qafoo passion for software quality professional PHP Open source enthusiasts Contributing to various FLOSS projects Designing Multilingual Applications 2 / 35
  • 3. About me Degree in computer sience More than 10 years of Qafoo passion for software quality professional PHP Open source enthusiasts Contributing to various FLOSS projects Designing Multilingual Applications 2 / 35
  • 4. About me Degree in computer sience More than 10 years of Qafoo passion for software quality professional PHP Open source enthusiasts Contributing to various FLOSS projects Designing Multilingual Applications 2 / 35
  • 5. About me Co-founder of Degree in computer sience More than 10 years of Qafoo passion for software quality professional PHP Open source enthusiasts Contributing to various FLOSS projects Designing Multilingual Applications 2 / 35
  • 6. About me Co-founder of Degree in computer sience More than 10 years of Qafoo passion for software quality professional PHP Open source enthusiasts We help people to create Contributing to various high quality PHP FLOSS projects applications. Designing Multilingual Applications 2 / 35
  • 7. About me Co-founder of Degree in computer sience More than 10 years of Qafoo passion for software quality professional PHP Open source enthusiasts We help people to create Contributing to various high quality PHP FLOSS projects applications. http://qafoo.com Designing Multilingual Applications 2 / 35
  • 8. Motivation Multilingual / Multicultural applications can be hard Different types of applications: Single fixed language Consistent language per installation Multilingual content Designing Multilingual Applications 3 / 35
  • 9. Motivation Multilingual / Multicultural applications can be hard Different types of applications: Single fixed language Consistent language per installation Multilingual content Designing Multilingual Applications 3 / 35
  • 10. Motivation Multilingual / Multicultural applications can be hard Different types of applications: Single fixed language Consistent language per installation Multilingual content Designing Multilingual Applications 3 / 35
  • 11. Motivation Multilingual / Multicultural applications can be hard Different types of applications: Single fixed language Consistent language per installation Multilingual content Designing Multilingual Applications 3 / 35
  • 12. Where are the problems? View Model Dispatcher Controller Designing Multilingual Applications 4 / 35
  • 13. Outline The Dispatcher The Model The View Conclusion Designing Multilingual Applications 5 / 35
  • 14. Locate your user Parsing accept headers is not hard Possbile to do by regular expression Never use geolocation for language selection Or I’ll get back at you! Result: de , en GB , cs CZ.UTF-8 , de AU@euro , . . . Format: langauge[ territory][.codeset][@modifier] Designing Multilingual Applications 6 / 35
  • 15. Locate your user Parsing accept headers is not hard Possbile to do by regular expression Never use geolocation for language selection Or I’ll get back at you! Result: de , en GB , cs CZ.UTF-8 , de AU@euro , . . . Format: langauge[ territory][.codeset][@modifier] Designing Multilingual Applications 6 / 35
  • 16. Locate your user Parsing accept headers is not hard Possbile to do by regular expression Never use geolocation for language selection Or I’ll get back at you! Result: de , en GB , cs CZ.UTF-8 , de AU@euro , . . . Format: langauge[ territory][.codeset][@modifier] Designing Multilingual Applications 6 / 35
  • 17. Locate your user Parsing accept headers is not hard Possbile to do by regular expression Never use geolocation for language selection Or I’ll get back at you! Result: de , en GB , cs CZ.UTF-8 , de AU@euro , . . . Format: langauge[ territory][.codeset][@modifier] Designing Multilingual Applications 6 / 35
  • 18. Outline The Dispatcher The Model The View Conclusion Designing Multilingual Applications 7 / 35
  • 19. The Model Translation of “user”-provided contents News, Articles, Products, Comments, . . . Designing Multilingual Applications 8 / 35
  • 20. Outline The Model Model persistance Domain-Problems Designing Multilingual Applications 9 / 35
  • 21. One multilingual table id language state title ... 42 de published Dies ist ein Titel 42 en published This is a title ... Dublication of non-translated items De-normalized Designing Multilingual Applications 10 / 35
  • 22. One multilingual table id language state title ... 42 de published Dies ist ein Titel 42 en published This is a title ... Dublication of non-translated items De-normalized Designing Multilingual Applications 10 / 35
  • 23. Multiple columns id state title_1 title_2 ... 42 published Dies ist ein Titel This is a title ... Limited number of translations Designing Multilingual Applications 11 / 35
  • 24. Multiple columns id state title_1 title_2 ... 42 published Dies ist ein Titel This is a title ... Limited number of translations Designing Multilingual Applications 11 / 35
  • 25. Multiple tables id state ... 42 published ... id language title ... 42 de Dies ist ein Titel 42 en This is a title ... More complex queries Designing Multilingual Applications 12 / 35
  • 26. Multiple tables id state ... 42 published ... id language title ... 42 de Dies ist ein Titel 42 en This is a title ... More complex queries Designing Multilingual Applications 12 / 35
  • 27. Full mapping Content class Instance Metadata content_object content_class id id content_class_id name name content_class_attribute content_object_version id content_object_version status content_class_id content_object_id attribute_type_id id language_id name name status_id description description creator configuration created default_value language id content_object_data attribute_type short content_object_version name id content_object_id name language_id description attribute_id configuration data Designing Multilingual Applications 13 / 35
  • 28. Outline The Model Model persistance Domain-Problems Designing Multilingual Applications 14 / 35
  • 29. The Model There is a bunch of domain-specific problems CMS Different contents Shop Tax calculation Legal requirements Currency conversions Others Recipe aggregation Designing Multilingual Applications 15 / 35
  • 30. The Model There is a bunch of domain-specific problems CMS Different contents Shop Tax calculation Legal requirements Currency conversions Others Recipe aggregation Designing Multilingual Applications 15 / 35
  • 31. The Model There is a bunch of domain-specific problems CMS Different contents Shop Tax calculation Legal requirements Currency conversions Others Recipe aggregation Designing Multilingual Applications 15 / 35
  • 32. The Model There is a bunch of domain-specific problems CMS Different contents Shop Tax calculation Legal requirements Currency conversions Others Recipe aggregation Designing Multilingual Applications 15 / 35
  • 33. Content (CMS) Structure of content tree Each item is translated into all languages Fallback language Display sub-tree for non-main languages Different contents per language Designing Multilingual Applications 16 / 35
  • 34. Content (CMS) Structure of content tree Each item is translated into all languages Fallback language Display sub-tree for non-main languages Different contents per language Designing Multilingual Applications 16 / 35
  • 35. Content (CMS) Structure of content tree Each item is translated into all languages Fallback language Display sub-tree for non-main languages Different contents per language Designing Multilingual Applications 16 / 35
  • 36. Content (CMS) Structure of content tree Each item is translated into all languages Fallback language Display sub-tree for non-main languages Different contents per language Designing Multilingual Applications 16 / 35
  • 37. Calculations (Shop) Rule based systems Select calculation rules based on language / country IF (@COUNTRY = "us" AND @STATE = "New York") @TAX = 23.43 IF (@COUNTRY = "de" AND @TYPE = "BOOK") @TAX = 7.00 DEFAULT: @TAX = 19.00 Designing Multilingual Applications 17 / 35
  • 38. Calculations (Shop) Rule based systems Select calculation rules based on language / country IF (@COUNTRY = "us" AND @STATE = "New York") @TAX = 23.43 IF (@COUNTRY = "de" AND @TYPE = "BOOK") @TAX = 7.00 DEFAULT: @TAX = 19.00 Designing Multilingual Applications 17 / 35
  • 39. Calculations (Shop) Rule based systems Select calculation rules based on language / country IF (@COUNTRY = "us" AND @STATE = "New York") @TAX = 23.43 IF (@COUNTRY = "de" AND @TYPE = "BOOK") @TAX = 7.00 DEFAULT: @TAX = 19.00 Designing Multilingual Applications 17 / 35
  • 40. Calculations (Shop) Rule based systems Select calculation rules based on language / country IF (@COUNTRY = "us" AND @STATE = "New York") @TAX = 23.43 IF (@COUNTRY = "de" AND @TYPE = "BOOK") @TAX = 7.00 DEFAULT: @TAX = 19.00 Designing Multilingual Applications 17 / 35
  • 41. Outline The Dispatcher The Model The View Conclusion Designing Multilingual Applications 18 / 35
  • 42. Translating strings gettext() Depends on setlocale() , which is not thread-safe QT Linguist XML based format used in QT PHP Arrays PHP Constants PHP implementation for gettext files Should not depend on setlocale() Will be slower Designing Multilingual Applications 19 / 35
  • 43. Plural forms Most libraries somehow support plural forms Support singular Support simple plural forms Support different plural forms depending on number Support multiple words with plural forms in one sentence Designing Multilingual Applications 20 / 35
  • 44. Plural forms Most libraries somehow support plural forms Support singular Support simple plural forms Support different plural forms depending on number Support multiple words with plural forms in one sentence Designing Multilingual Applications 20 / 35
  • 45. Plural forms Most libraries somehow support plural forms Support singular Support simple plural forms Support different plural forms depending on number Support multiple words with plural forms in one sentence Designing Multilingual Applications 20 / 35
  • 46. Plural forms Most libraries somehow support plural forms Support singular Support simple plural forms Support different plural forms depending on number Support multiple words with plural forms in one sentence Designing Multilingual Applications 20 / 35
  • 47. Finding strings Locating untranslated strings Plain strings are “trivial” to find Parameterized strings are possible to find Error messages created in applications are impossible to find Handling untranslated strings Use proper message as identifier (not MY FOO ERRORMSG1 ) Add “context” Append strings to storage as “untranslated” Designing Multilingual Applications 21 / 35
  • 48. Finding strings Locating untranslated strings Plain strings are “trivial” to find Parameterized strings are possible to find Error messages created in applications are impossible to find Handling untranslated strings Use proper message as identifier (not MY FOO ERRORMSG1 ) Add “context” Append strings to storage as “untranslated” Designing Multilingual Applications 21 / 35
  • 49. Finding strings Locating untranslated strings Plain strings are “trivial” to find Parameterized strings are possible to find Error messages created in applications are impossible to find Handling untranslated strings Use proper message as identifier (not MY FOO ERRORMSG1 ) Add “context” Append strings to storage as “untranslated” Designing Multilingual Applications 21 / 35
  • 50. Finding strings Locating untranslated strings Plain strings are “trivial” to find Parameterized strings are possible to find Error messages created in applications are impossible to find Handling untranslated strings Use proper message as identifier (not MY FOO ERRORMSG1 ) Add “context” Append strings to storage as “untranslated” Designing Multilingual Applications 21 / 35
  • 51. Translations Standardized formats help Translators Make it easy for them There are various websites which make collaboration easy Commonly support QT Linguist and gettext There is a GUI for QT Linguist translations Designing Multilingual Applications 22 / 35
  • 52. Example: crowdin.net http://crowdin.net Designing Multilingual Applications 23 / 35
  • 53. Example: QT3 Linguist Designing Multilingual Applications 24 / 35
  • 54. Outline The View Data handling Designing Multilingual Applications 25 / 35
  • 55. Number formatting 1 <?php 2 3 var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 ) ) ; 4 // s t r i n g ( 9 ) ” 4 2 , 0 0 0 . 2 3 ” 5 6 var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 , ’ , ’ , ’ . ’ ) ) ; 7 // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ” Designing Multilingual Applications 26 / 35
  • 56. Number formatting 1 <?php 2 3 var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 ) ) ; 4 // s t r i n g ( 9 ) ” 4 2 , 0 0 0 . 2 3 ” 5 6 var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 , ’ , ’ , ’ . ’ ) ) ; 7 // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ” Designing Multilingual Applications 26 / 35
  • 57. Number formatting 1 <?php 2 3 var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 ) ) ; 4 // s t r i n g ( 9 ) ” 4 2 , 0 0 0 . 2 3 ” 5 6 var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 , ’ , ’ , ’ . ’ ) ) ; 7 // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ” Designing Multilingual Applications 26 / 35
  • 58. Number formatting 1 <?php 2 3 var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 ) ) ; 4 // s t r i n g ( 9 ) ” 4 2 , 0 0 0 . 2 3 ” 5 6 var dump ( n u m b e r f o r m a t ( 4 2 0 0 0 . 2 3 , 2 , ’ , ’ , ’ . ’ ) ) ; 7 // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ” Designing Multilingual Applications 26 / 35
  • 59. Number formatting (Intl) 1 <?php 2 3 $ f o r m a t t e r = new NumberFormatter ( ’ de DE ’ , NumberFormatter : : DECIMAL ) ; 4 var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ; >f 5 // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ” 6 7 $ f o r m a t t e r = new NumberFormatter ( ’ en US ’ , NumberFormatter : : SPELLOUT ) ; 8 var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ; >f 9 // s t r i n g ( 3 4 ) ” f o r t y −two t h o u s a n d p o i n t two t h r e e ” Designing Multilingual Applications 27 / 35
  • 60. Number formatting (Intl) 1 <?php 2 3 $ f o r m a t t e r = new NumberFormatter ( ’ de DE ’ , NumberFormatter : : DECIMAL ) ; 4 var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ; >f 5 // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ” 6 7 $ f o r m a t t e r = new NumberFormatter ( ’ en US ’ , NumberFormatter : : SPELLOUT ) ; 8 var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ; >f 9 // s t r i n g ( 3 4 ) ” f o r t y −two t h o u s a n d p o i n t two t h r e e ” Designing Multilingual Applications 27 / 35
  • 61. Number formatting (Intl) 1 <?php 2 3 $ f o r m a t t e r = new NumberFormatter ( ’ de DE ’ , NumberFormatter : : DECIMAL ) ; 4 var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ; >f 5 // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ” 6 7 $ f o r m a t t e r = new NumberFormatter ( ’ en US ’ , NumberFormatter : : SPELLOUT ) ; 8 var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ; >f 9 // s t r i n g ( 3 4 ) ” f o r t y −two t h o u s a n d p o i n t two t h r e e ” Designing Multilingual Applications 27 / 35
  • 62. Number formatting (Intl) 1 <?php 2 3 $ f o r m a t t e r = new NumberFormatter ( ’ de DE ’ , NumberFormatter : : DECIMAL ) ; 4 var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ; >f 5 // s t r i n g ( 9 ) ” 4 2 . 0 0 0 , 2 3 ” 6 7 $ f o r m a t t e r = new NumberFormatter ( ’ en US ’ , NumberFormatter : : SPELLOUT ) ; 8 var dump ( $ f o r m a t t e r − o r m a t ( 4 2 0 0 0 . 2 3 ) ) ; >f 9 // s t r i n g ( 3 4 ) ” f o r t y −two t h o u s a n d p o i n t two t h r e e ” Designing Multilingual Applications 27 / 35
  • 63. Date formatting 1 <?php 2 3 $time = 1234567890; 4 5 var dump ( s t r f t i m e ( ’%A , %e . %B %G − %I :%M %P ’ , $ t i m e ) ) ; 6 // s t r i n g ( 3 8 ) ” S a t u r d a y , 1 4 . F e b r u a r y 2009 − 1 2 : 3 1 am” 7 8 s e t l o c a l e ( LC TIME , ’ de ’ , ’ de DE ’ , ’ de DE . UTF−8 ’ , ’ deu ’ ) ; 9 var dump ( s t r f t i m e ( ’%A , %e . %B %G − %H:%M’ , $ t i m e ) ) ; 10 // s t r i n g ( 3 3 ) ” Samstag , 1 4 . F e b r u a r 2009 − 0 0 : 3 1 ” Designing Multilingual Applications 28 / 35
  • 64. Date formatting 1 <?php 2 3 $time = 1234567890; 4 5 var dump ( s t r f t i m e ( ’%A , %e . %B %G − %I :%M %P ’ , $ t i m e ) ) ; 6 // s t r i n g ( 3 8 ) ” S a t u r d a y , 1 4 . F e b r u a r y 2009 − 1 2 : 3 1 am” 7 8 s e t l o c a l e ( LC TIME , ’ de ’ , ’ de DE ’ , ’ de DE . UTF−8 ’ , ’ deu ’ ) ; 9 var dump ( s t r f t i m e ( ’%A , %e . %B %G − %H:%M’ , $ t i m e ) ) ; 10 // s t r i n g ( 3 3 ) ” Samstag , 1 4 . F e b r u a r 2009 − 0 0 : 3 1 ” Designing Multilingual Applications 28 / 35
  • 65. Date formatting 1 <?php 2 3 $time = 1234567890; 4 5 var dump ( s t r f t i m e ( ’%A , %e . %B %G − %I :%M %P ’ , $ t i m e ) ) ; 6 // s t r i n g ( 3 8 ) ” S a t u r d a y , 1 4 . F e b r u a r y 2009 − 1 2 : 3 1 am” 7 8 s e t l o c a l e ( LC TIME , ’ de ’ , ’ de DE ’ , ’ de DE . UTF−8 ’ , ’ deu ’ ) ; 9 var dump ( s t r f t i m e ( ’%A , %e . %B %G − %H:%M’ , $ t i m e ) ) ; 10 // s t r i n g ( 3 3 ) ” Samstag , 1 4 . F e b r u a r 2009 − 0 0 : 3 1 ” Designing Multilingual Applications 28 / 35
  • 66. Date formatting 1 <?php 2 3 $time = 1234567890; 4 5 var dump ( s t r f t i m e ( ’%A , %e . %B %G − %I :%M %P ’ , $ t i m e ) ) ; 6 // s t r i n g ( 3 8 ) ” S a t u r d a y , 1 4 . F e b r u a r y 2009 − 1 2 : 3 1 am” 7 8 s e t l o c a l e ( LC TIME , ’ de ’ , ’ de DE ’ , ’ de DE . UTF−8 ’ , ’ deu ’ ) ; 9 var dump ( s t r f t i m e ( ’%A , %e . %B %G − %H:%M’ , $ t i m e ) ) ; 10 // s t r i n g ( 3 3 ) ” Samstag , 1 4 . F e b r u a r 2009 − 0 0 : 3 1 ” Designing Multilingual Applications 28 / 35
  • 67. Date formatting (Intl) 1 <?php 2 3 $time = 1234567890; 4 5 $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r ( 6 ’ en ’ , 7 I n t l D a t e F o r m a t t e r : : FULL , // d a t e 8 I n t l D a t e F o r m a t t e r : : SHORT // t i m e 9 ); 10 var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ; >f 11 // s t r i n g ( 3 6 ) ” S a t u r d a y , F e b r u a r y 1 4 , 2009 1 2 : 3 1 AM” 12 13 $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r ( 14 ’ de DE ’ , 15 I n t l D a t e F o r m a t t e r : : FULL , // d a t e 16 I n t l D a t e F o r m a t t e r : : SHORT // t i m e 17 ); 18 var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ; >f 19 // s t r i n g ( 3 1 ) ” Samstag , 1 4 . F e b r u a r 2009 0 0 : 3 1 ” Designing Multilingual Applications 29 / 35
  • 68. Date formatting (Intl) 1 <?php 2 3 $time = 1234567890; 4 5 $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r ( 6 ’ en ’ , 7 I n t l D a t e F o r m a t t e r : : FULL , // d a t e 8 I n t l D a t e F o r m a t t e r : : SHORT // t i m e 9 ); 10 var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ; >f 11 // s t r i n g ( 3 6 ) ” S a t u r d a y , F e b r u a r y 1 4 , 2009 1 2 : 3 1 AM” 12 13 $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r ( 14 ’ de DE ’ , 15 I n t l D a t e F o r m a t t e r : : FULL , // d a t e 16 I n t l D a t e F o r m a t t e r : : SHORT // t i m e 17 ); 18 var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ; >f 19 // s t r i n g ( 3 1 ) ” Samstag , 1 4 . F e b r u a r 2009 0 0 : 3 1 ” Designing Multilingual Applications 29 / 35
  • 69. Date formatting (Intl) 1 <?php 2 3 $time = 1234567890; 4 5 $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r ( 6 ’ en ’ , 7 I n t l D a t e F o r m a t t e r : : FULL , // d a t e 8 I n t l D a t e F o r m a t t e r : : SHORT // t i m e 9 ); 10 var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ; >f 11 // s t r i n g ( 3 6 ) ” S a t u r d a y , F e b r u a r y 1 4 , 2009 1 2 : 3 1 AM” 12 13 $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r ( 14 ’ de DE ’ , 15 I n t l D a t e F o r m a t t e r : : FULL , // d a t e 16 I n t l D a t e F o r m a t t e r : : SHORT // t i m e 17 ); 18 var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ; >f 19 // s t r i n g ( 3 1 ) ” Samstag , 1 4 . F e b r u a r 2009 0 0 : 3 1 ” Designing Multilingual Applications 29 / 35
  • 70. Date formatting (Intl) 1 <?php 2 3 $time = 1234567890; 4 5 $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r ( 6 ’ en ’ , 7 I n t l D a t e F o r m a t t e r : : FULL , // d a t e 8 I n t l D a t e F o r m a t t e r : : SHORT // t i m e 9 ); 10 var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ; >f 11 // s t r i n g ( 3 6 ) ” S a t u r d a y , F e b r u a r y 1 4 , 2009 1 2 : 3 1 AM” 12 13 $ f o r m a t t e r = new I n t l D a t e F o r m a t t e r ( 14 ’ de DE ’ , 15 I n t l D a t e F o r m a t t e r : : FULL , // d a t e 16 I n t l D a t e F o r m a t t e r : : SHORT // t i m e 17 ); 18 var dump ( $ f o r m a t t e r − o r m a t ( $ t i m e ) ) ; >f 19 // s t r i n g ( 3 1 ) ” Samstag , 1 4 . F e b r u a r 2009 0 0 : 3 1 ” Designing Multilingual Applications 29 / 35
  • 71. Alternatives Zend Date Symfony arbitDateFormatter Designing Multilingual Applications 30 / 35
  • 72. Intl gems Collator Normalizer Locale MessageFormatter NumberFormatter IntlDateFormatter Designing Multilingual Applications 31 / 35
  • 73. Charsets & Encodings Use UTF-8 Also see: http://www.kore-nordmann.de/blog/php_ charset_encoding_FAQ.html Designing Multilingual Applications 32 / 35
  • 74. Charsets & Encodings Use UTF-8 Also see: http://www.kore-nordmann.de/blog/php_ charset_encoding_FAQ.html Designing Multilingual Applications 32 / 35
  • 75. Outline The Dispatcher The Model The View Conclusion Designing Multilingual Applications 33 / 35
  • 76. Conclusion There are really tricky domain specific problems Use solutions not depending on setlocale() Use intl extension if possible Designing Multilingual Applications 34 / 35
  • 77. Thanks for listening Please rate this talk at http://joind.in/3491 and (optionally) give us some feedback right now Designing Multilingual Applications 35 / 35
  • 78. Thanks for listening Please rate this talk at http://joind.in/3491 and (optionally) give us some feedback right now This is very important for . . . Speakers Organizers You! Designing Multilingual Applications 35 / 35
  • 79. Thanks for listening Please rate this talk at http://joind.in/3491 and (optionally) give us some feedback right now Stay in touch Kore Nordmann kore@qafoo.com @koredn / @qafoo Rent a PHP quality expert: http://qafoo.com Designing Multilingual Applications 35 / 35