Translating ruby OSS

655 views

Published on

Slides from my presentation for #parisrb on the 6th Feb 2012

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

No Downloads
Views
Total views
655
On SlideShare
0
From Embeds
0
Number of Embeds
79
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • - Anecdote sur le dessin\n- Here presented as two different people, but are often just 1 person\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • - I18n Project Vs. In project app\n
  • - I18n Project Vs. In project app\n
  • - I18n Project Vs. In project app\n
  • - I18n Project Vs. In project app\n
  • - I18n Project Vs. In project app\n
  • - Why do we need a default locale in the first place?\n - It’s the base that all translations are created from\n
  • - Why do we need a default locale in the first place?\n - It’s the base that all translations are created from\n
  • English is the universal language\n
  • English is the universal language\n
  • English is the universal language\n
  • NOthing is purer? right? WRONG!!\n
  • NOthing is purer? right? WRONG!!\n
  • - Rails says en even though it is really en-US.\n- Change happend end of 2008, at the time i18n didn’t support language fallbacks\n- rails-i18n marks the different englishes\n- use whatever locale for your own projects, but en-US for OSS\n
  • \n
  • \n
  • \n
  • \n
  • A locale has a cultural or territorial component\nBrazilian portuguese, canadian french, swiss!\n
  • - There are of course a load of other backends\n- Implement your own by writing a get/set\n
  • - There are of course a load of other backends\n- Implement your own by writing a get/set\n
  • - There are of course a load of other backends\n- Implement your own by writing a get/set\n
  • - There are of course a load of other backends\n- Implement your own by writing a get/set\n
  • - Might have seen this upgrading to 1.9.2\n- Psych included in 1.9.2 and default\n- Conforms to YAML 1.0\n- Syck to be removed from 1.9.3\n
  • - Might have seen this upgrading to 1.9.2\n- Psych included in 1.9.2 and default\n- Conforms to YAML 1.0\n- Syck to be removed from 1.9.3\n
  • - rails-i18n is generated with Locale \n- is compatible since it’s the output from Psych\n\n- it would be nice to be able to foresee these file problems\n- Syntax errors aren’t the only problem (ex: indentation)\n
  • - rspec shared examples\n
  • - rspec shared examples\n
  • - Advantage is that I don’t need to be able to read the locale file to know it’s valid\n- It’s integrated into my regular development workflow\n- autotest, guard, travis-ci\n
  • - Advantage is that I don’t need to be able to read the locale file to know it’s valid\n- It’s integrated into my regular development workflow\n- autotest, guard, travis-ci\n
  • \n
  • \n
  • Looks i18n doesn’t understand the proper grammer\n
  • Looks i18n doesn’t understand the proper grammer\n
  • Looks i18n doesn’t understand the proper grammer\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • You build the project and it creates ruby / yaml\n
  • You build the project and it creates ruby / yaml\n
  • - ruby-cldr formats for i18n\n- By inserting this into config/locales we get proper pluralization rules\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Translating ruby OSS

    1. 1. TRANSLATING RUBY OSS Christopher Dell @tigrish
    2. 2. DISCLAIMER WOW!I cofounded this Try it, it’s awesome! http://www.localeapp.com
    3. 3. SOME TRANSLATED PROJECTS
    4. 4. SOME TRANSLATED PROJECTS Gems- rails- devise- will-paginate
    5. 5. SOME TRANSLATED PROJECTS Gems Apps- rails - ChiliProject- devise - Spree- will-paginate - LocomotiveCMS
    6. 6. SOME TRANSLATED PROJECTS Gems Apps CLIs- rails - ChiliProject - remarkable- devise - Spree -?- will-paginate - LocomotiveCMS
    7. 7. SOME TRANSLATED PROJECTS Gems Apps CLIs- rails - ChiliProject - remarkable- devise - Spree -?- will-paginate - LocomotiveCMS i18n gem
    8. 8. THE TERRIBLE TWO Terrance Phillip“the translator” “the programmer”
    9. 9. THE PROGRAMMER
    10. 10. THE PROGRAMMERis involved in internationalization
    11. 11. THE PROGRAMMERis involved in internationalization i18n
    12. 12. THE TRANSLATOR
    13. 13. THE TRANSLATOR is involved in localization
    14. 14. THE TRANSLATOR is involved in localization l10n
    15. 15. FIGHT!
    16. 16. heart will go on editionnot a real project celine-db
    17. 17. heart will go on editionnot a real project celine-db-i18n
    18. 18. What should our default language be?
    19. 19. What should our default language be? ...probably English
    20. 20.
    21. 21. ✔ ✔
    22. 22. ✔ ✔ ?
    23. 23. PROO00OOOOOT
    24. 24. All your base are belong to en-US
    25. 25. Colour ColourLocalisation Localization
    26. 26. Colour ColourLocalisation LocalizationJam Jelly
    27. 27. Colour ColourLocalisation LocalizationJam JellyJelly Jell-o
    28. 28. Colour Colour Localisation Localization Jam Jelly Jelly Jell-o06/02/2012 6th Feb 2012 2nd Jun 2012
    29. 29. LANGUAGES ≠LOCALES
    30. 30. Let’s use YAML for storage and distribution
    31. 31. Let’s use YAML for storage and distribution• Ruby std lib
    32. 32. Let’s use YAML for storage and distribution• Ruby std lib• Used by i18n’s Simple Backend
    33. 33. Let’s use YAML for storage and distribution• Ruby std lib• Used by i18n’s Simple Backend• Text file, simple structure
    34. 34. /lib/ruby/1.9.2/psych.rb:148:in `parse: couldnt parse YAML at line 182 column 9 (Psych::SyntaxError)
    35. 35. I18N-SPECgithub.com/tigrish/i18n-spec
    36. 36. I18N-SPEC github.com/tigrish/i18n-specdescribe "config/locales/en.yml" do it { should be_parseable } it { should have_valid_pluralization_keys } it { should have_one_top_level_namespace } it { should be_named_like_top_level_namespace } it { should_not have_legacy_interpolations }end
    37. 37. I18N-SPEC github.com/tigrish/i18n-specdescribe "config/locales/en.yml" do it { should be_parseable } it { should have_valid_pluralization_keys } it { should have_one_top_level_namespace } it { should be_named_like_top_level_namespace } it { should_not have_legacy_interpolations }endDir.glob(config/locales/*.yml) do |locale_file| describe "a locale file" do it_behaves_like a valid locale file, locale_file endend
    38. 38. I18N-SPECgithub.com/tigrish/i18n-spec
    39. 39. I18N-SPEC github.com/tigrish/i18n-specdescribe "config/locales/fr.yml" do it { should be_a_subset_of ‘config/locales/en.yml’ }end
    40. 40. I18N-SPEC github.com/tigrish/i18n-specdescribe "config/locales/fr.yml" do it { should be_a_subset_of ‘config/locales/en.yml’ }enddescribe "config/locales/fr.yml" do it { should be_a_complete_translation_of ‘config/locales/en.yml’ }end
    41. 41. There’s a grammar error !
    42. 42. There’s a grammar error ! In French, the phrase :“1.2 regards fataux” should be : “1.2 regard fatal”
    43. 43. <?= t(:regard_fatal, :count => 1.2) ?>
    44. 44. <?= t(:regard_fatal, :count => 1.2) ?>regard_fatal: one: 1 regard fatal other: %{count} regards fataux
    45. 45. <?= t(:regard_fatal, :count => 1.2) ?> WTF?regard_fatal: one: 1 regard fatal other: %{count} regards fataux
    46. 46. CLDRUnicode Common Locale Data Repository cldr.unicode.org
    47. 47. CLDRUnicode Common Locale Data Repository cldr.unicode.org • Dates, Times, Time Zones • Numbers, Currencies • Sorting • Languages, Countries • Pluralizations • Charsets, Collations • Transliterations
    48. 48. CLDR
    49. 49. CLDR
    50. 50. CLDRXML
    51. 51. CLDRXMLJava
    52. 52. RUBY-CLDRgithub.com/svenfuchs/ruby-cldr
    53. 53. data/fr/plurals.rb{ :fr => { :i18n => { :plural => { :keys => [:one, :other], :rule => lambda { |n| n.between?(0, 2) && n != 2 :one : :other } } } }}
    54. 54. if n % 10 == 1 && n % 100 != 11 :oneelsif [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100) :fewelsif n % 10 == 0 || [5, 6, 7, 8, 9].include?(n % 10) || [11, 12, 13, 14].include?(n % 100) :manyelse :otherend
    55. 55. if n % 10 == 1 && n % 100 != 11 :oneelsif [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100) :fewelsif n % 10 == 0 || [5, 6, 7, 8, 9].include?(n % 10) || [11, 12, 13, 14].include?(n % 100) :manyelse :otherend0 : many 10 : many 20 : many 30 : many1 : one 11 : many 21 : one 30.5 : other2 : few 12 : many 22 : few3 : few 13 : many 23 : few4 : few 14 : many 24 : few5 : many 15 : many 25 : many6 : many 16 : many 26 : many7 : many 17 : many 27 : many8 : many 18 : many 28 : many9 : many 19 : many 29 : many
    56. 56. kittens: zero: Sorry, no kittens other: %{count} kittens
    57. 57. <? if kittens.size > 0 ?> <?= t :kittens,kittens: :count => kittens.size ?%> zero: Sorry, no kittens <? else ?> other: %{count} kittens <?= t :no_kittens ?%> <? end ?>
    58. 58. <? if kittens.size > 0 ?> <?= t :kittens,kittens: :count => kittens.size ?%> zero: Sorry, no kittens <? else ?> other: %{count} kittens <?= t :no_kittens ?%> <? end ?>kittens: one: One kitten other: %{count} kittens
    59. 59. <? if kittens.size > 0 ?> <?= t :kittens,kittens: :count => kittens.size ?%> zero: Sorry, no kittens <? else ?> other: %{count} kittens <?= t :no_kittens ?%> <? end ?>kittens: kittens: one: One kitten one: %{count} kitten other: %{count} kittens other: %{count} kittens
    60. 60. v1.0
    61. 61. v1.0celine-db-i18n
    62. 62. MANUAL
    63. 63. MANUAL✓ Only use what you need
    64. 64. MANUAL✓ Only use what you need✓ Good translation visibility
    65. 65. MANUAL✓ Only use what you need X Need to repeat for each additional locale✓ Good translation visibility
    66. 66. MANUAL✓ Only use what you need X Need to repeat for each additional locale✓ Good translation visibility X Need to repeat with each update
    67. 67. BUNDLER
    68. 68. BUNDLER✓ All locales included
    69. 69. BUNDLER✓ All locales included✓ Easy updates
    70. 70. BUNDLER✓ All locales included X Memory usage✓ Easy updates
    71. 71. BUNDLER✓ All locales included X Memory usage✓ Easy updates X Load path issues
    72. 72. LOCALE
    73. 73. LOCALE✓ Good translation visibility
    74. 74. LOCALE✓ Good translation visibility✓ Easy updates
    75. 75. LOCALE✓ Good translation visibility X Small selection of libraries✓ Easy updates
    76. 76. • locale : http://www.localeapp.com/• i18n : https://github.com/svenfuchs/i18n• rails-i18n : https://github.com/svenfuchs/rails-i18n• i18n-spec : https://github.com/tigrish/i18n-spec• cldr : http://cldr.unicode.org/• ruby-cldr : https://github.com/svenfuchs/ruby-cldr• devise-i18n : https://github.com/tigrish/devise-i18n• will-paginate-i18n : https://github.com/tigrish/will-paginate-i18n

    ×