Skip to main content
Let’s take over the world
                                   with Zend Framework




                                         Martin de Keijzer
                               Dutch PHP Conference 2011


Monday, 23 May 2011
Introduction




                                     2
Monday, 23 May 2011
Introduction

         Martin de Keijzer


         Software engineer at Ibuildings
         Board member of PHPBenelux
         PHP 5 Zend Certified Engineer


         Twitter: Martin1982
         Joind.in: http://joind.in/3253
         Blog: www.martindekeijzer.nl




                                           3
Monday, 23 May 2011
DISCLAIMER




            DISCLAIMER: ALL EXAMPLE CODE
           IS WRITTEN IN THE CONTROLLER BY
               EXAMPLE! USE MODELS!!!!




                                             4
Monday, 23 May 2011
Monday, 23 May 2011
The case




                      What do we need to take over the
                                  world?




                                                         6
Monday, 23 May 2011
The case

            ✓Location (Country and region)

            ✓Language

            ✓Date and time

            ✓Currency

            ✓Measuring

                                             7
Monday, 23 May 2011
“Location! Location! Location!”
                                  Quote from Achmed (2009)




                                                         8
Monday, 23 May 2011
Zend Locale


Monday, 23 May 2011
Zend Locale




             A locale defines a country (territory) and a language to
                   bind the various localized information to it.




                                                                        10
Monday, 23 May 2011
Zend Locale

              nl_NL




              de_BE




              fr_BE




              nl_BE


                       11
Monday, 23 May 2011
Zend Locale

                              CLDR
                  Common Locale Data Repository
                     http://cldr.unicode.org




                                                  12
Monday, 23 May 2011
Zend Locale




                       13
Monday, 23 May 2011
Zend Locale

        The current locale is is: nl
       The browser's locale is is: nl
       The environment's locale is is: de_DE
       The set locale is is: en_US




                                               14
Monday, 23 May 2011
Zend Locale




                       15
Monday, 23 May 2011
Zend Locale




                       16
Monday, 23 May 2011
Zend Locale




                       In FR people speak fr




                                               17
Monday, 23 May 2011
Zend Locale




                  In FR people speak fr.
                  In France people speak French.

                                                   18
Monday, 23 May 2011
Zend Locale




                       19
Monday, 23 May 2011
Zend Locale




                       20
Monday, 23 May 2011
Zend Locale


          array(6) {
           ["yes"]=>
           string(2) "ja"
           ["no"]=>
           string(3) "nee"
         }
                             21
Monday, 23 May 2011
Zend Locale

                ["yesarray"]=>
                array(2) {
                  [0]=>string(2)   "ja"
                  [1]=>string(1)   "j"
                }
                ["noarray"]=>
                array(2) {
                  [0]=>string(3)   "nee"
                  [1]=>string(1)   "n"
                }




                                           22
Monday, 23 May 2011
Zend Locale




          ["yesexpr"]=>
           string(20) "^([jJ][aA]?)|([jJ]?)"
           ["noexpr"]=>
           string(26) "^([nN]([eE][eE])?)|
         ([nN]?)"




                                               23
Monday, 23 May 2011
Zend Locale




                      A list of supported locales:

            http://framework.zend.com/manual/
                en/zend.locale.appendix.html



                                                     24
Monday, 23 May 2011
Zend Locale

         Utilized by:


         Zend_Controller_Router
         Zend_Currency
         Zend_Date
         Zend_Filter
         Zend_Measure
         Zend_Service_Technorati
         Zend_Timesync
         Zend_Translate
         Zend_Validate

                                   25
Monday, 23 May 2011
Speaking the language
                      Zend_Translate




                                              26
Monday, 23 May 2011
Zend Translate

         Operates using adapters:
              Array
              Csv
              Gettext
              Tbx
              Tmx
              Qt
              Xliff
              Xmltm




                                    27
Monday, 23 May 2011
Zend Translate




                          28
Monday, 23 May 2011
Zend Translate




                          29
Monday, 23 May 2011
Zend Translate
                          nl.php




                          fr.php




                                   30
Monday, 23 May 2011
Zend Translate


                          my-view.phtml




                                          31
Monday, 23 May 2011
Zend Locale




                       32
Monday, 23 May 2011
Zend Locale




                           Quick hint: Google uses locales too!
                      Zend Framework is your gateway to more power!




                                                                      33
Monday, 23 May 2011
Monday, 23 May 2011
Do not get lost in time
                      Zend_Date




                                                35
Monday, 23 May 2011
Zend Date




                      The date is May 2, 2011 9:13:41 PM.
                       The date is 2 mei 2011 21:13:41.



                                                            36
Monday, 23 May 2011
Zend Timesync




                      2 mai 2011 21:25:09


                                            37
Monday, 23 May 2011
Zend_Locale revisited




                 You can use Zend_Locale_Format to override
                         date and number formatting.

                        I never had any use for it though.....




                                                                 38
Monday, 23 May 2011
Show me the money!
                      Zend_Currency




                                           39
Monday, 23 May 2011
Zend Currency




                         40
Monday, 23 May 2011
Zend Currency




               In the Netherlands you pay with Euro (€).
               And in the UK you pay with British Pound
                              Sterling (£).




                                                           41
Monday, 23 May 2011
Zend Currency




                         42
Monday, 23 May 2011
Zend Currency

                      Please hand me 10.00
                      US Dollar for food and
                             shelter.




                                               43
Monday, 23 May 2011
Zend Currency



                      Got lost in locales?
                        getCurrencyList()
                         getRegionList()
                           getLocale()




                                             44
Monday, 23 May 2011
Never trust a user!
                      Zend_Validate




                                            45
Monday, 23 May 2011
Zend Validate




                         46
Monday, 23 May 2011
Zend Validate




                         47
Monday, 23 May 2011
Measures please?
                      Zend_Measure




                                         48
Monday, 23 May 2011
Zend Measure




                        49
Monday, 23 May 2011
Zend Measure

            A Big Mac’s weight is 200,05 g in the Netherlands.

                          In the USA this would be
                      0.441034755500847600236309 lbs




                                                                 50
Monday, 23 May 2011
Zend Measure




                      Zend_Measure doesn’t utilize locales to give you
                       the correct units, but only the correct number
                                           formats.




                                                                         51
Monday, 23 May 2011
Conclusion




                      52
Monday, 23 May 2011
Image sources
         Achmed http://barenakedislam.wordpress.com/2011/01/27/sweden-muslim-offended-by-ahmed-the-dead-terrorist-demands-compensation-for-mental-
         anguish/jeff-dunham_achmed/

         Clocks http://blogs.manageengine.com/image/501000000062207/timezones.jpg

         Cat http://icanhascheezburger.com

         Pinky & the brain http://blogg.visir.is/purplemagic/category/truarbrogð/

         Zend Framework logo http://www.myskills.be/

         Sneaking in: http://fakeposters.com




                                                                                                                                                 53
Monday, 23 May 2011
Questions ?




                                    54
Monday, 23 May 2011
Thank you!
                                         Contact details:
                                    Twitter: @Martin1982
                      Blog: http://www.martindekeijzer.nl

                        Please give feedback on Joind.in!
                                     http://joind.in/3253

Monday, 23 May 2011