SlideShare a Scribd company logo
1 of 30
Download to read offline
Lokalisierung von
  Ruby on Rails

      Till Vollmer
  Geschäftsführer Codemart GmbH
“The Confusion of Tongues”
                                       by Gustave Doré




Locali[s|z]ing Ruby on Rails
          Till Vollmer
     Managing Director Codemart GmbH
Why?

 64% of people online
   do not speak English!
   (680 Mio people)




Source: http://global-reach.biz


                                    3
Definitions

 Internationalisation i18N
   to handle international text (input, process
   and output)
 Localising L10N
   Process of making an application to fit a
   locale
 Globalisation G11N
   Refers to both


                                                  4
Locale

 Language
 Region
 Time zone
 Time format
 Number display
 Currency



                       5
Locale examples

 Date: 28.Oktober 2006 - 10/28 2006
 Time: 16:45 – 4:45 pm
 Numbers: 100.000,34 - 100,000.34
 Currency: EUR 1.000 - $1,000
 Language: Mädchen – girl




                                       6
History of Text


 ASCII – American Standard
  Code for Information
  Interchange (1967)
 7 Bit with control chars
 developed from
  telegraphic codes




                                           7
History of Text

 Codepages
 Use of 8th Bit to
  introduce all sort of
  characters
 Charsets
 ISO-8859-X
 Problems: No texts
  with mixed
  encodings

                                       8
Unicode

 Have one! system that
  can handle all possible
  characters (1991)
 encodes the underlying
  characters — graphemes
  — rather than the
  variant glyphs
  (renderings) for such
  characters
                      http://ian-albert.com/misc/unichart.php

                                                          9
Unicode

 Codepoints
    Notation: U+xxxxxxxx (hex)
    Only theoretical not an encoding!
    First 256 chars -> ISO 8859-1
    Example: U+0052, U+0075, U+0062, U+0079
    Don‘t get mislead by leading 00 (not 2-
    Bytes)



                                              10
Klingon language - Klingonese

 Was rejected in 2001 by Unicode
  Consortium, but exists in private Area
  U+F8D0 to U+F8FF




   Copyright: Paramount Pictures




                                                         11
Unicode encodings

 Mapping of codepoint into Bytes
    UTF-7 7-bit encoding, suited for transmission and storage only; obsolete
    UTF-8 an 8-bit, variable-width encoding, compatible with ASCII
    UTF-16 a 16-bit, variable-width encoding
    UTF-32/UCS4 functionally identical 32-bit fixed-width encodings
    UCS2 a 16-bit, fixed-width encoding that only supports the BMP
 Most common myth: UTF-8 only needs 2 Bytes
    maximum! It can use up to 4 (or even 6 in ISO-
    10646)



                                                                               12
UTF-8

 Variable length and ASCII fits in
 Up to 4 Bytes (or even 6 in ISO)
ISO 10646 range covered UTF-8 representation
----------------------- --------------------
Bits Hex Min Hex Max Byte Sequence in Binary
 7   00000000   0000007f   0vvvvvvv
11   00000080   000007FF   110vvvvv   10vvvvvv
16   00000800   0000FFFF   1110vvvv   10vvvvvv   10vvvvvv
21   00010000   001FFFFF   11110vvv   10vvvvvv   10vvvvvv 10vvvvvv
26   00200000   03FFFFFF   111110vv   10vvvvvv   10vvvvvv 10vvvvvv 10vvvvvv
31   04000000   7FFFFFFF   1111110v   10vvvvvv   10vvvvvv 10vvvvvv 10vvvvvv 10vvvvvv




                                                                               13
Unicode and Ruby

 The ugly truth is:
    Ruby does not support it.
    But: only Java and .net are truly into
    Unicode
 Ruby supports different encoding for the
  code itself
     $KCODE = ' UTF8‚
     require ' jcode'


                                             14
Bad examples

 quot;Über-Rubyquot;.length # -> 10
 quot;Caféquot;.length # -> 5
 quot;Caféquot;.reverse # -> faC
 quot;Caféquot;[0..3] #-> Caf303
 quot;efficientquot;[0..1] #=> “ef” ? -> effi
 Upcase, reverse, downcase, etc will not
  work


                                            15
Implications

 Be aware that for Ruby UTF-8 is just a
  byte sequence
 e.g. String#length: Watch your validators

=> There are tools to handle Unicode
  correctly!
 Hear more about Unicode and how to
  handle Strings properly tomorrow on the
  Unicode track from Dominic Mitchell

                                            16
Localising Rails apps

    Views

    Models

    Date/Time

    Currency

    Number formating

    Other: e.g. Name display

    Built in stuff


=> Depends on Region and language

                                          17
Built in stuff

    Active Record error messages

    Active Record model names

    strftime (month names, weekdays)

    distance_of_time_in_words

    number_to_currency

    date_select, datetime_select

    Date.*, Time.*

    …

    => be prepared



                                            18
Basic things in Rails

 Database set to utf-8
 database.yml
    encoding: utf8
    => set names = utf8
 set header in filter application.rb:
    @response.headers[quot;Content-Typequot;] = quot;text/html;
    charset=utf-8quot;
 META Tag
    <meta http-equiv=quot;Content-Typequot;
    content=quot;text/html; charset=utf-8quot;/>
 Convince your editor to use UTF-8
  Radrails -> global setting
 Nasty: YAML has some bugs: fixtures ?!

                                                      19
Rails Plugins/Gems

    Globalize

    Localize

    Gloc

    Localization Simplified

    Ruby Gettext

    Ri18N


=> All have different features
      http://wiki.rubyonrails.com/rails/pages/InternationalizationComparison
                                                                      20
Globalize

    Model Translations

    View Translations

    Active Record errors

    Caching

    Currency, Date/Time

    Pluralisation

    All translations are in database

    Locale handling

    View files, ActionMailer

    Comes with prefilled database for ~240 countries


=> Complex, but very powerful

                                                       21
Globalize Examples

Model:
class Model < ActiveRecord::Base
    translates :title, :description, :text
end
Locale.set quot;en-USquot;
model.title= quot;Englishquot;


View:
<%=:mytext.t%>
<%=quot;My text goes herequot;.t%>
<%=_quot;My textquot;%> # gettext syntax


                                             22
Localize

   Only View

   Only strings

   Simple pluralisation, but Proc support

   Translations are in .rb files

=> Simple but efficient if you only need string
   translation
Localization.define('de') do |l|
    l.store 'Hello World', 'Hallo Welt'
    l.store '(time)', lambda { |t|   t.strftime('%H:%M') }
end
_quot;Hello Worldquot;
_quot;(time)quot;



                                                         23
Gloc

     Only View

     Date/Time

     Active Record errors

     Pluralisation rules

     Translation is stored in .yml file


_gloc_rule_default: ' |n| n==1 ? quot;_singlequot; : quot;_pluralquot; '
 man_count_plural: There are %d men.
 man_count_single: There is 1 man.

    lwr(:man_count, 1)   # => There is 1 man.
    lwr(:man_count, 8)   # => There are 8 men.


                                                           24
Localization Simplified

 Localisation for a site that uses only ONE
    language other than English
    Date/Time

    Active Record Error Messages

    Sets connection and HTTP header

    View is normal





                                           25
Ruby Gettext

 Based on GNU gettext
 Translation stored in po/mo files
 A lot of tools exist to translate
 Rails support (Active Records Errors,
  ActionMailer)
 Pluralisation
  _quot;My Textquot;




                                          26
Ri18N

 Again based on gettext, but not so
  complex
 Po files
 NO Rails support
 Purly based on Ruby for Ruby


=> all built in things must be taken care of


                                               27
Recommendations

 Choose wisely
 Patching may occur
 If you need model translation, the only
  choice is Globalize
 Using _() in general is a good idea if you
  plan to go global ant take over the world



                                            28
Summary

 Unicode is the best choice (UTF-8) for
  storing texts
 Ruby is not good at UTF-8 (but not alone)
 Localisation: A lot more than store text
 A lot of plugins exist to help




                                           29
 DEMO




         30

More Related Content

What's hot

Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRubyFrederic Jean
 
Security Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSecurity Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSource Conference
 
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rbHow to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rbHiroshi SHIBATA
 
Mashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMatt Butcher
 
30 Minutes To CPAN
30 Minutes To CPAN30 Minutes To CPAN
30 Minutes To CPANdaoswald
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Touroscon2007
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on RailsAgnieszka Figiel
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Mark Menard
 
Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversTatsuhiko Miyagawa
 
Getting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::CGetting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::Cdaoswald
 
Leave end-to-end testing to Capybara
Leave end-to-end testing to CapybaraLeave end-to-end testing to Capybara
Leave end-to-end testing to CapybaraHiroshi SHIBATA
 
Getting started with Catalyst and extjs
Getting started with Catalyst and extjsGetting started with Catalyst and extjs
Getting started with Catalyst and extjsPeter Edwards
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
O que há de novo no Rails 3
O que há de novo no Rails 3O que há de novo no Rails 3
O que há de novo no Rails 3Hugo Baraúna
 
Gate of Agile Web Development
Gate of Agile Web DevelopmentGate of Agile Web Development
Gate of Agile Web DevelopmentKoichi ITO
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 

What's hot (20)

Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRuby
 
Security Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSecurity Goodness with Ruby on Rails
Security Goodness with Ruby on Rails
 
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rbHow to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rb
 
Mashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMashups with Drupal and QueryPath
Mashups with Drupal and QueryPath
 
30 Minutes To CPAN
30 Minutes To CPAN30 Minutes To CPAN
30 Minutes To CPAN
 
Intro to PSGI and Plack
Intro to PSGI and PlackIntro to PSGI and Plack
Intro to PSGI and Plack
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Tour
 
Debugging on rails
Debugging on railsDebugging on rails
Debugging on rails
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and servers
 
Getting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::CGetting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::C
 
Leave end-to-end testing to Capybara
Leave end-to-end testing to CapybaraLeave end-to-end testing to Capybara
Leave end-to-end testing to Capybara
 
Getting started with Catalyst and extjs
Getting started with Catalyst and extjsGetting started with Catalyst and extjs
Getting started with Catalyst and extjs
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
O que há de novo no Rails 3
O que há de novo no Rails 3O que há de novo no Rails 3
O que há de novo no Rails 3
 
Plack - LPW 2009
Plack - LPW 2009Plack - LPW 2009
Plack - LPW 2009
 
Gate of Agile Web Development
Gate of Agile Web DevelopmentGate of Agile Web Development
Gate of Agile Web Development
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 

Similar to Localizing Ruby on Rails in 64% of the World

Practical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in GroovyPractical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in GroovyGuillaume Laforge
 
Unicode and Collations in MySQL 8.0
Unicode and Collations in MySQL 8.0Unicode and Collations in MySQL 8.0
Unicode and Collations in MySQL 8.0Bernt Marius Johnsen
 
Living in a Multi-lingual World: Internationalization in Web and Desktop Appl...
Living in a Multi-lingual World: Internationalization in Web and Desktop Appl...Living in a Multi-lingual World: Internationalization in Web and Desktop Appl...
Living in a Multi-lingual World: Internationalization in Web and Desktop Appl...adunne
 
Internationalization in Rails 2.2
Internationalization in Rails 2.2Internationalization in Rails 2.2
Internationalization in Rails 2.2Nicolas Jacobeus
 
Living in a multiligual world: Internationalization for Web 2.0 Applications
Living in a multiligual world: Internationalization for Web 2.0 ApplicationsLiving in a multiligual world: Internationalization for Web 2.0 Applications
Living in a multiligual world: Internationalization for Web 2.0 ApplicationsLars Trieloff
 
Scaling a Rails Application from the Bottom Up
Scaling a Rails Application from the Bottom Up Scaling a Rails Application from the Bottom Up
Scaling a Rails Application from the Bottom Up Abhishek Singh
 
MySQL 8.0 & Unicode: Why, what & how
MySQL 8.0 & Unicode: Why, what & howMySQL 8.0 & Unicode: Why, what & how
MySQL 8.0 & Unicode: Why, what & howBernt Marius Johnsen
 
How To Build And Launch A Successful Globalized App From Day One Or All The ...
How To Build And Launch A Successful Globalized App From Day One  Or All The ...How To Build And Launch A Successful Globalized App From Day One  Or All The ...
How To Build And Launch A Successful Globalized App From Day One Or All The ...agileware
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9tomaspavelka
 
What's New in Web Development
What's New in Web DevelopmentWhat's New in Web Development
What's New in Web DevelopmentKonstantin Käfer
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRubyAmit Solanki
 
Rails Conf Europe 2007 Notes
Rails Conf  Europe 2007  NotesRails Conf  Europe 2007  Notes
Rails Conf Europe 2007 NotesRoss Lawley
 
John Davies Last Minute Fill In For Sick Speaker
John Davies Last Minute Fill In For Sick SpeakerJohn Davies Last Minute Fill In For Sick Speaker
John Davies Last Minute Fill In For Sick Speakerdeimos
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The JvmQConLondon2008
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Patrick Chanezon
 
Rails hosting
Rails hostingRails hosting
Rails hostingwonko
 

Similar to Localizing Ruby on Rails in 64% of the World (20)

Practical Groovy DSL
Practical Groovy DSLPractical Groovy DSL
Practical Groovy DSL
 
Practical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in GroovyPractical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in Groovy
 
Unicode and Collations in MySQL 8.0
Unicode and Collations in MySQL 8.0Unicode and Collations in MySQL 8.0
Unicode and Collations in MySQL 8.0
 
Living in a Multi-lingual World: Internationalization in Web and Desktop Appl...
Living in a Multi-lingual World: Internationalization in Web and Desktop Appl...Living in a Multi-lingual World: Internationalization in Web and Desktop Appl...
Living in a Multi-lingual World: Internationalization in Web and Desktop Appl...
 
Internationalization in Rails 2.2
Internationalization in Rails 2.2Internationalization in Rails 2.2
Internationalization in Rails 2.2
 
Living in a multiligual world: Internationalization for Web 2.0 Applications
Living in a multiligual world: Internationalization for Web 2.0 ApplicationsLiving in a multiligual world: Internationalization for Web 2.0 Applications
Living in a multiligual world: Internationalization for Web 2.0 Applications
 
Scaling a Rails Application from the Bottom Up
Scaling a Rails Application from the Bottom Up Scaling a Rails Application from the Bottom Up
Scaling a Rails Application from the Bottom Up
 
MySQL 8.0 & Unicode: Why, what & how
MySQL 8.0 & Unicode: Why, what & howMySQL 8.0 & Unicode: Why, what & how
MySQL 8.0 & Unicode: Why, what & how
 
How To Build And Launch A Successful Globalized App From Day One Or All The ...
How To Build And Launch A Successful Globalized App From Day One  Or All The ...How To Build And Launch A Successful Globalized App From Day One  Or All The ...
How To Build And Launch A Successful Globalized App From Day One Or All The ...
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9
 
What's New in Web Development
What's New in Web DevelopmentWhat's New in Web Development
What's New in Web Development
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
Rails Conf Europe 2007 Notes
Rails Conf  Europe 2007  NotesRails Conf  Europe 2007  Notes
Rails Conf Europe 2007 Notes
 
XTech May 2008
XTech May 2008XTech May 2008
XTech May 2008
 
Amoocon May 2009 Germany
Amoocon May 2009   GermanyAmoocon May 2009   Germany
Amoocon May 2009 Germany
 
I35s
I35sI35s
I35s
 
John Davies Last Minute Fill In For Sick Speaker
John Davies Last Minute Fill In For Sick SpeakerJohn Davies Last Minute Fill In For Sick Speaker
John Davies Last Minute Fill In For Sick Speaker
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The Jvm
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?
 
Rails hosting
Rails hostingRails hosting
Rails hosting
 

More from RubyOnRails_dude (14)

Slides
SlidesSlides
Slides
 
State Of Rails 05
State Of Rails 05State Of Rails 05
State Of Rails 05
 
Rails Conf Talk Slides
Rails Conf Talk SlidesRails Conf Talk Slides
Rails Conf Talk Slides
 
Secretsofrubyonrails
SecretsofrubyonrailsSecretsofrubyonrails
Secretsofrubyonrails
 
Thomas Fuchs Presentation
Thomas Fuchs PresentationThomas Fuchs Presentation
Thomas Fuchs Presentation
 
Ugo Cei Presentation
Ugo Cei PresentationUgo Cei Presentation
Ugo Cei Presentation
 
Extractingrails
ExtractingrailsExtractingrails
Extractingrails
 
Marcel Molina Jr. Presentation
Marcel Molina Jr. PresentationMarcel Molina Jr. Presentation
Marcel Molina Jr. Presentation
 
Rails4 Days
Rails4 DaysRails4 Days
Rails4 Days
 
Programminghappiness
ProgramminghappinessProgramminghappiness
Programminghappiness
 
Pursuitofbeauty
PursuitofbeautyPursuitofbeauty
Pursuitofbeauty
 
Dan Webb Presentation
Dan Webb PresentationDan Webb Presentation
Dan Webb Presentation
 
Fisl6
Fisl6Fisl6
Fisl6
 
Worldofresources
WorldofresourcesWorldofresources
Worldofresources
 

Recently uploaded

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Localizing Ruby on Rails in 64% of the World

  • 1. Lokalisierung von Ruby on Rails Till Vollmer Geschäftsführer Codemart GmbH
  • 2. “The Confusion of Tongues” by Gustave Doré Locali[s|z]ing Ruby on Rails Till Vollmer Managing Director Codemart GmbH
  • 3. Why?  64% of people online do not speak English! (680 Mio people) Source: http://global-reach.biz 3
  • 4. Definitions  Internationalisation i18N to handle international text (input, process and output)  Localising L10N Process of making an application to fit a locale  Globalisation G11N Refers to both 4
  • 5. Locale  Language  Region  Time zone  Time format  Number display  Currency 5
  • 6. Locale examples  Date: 28.Oktober 2006 - 10/28 2006  Time: 16:45 – 4:45 pm  Numbers: 100.000,34 - 100,000.34  Currency: EUR 1.000 - $1,000  Language: Mädchen – girl 6
  • 7. History of Text  ASCII – American Standard Code for Information Interchange (1967)  7 Bit with control chars  developed from telegraphic codes 7
  • 8. History of Text  Codepages  Use of 8th Bit to introduce all sort of characters  Charsets  ISO-8859-X  Problems: No texts with mixed encodings 8
  • 9. Unicode  Have one! system that can handle all possible characters (1991)  encodes the underlying characters — graphemes — rather than the variant glyphs (renderings) for such characters http://ian-albert.com/misc/unichart.php 9
  • 10. Unicode  Codepoints Notation: U+xxxxxxxx (hex) Only theoretical not an encoding! First 256 chars -> ISO 8859-1 Example: U+0052, U+0075, U+0062, U+0079 Don‘t get mislead by leading 00 (not 2- Bytes) 10
  • 11. Klingon language - Klingonese  Was rejected in 2001 by Unicode Consortium, but exists in private Area U+F8D0 to U+F8FF Copyright: Paramount Pictures 11
  • 12. Unicode encodings  Mapping of codepoint into Bytes UTF-7 7-bit encoding, suited for transmission and storage only; obsolete UTF-8 an 8-bit, variable-width encoding, compatible with ASCII UTF-16 a 16-bit, variable-width encoding UTF-32/UCS4 functionally identical 32-bit fixed-width encodings UCS2 a 16-bit, fixed-width encoding that only supports the BMP  Most common myth: UTF-8 only needs 2 Bytes maximum! It can use up to 4 (or even 6 in ISO- 10646) 12
  • 13. UTF-8  Variable length and ASCII fits in  Up to 4 Bytes (or even 6 in ISO) ISO 10646 range covered UTF-8 representation ----------------------- -------------------- Bits Hex Min Hex Max Byte Sequence in Binary 7 00000000 0000007f 0vvvvvvv 11 00000080 000007FF 110vvvvv 10vvvvvv 16 00000800 0000FFFF 1110vvvv 10vvvvvv 10vvvvvv 21 00010000 001FFFFF 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv 26 00200000 03FFFFFF 111110vv 10vvvvvv 10vvvvvv 10vvvvvv 10vvvvvv 31 04000000 7FFFFFFF 1111110v 10vvvvvv 10vvvvvv 10vvvvvv 10vvvvvv 10vvvvvv 13
  • 14. Unicode and Ruby  The ugly truth is: Ruby does not support it. But: only Java and .net are truly into Unicode  Ruby supports different encoding for the code itself $KCODE = ' UTF8‚ require ' jcode' 14
  • 15. Bad examples  quot;Über-Rubyquot;.length # -> 10  quot;Caféquot;.length # -> 5  quot;Caféquot;.reverse # -> faC  quot;Caféquot;[0..3] #-> Caf303  quot;efficientquot;[0..1] #=> “ef” ? -> effi  Upcase, reverse, downcase, etc will not work 15
  • 16. Implications  Be aware that for Ruby UTF-8 is just a byte sequence  e.g. String#length: Watch your validators => There are tools to handle Unicode correctly!  Hear more about Unicode and how to handle Strings properly tomorrow on the Unicode track from Dominic Mitchell 16
  • 17. Localising Rails apps Views  Models  Date/Time  Currency  Number formating  Other: e.g. Name display  Built in stuff  => Depends on Region and language 17
  • 18. Built in stuff Active Record error messages  Active Record model names  strftime (month names, weekdays)  distance_of_time_in_words  number_to_currency  date_select, datetime_select  Date.*, Time.*  …  => be prepared  18
  • 19. Basic things in Rails  Database set to utf-8  database.yml encoding: utf8 => set names = utf8  set header in filter application.rb: @response.headers[quot;Content-Typequot;] = quot;text/html; charset=utf-8quot;  META Tag <meta http-equiv=quot;Content-Typequot; content=quot;text/html; charset=utf-8quot;/>  Convince your editor to use UTF-8 Radrails -> global setting  Nasty: YAML has some bugs: fixtures ?! 19
  • 20. Rails Plugins/Gems Globalize  Localize  Gloc  Localization Simplified  Ruby Gettext  Ri18N  => All have different features http://wiki.rubyonrails.com/rails/pages/InternationalizationComparison 20
  • 21. Globalize Model Translations  View Translations  Active Record errors  Caching  Currency, Date/Time  Pluralisation  All translations are in database  Locale handling  View files, ActionMailer  Comes with prefilled database for ~240 countries  => Complex, but very powerful 21
  • 22. Globalize Examples Model: class Model < ActiveRecord::Base translates :title, :description, :text end Locale.set quot;en-USquot; model.title= quot;Englishquot; View: <%=:mytext.t%> <%=quot;My text goes herequot;.t%> <%=_quot;My textquot;%> # gettext syntax 22
  • 23. Localize Only View  Only strings  Simple pluralisation, but Proc support  Translations are in .rb files  => Simple but efficient if you only need string translation Localization.define('de') do |l| l.store 'Hello World', 'Hallo Welt' l.store '(time)', lambda { |t| t.strftime('%H:%M') } end _quot;Hello Worldquot; _quot;(time)quot; 23
  • 24. Gloc Only View  Date/Time  Active Record errors  Pluralisation rules  Translation is stored in .yml file  _gloc_rule_default: ' |n| n==1 ? quot;_singlequot; : quot;_pluralquot; ' man_count_plural: There are %d men. man_count_single: There is 1 man. lwr(:man_count, 1) # => There is 1 man. lwr(:man_count, 8) # => There are 8 men. 24
  • 25. Localization Simplified  Localisation for a site that uses only ONE language other than English Date/Time  Active Record Error Messages  Sets connection and HTTP header  View is normal  25
  • 26. Ruby Gettext  Based on GNU gettext  Translation stored in po/mo files  A lot of tools exist to translate  Rails support (Active Records Errors, ActionMailer)  Pluralisation _quot;My Textquot; 26
  • 27. Ri18N  Again based on gettext, but not so complex  Po files  NO Rails support  Purly based on Ruby for Ruby => all built in things must be taken care of 27
  • 28. Recommendations  Choose wisely  Patching may occur  If you need model translation, the only choice is Globalize  Using _() in general is a good idea if you plan to go global ant take over the world 28
  • 29. Summary  Unicode is the best choice (UTF-8) for storing texts  Ruby is not good at UTF-8 (but not alone)  Localisation: A lot more than store text  A lot of plugins exist to help 29
  • 30.  DEMO 30