i18n_toolbox - Jens Balvig

2,356 views

Published on

Solving common i18n problems with i18n_toolbox: It provides a set of convenient helpers and active model additions for working with multiple languages

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,356
On SlideShare
0
From Embeds
0
Number of Embeds
1,323
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

i18n_toolbox - Jens Balvig

  1. 1. Solving common i18n problems with i18n_toolbox Jens Balvig - COOKPAD2011 9 7
  2. 2. COOKPAD INTERNATIONAL http://cookpad.it2011 9 7
  3. 3. gem i18n_toolbox2011 9 7
  4. 4. Japanese Logo English Logo2011 9 7
  5. 5. I18n.locale = :ja I18n.locale = :en2011 9 7
  6. 6. <% if I18n.locale == :ja %> <%= image_tag(japanese_logo.jpg)%> <% elsif I18n.locale == :en%> <%= image_tag(english_logo.jpg)%> <% end %> or <%= image_tag("#{I18n.locale}/logo.jpg")%> etc...2011 9 7
  7. 7. <%= image_tag(logo.jpg)%> <img src=/images/logo.jpg/>2011 9 7
  8. 8. <%= image_tag(logo.jpg, :localize => true)%>2011 9 7
  9. 9. <%= image_tag(logo.jpg, :localize => true)%> I18n.locale = :ja I18n.locale = :en <img src=/images/ja/logo.jpg/> <img src=/images/en/logo.jpg/>2011 9 7
  10. 10. 2011 9 7
  11. 11. <%= @user.name%>s Kitchen ?2011 9 7
  12. 12. Bob’s Kitchen Apostrophes Dennis’ Kitchen2011 9 7
  13. 13. Bob’s Kitchen Apostrophes Dennis’ Kitchen + Dionis Chiuas Kitchen I18N La cuisine de Dinois Chiua Dinois Chiua2011 9 7
  14. 14. en: i18n_toolbox: possessive: "%{owner}s %{thing}" possessive_s: "%{owner} %{thing}"2011 9 7
  15. 15. <%= possessive(@user.name, Kitchen)%>2011 9 7
  16. 16. <%= possessive(@user.name, Kitchen)%> I18n.locale = :en => “Dennis’ Kitchen” I18n.locale = :ja => “Dennis Kitchen” I18n.locale = :fr => “Kitchen de Dennis”2011 9 7
  17. 17. 2011 9 7
  18. 18. Would you like to use my pen? 29 Characters2011 9 7
  19. 19. Would you like to use my pen? Anata wa watashi no pen wo tsukaimasu ka?2011 9 7
  20. 20. Anata wa watashi no pen wo tsukaimasu ka? 41 Characters2011 9 7
  21. 21. Anata wa watashi no pen wo tsukaimasu ka?2011 9 7
  22. 22. “You” Anata wa watashi no pen wo tsukaimasu ka?2011 9 7
  23. 23. watashi no pen wo tsukaimasu ka?2011 9 7
  24. 24. “My” watashi no pen wo tsukaimasu ka?2011 9 7
  25. 25. pen wo tsukaimasu ka?2011 9 7
  26. 26. “Pen” + object marker pen wo tsukaimasu ka?2011 9 7
  27. 27. tsukaimasu ka?2011 9 7
  28. 28. question marker tsukaimasu ka?2011 9 7
  29. 29. tsukaimasu?2011 9 7
  30. 30. polite form of “use” u tsukaimasu?2011 9 7
  31. 31. tsukau? = “use?”2011 9 7
  32. 32. hiragana! tsu ka u?2011 9 7
  33. 33. kanji!2011 9 7
  34. 34. 2011 9 7
  35. 35. 2011 9 7
  36. 36. Would you like to use my pen? 29 Characters VS 3 Characters2011 9 7
  37. 37. validates_length_of :title, :maximum => 102011 9 7
  38. 38. Recipe.new(:title => " ").valid? (9 < 10) => true Recipe.new(:title => "Delicious Pancakes").valid? (18 < 10) => false2011 9 7
  39. 39. "SHINJUKU MARUI ONE is the launch pad for Tokyos cool fashion culture. A super- individualistic fashion building unique in the world, SHINJUKU MARUI ONE carries a wide selection of brands with original worldviews such as Gothic, Lolita and Punk, as well as modern kimono. ".length => 271 "SHINJUKU MARUI ONE ".length => 1162011 9 7
  40. 40. locales/ja.yml ja: i18n_toolbox: character_ratio: 0.52011 9 7
  41. 41. validates_length_of :title, :maximum => 20, :localize => true2011 9 7
  42. 42. I18n.locale = :ja Recipe.new(:title => " ").valid? (9 < 10) => true I18n.locale = :en Recipe.new(:title => "Delicious Pancakes").valid? (18 < 20) => true2011 9 7
  43. 43. a2011 9 7
  44. 44. a2011 9 7
  45. 45. <%= truncate(text) %>2011 9 7
  46. 46. <%= truncate(text) %>2011 9 7
  47. 47. locales/ja.yml ja: i18n_toolbox: character_ratio: 0.52011 9 7
  48. 48. <%= truncate(text) %> I18n.locale = :en I18n.locale = :ja2011 9 7
  49. 49. <%= truncate(text, :localize => true) %> I18n.locale = :en I18n.locale = :ja2011 9 7
  50. 50. https://github.com/balvig/i18n_toolbox2011 9 7
  51. 51. Thank you! Jens Balvig - COOKPAD http://tech.cookpad.com @balvig2011 9 7

×