SlideShare a Scribd company logo
1 of 21
rambling on rails’ i18n
  décousue discussion à propos de rails i18n
SRC 2012 Reject Conf
          Starring Alan Gardner


TICKETS AVAILABLE NOW!
  http://j.mp/scotruby-reject
rambling on rails’ i18n
  décousue discussion à propos de rails i18n
i18n l10n- wtf?

internationalisation is the process of preparing your
application for localisation
localisation is the process of providing locale / language
specific content within your internationalised application
you internationalise so that you can localise
Internationalisation in Rails

baked in, which is great!
easy to get started with
plenty of documentation
Contrived Overview!
Where the magic happens

Rails automatically loads any .rb or .yml files in config/
locales and makes them available to the i18n and l10n APIs.
rails-i18n gem will give you locale files for a fair few
languages including translations of Active Record’s error
messages, saving you effort
Boilerplate
     #in config/locales/en.yml

     en:
       good_afternoon: good afternoon


     #in config/locales/fr.yml

     fr:
       good_afternoon: bonjour


     #in config/locales/ja.yml

     ja:
       good_afternoon: こにちわ
Boilerplate
 #in config/routes.rb

 Example::Application.routes.draw do
   root :to => ‘example#greet`
 end

 #in app/controller/example_controller

 class ExampleController < ApplicationController

  def greet
    render :text => t(:good_afternoon)
  end

 end
What’s that given us?

Three different locales, each with a localised value for the
internationalised key ‘:good_afternoon’
A controller which will serve up this localised value when
someone visits it
The default locale is ‘en’ so the user will see ‘good
afternoon’
Make them go

 #in app/controller/example_controller

 class ExampleController < ApplicationController

  def greet
    I18n.locale = params[:locale] || ‘en’
    render :text => t(:good_afternoon)
  end

 end
Make them go

 #in app/controller/example_controller

 class ExampleController < ApplicationController

  def greet
    I18n.locale = params[:locale] || ‘en’
    render :text => t(:good_afternoon)
  end

 end
So now what?

http://localhost:3000/?locale=fr would see “bonjour”
http://localhost:3000/?locale=jp would see “こにちわ”

Anyone else would see “good afternoon”
So that’s the basics
It’s actually quite hard
Here’s the fluffy bit
Whys and Whatfors

more people don’t speak English than do - why limit your
audience?
being forced to think about how information will be
presented in various locales is a fun-fun challenge
it forces you to move view-level detail out into dictionaries
and away from your models and such - this is good!
Whys and Whatfors

it’s hard work to internationalise everything but really
rewarding if you have the need to do it
you’ll know yourself if the project you’re working with needs
to be i18n’d
personally, I always default to i18ning everything, but that’s
because I’m a masochist
Further Reading

Rails i18n guide: http://guides.rubyonrails.org/i18n.html
Rails i18n locales repository https://github.com/svenfuchs/
rails-i18n
Ruby i18n wiki: http://ruby-i18n.org/wiki
Got any questions?
I’ve not covered a lot, ask about specifics!
ありがとう!

@ryanstenhouse on Twitter
@HHRy on GitHub
http://ryanstenhouse.eu

More Related Content

Viewers also liked

Testing Equipment
Testing EquipmentTesting Equipment
Testing EquipmentRk Oberoi
 
My visit to nepal
My visit to nepalMy visit to nepal
My visit to nepalrrmahitcha
 
50 million missing women
50 million missing women50 million missing women
50 million missing womenMitu Khosla
 
Sarifna Blogspot
Sarifna BlogspotSarifna Blogspot
Sarifna BlogspotSarifna
 
Systems Technology Forum Construction Documents
Systems Technology Forum Construction DocumentsSystems Technology Forum Construction Documents
Systems Technology Forum Construction Documentselliegirl07
 
Presentacion en power point
Presentacion en power pointPresentacion en power point
Presentacion en power pointfvalarezo03
 
Portable metal hardness testers
Portable metal hardness testersPortable metal hardness testers
Portable metal hardness testersBede Kortegast
 
Dossier de production
Dossier de productionDossier de production
Dossier de productionYoann Connord
 
Testing/Manufacture/Hepa Filter Packaging Tester
Testing/Manufacture/Hepa Filter Packaging TesterTesting/Manufacture/Hepa Filter Packaging Tester
Testing/Manufacture/Hepa Filter Packaging Testerfec2020
 
asd Practicepowerpoint
asd Practicepowerpointasd Practicepowerpoint
asd PracticepowerpointKinjal Gor
 
Testing/Manufacture/Footwear Testing Equipments
Testing/Manufacture/Footwear Testing EquipmentsTesting/Manufacture/Footwear Testing Equipments
Testing/Manufacture/Footwear Testing Equipmentsfec2020
 
Anticonceptivos
AnticonceptivosAnticonceptivos
Anticonceptivoserikawera
 
Testing/Manufacture/PlasticTesting Equipmetns
Testing/Manufacture/PlasticTesting EquipmetnsTesting/Manufacture/PlasticTesting Equipmetns
Testing/Manufacture/PlasticTesting Equipmetnsfec2020
 
Testing/Manufacture/Closed and open cells content
Testing/Manufacture/Closed and open cells contentTesting/Manufacture/Closed and open cells content
Testing/Manufacture/Closed and open cells contentfec2020
 
Testing/Manufacture/Paper Testing Equipments
Testing/Manufacture/Paper Testing EquipmentsTesting/Manufacture/Paper Testing Equipments
Testing/Manufacture/Paper Testing Equipmentsfec2020
 

Viewers also liked (18)

Diriodeumco
DiriodeumcoDiriodeumco
Diriodeumco
 
Testing Equipment
Testing EquipmentTesting Equipment
Testing Equipment
 
My visit to nepal
My visit to nepalMy visit to nepal
My visit to nepal
 
50 million missing women
50 million missing women50 million missing women
50 million missing women
 
Double vision
Double visionDouble vision
Double vision
 
Sarifna Blogspot
Sarifna BlogspotSarifna Blogspot
Sarifna Blogspot
 
Systems Technology Forum Construction Documents
Systems Technology Forum Construction DocumentsSystems Technology Forum Construction Documents
Systems Technology Forum Construction Documents
 
Presentacion en power point
Presentacion en power pointPresentacion en power point
Presentacion en power point
 
Portable metal hardness testers
Portable metal hardness testersPortable metal hardness testers
Portable metal hardness testers
 
Dossier de production
Dossier de productionDossier de production
Dossier de production
 
Testing/Manufacture/Hepa Filter Packaging Tester
Testing/Manufacture/Hepa Filter Packaging TesterTesting/Manufacture/Hepa Filter Packaging Tester
Testing/Manufacture/Hepa Filter Packaging Tester
 
asd Practicepowerpoint
asd Practicepowerpointasd Practicepowerpoint
asd Practicepowerpoint
 
Testing/Manufacture/Footwear Testing Equipments
Testing/Manufacture/Footwear Testing EquipmentsTesting/Manufacture/Footwear Testing Equipments
Testing/Manufacture/Footwear Testing Equipments
 
SIS
SISSIS
SIS
 
Anticonceptivos
AnticonceptivosAnticonceptivos
Anticonceptivos
 
Testing/Manufacture/PlasticTesting Equipmetns
Testing/Manufacture/PlasticTesting EquipmetnsTesting/Manufacture/PlasticTesting Equipmetns
Testing/Manufacture/PlasticTesting Equipmetns
 
Testing/Manufacture/Closed and open cells content
Testing/Manufacture/Closed and open cells contentTesting/Manufacture/Closed and open cells content
Testing/Manufacture/Closed and open cells content
 
Testing/Manufacture/Paper Testing Equipments
Testing/Manufacture/Paper Testing EquipmentsTesting/Manufacture/Paper Testing Equipments
Testing/Manufacture/Paper Testing Equipments
 

Similar to Rails i18n

Internationalization in Rails 2.2
Internationalization in Rails 2.2Internationalization in Rails 2.2
Internationalization in Rails 2.2Belighted
 
Ruby i18n - internationalization for ruby
Ruby i18n - internationalization for rubyRuby i18n - internationalization for ruby
Ruby i18n - internationalization for rubyLingoHub
 
Multi Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoMulti Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoPaul Marden
 
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
 
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
 
Developing Multilingual Applications
Developing Multilingual ApplicationsDeveloping Multilingual Applications
Developing Multilingual ApplicationsPriyank Kapadia
 
symfony : I18n And L10n
symfony : I18n And L10nsymfony : I18n And L10n
symfony : I18n And L10nWildan Maulana
 
I18n
I18nI18n
I18nsoon
 
The Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core ApiThe Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core ApiNTT DATA Americas
 
KazooCon 2014 - Kazoo Scalability
KazooCon 2014 - Kazoo ScalabilityKazooCon 2014 - Kazoo Scalability
KazooCon 2014 - Kazoo Scalability2600Hz
 
Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation Rebaz Najeeb
 
BIS07 Application Development - I
BIS07 Application Development - IBIS07 Application Development - I
BIS07 Application Development - IPrithwis Mukerjee
 
API and Microservices Meetup - To Code or Low Code?
API and Microservices Meetup - To Code or Low Code?API and Microservices Meetup - To Code or Low Code?
API and Microservices Meetup - To Code or Low Code?Ian Vanstone
 
i18n was the missing piece_ make your apps accessible to 70%+ of the users in...
i18n was the missing piece_ make your apps accessible to 70%+ of the users in...i18n was the missing piece_ make your apps accessible to 70%+ of the users in...
i18n was the missing piece_ make your apps accessible to 70%+ of the users in...Arisa Fukuzaki
 
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
 
Internationalisation In Rails
Internationalisation In RailsInternationalisation In Rails
Internationalisation In RailsRishav Dixit
 
Internationalizing Your AngularJS App
Internationalizing Your AngularJS AppInternationalizing Your AngularJS App
Internationalizing Your AngularJS AppSarah Hudson
 

Similar to Rails i18n (20)

Internationalization in Rails 2.2
Internationalization in Rails 2.2Internationalization in Rails 2.2
Internationalization in Rails 2.2
 
Ruby i18n - internationalization for ruby
Ruby i18n - internationalization for rubyRuby i18n - internationalization for ruby
Ruby i18n - internationalization for ruby
 
ColdBox i18N
ColdBox i18N ColdBox i18N
ColdBox i18N
 
Multi Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoMulti Lingual Websites In Umbraco
Multi Lingual Websites In Umbraco
 
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
 
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...
 
Developing Multilingual Applications
Developing Multilingual ApplicationsDeveloping Multilingual Applications
Developing Multilingual Applications
 
symfony : I18n And L10n
symfony : I18n And L10nsymfony : I18n And L10n
symfony : I18n And L10n
 
I18n
I18nI18n
I18n
 
The Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core ApiThe Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core Api
 
KazooCon 2014 - Kazoo Scalability
KazooCon 2014 - Kazoo ScalabilityKazooCon 2014 - Kazoo Scalability
KazooCon 2014 - Kazoo Scalability
 
Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
BIS07 Application Development - I
BIS07 Application Development - IBIS07 Application Development - I
BIS07 Application Development - I
 
API and Microservices Meetup - To Code or Low Code?
API and Microservices Meetup - To Code or Low Code?API and Microservices Meetup - To Code or Low Code?
API and Microservices Meetup - To Code or Low Code?
 
i18n was the missing piece_ make your apps accessible to 70%+ of the users in...
i18n was the missing piece_ make your apps accessible to 70%+ of the users in...i18n was the missing piece_ make your apps accessible to 70%+ of the users in...
i18n was the missing piece_ make your apps accessible to 70%+ of the users in...
 
Otto AI
Otto AIOtto AI
Otto AI
 
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 ...
 
Internationalisation In Rails
Internationalisation In RailsInternationalisation In Rails
Internationalisation In Rails
 
Internationalizing Your AngularJS App
Internationalizing Your AngularJS AppInternationalizing Your AngularJS App
Internationalizing Your AngularJS App
 

Recently uploaded

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
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
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Recently uploaded (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
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...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
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 ...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Rails i18n

  • 1. rambling on rails’ i18n décousue discussion à propos de rails i18n
  • 2. SRC 2012 Reject Conf Starring Alan Gardner TICKETS AVAILABLE NOW! http://j.mp/scotruby-reject
  • 3. rambling on rails’ i18n décousue discussion à propos de rails i18n
  • 4. i18n l10n- wtf? internationalisation is the process of preparing your application for localisation localisation is the process of providing locale / language specific content within your internationalised application you internationalise so that you can localise
  • 5. Internationalisation in Rails baked in, which is great! easy to get started with plenty of documentation
  • 7. Where the magic happens Rails automatically loads any .rb or .yml files in config/ locales and makes them available to the i18n and l10n APIs. rails-i18n gem will give you locale files for a fair few languages including translations of Active Record’s error messages, saving you effort
  • 8. Boilerplate #in config/locales/en.yml en: good_afternoon: good afternoon #in config/locales/fr.yml fr: good_afternoon: bonjour #in config/locales/ja.yml ja: good_afternoon: こにちわ
  • 9. Boilerplate #in config/routes.rb Example::Application.routes.draw do root :to => ‘example#greet` end #in app/controller/example_controller class ExampleController < ApplicationController def greet render :text => t(:good_afternoon) end end
  • 10. What’s that given us? Three different locales, each with a localised value for the internationalised key ‘:good_afternoon’ A controller which will serve up this localised value when someone visits it The default locale is ‘en’ so the user will see ‘good afternoon’
  • 11. Make them go #in app/controller/example_controller class ExampleController < ApplicationController def greet I18n.locale = params[:locale] || ‘en’ render :text => t(:good_afternoon) end end
  • 12. Make them go #in app/controller/example_controller class ExampleController < ApplicationController def greet I18n.locale = params[:locale] || ‘en’ render :text => t(:good_afternoon) end end
  • 13. So now what? http://localhost:3000/?locale=fr would see “bonjour” http://localhost:3000/?locale=jp would see “こにちわ” Anyone else would see “good afternoon”
  • 14. So that’s the basics
  • 17. Whys and Whatfors more people don’t speak English than do - why limit your audience? being forced to think about how information will be presented in various locales is a fun-fun challenge it forces you to move view-level detail out into dictionaries and away from your models and such - this is good!
  • 18. Whys and Whatfors it’s hard work to internationalise everything but really rewarding if you have the need to do it you’ll know yourself if the project you’re working with needs to be i18n’d personally, I always default to i18ning everything, but that’s because I’m a masochist
  • 19. Further Reading Rails i18n guide: http://guides.rubyonrails.org/i18n.html Rails i18n locales repository https://github.com/svenfuchs/ rails-i18n Ruby i18n wiki: http://ruby-i18n.org/wiki
  • 20. Got any questions? I’ve not covered a lot, ask about specifics!
  • 21. ありがとう! @ryanstenhouse on Twitter @HHRy on GitHub http://ryanstenhouse.eu

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n