README.textile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. h1. Ruby I18n
  2. Ruby Internationalization and localization solution.
  3. Features:
  4. * translation and localization
  5. * interpolation of values to translations (Ruby 1.9 compatible syntax)
  6. * pluralization (CLDR compatible)
  7. * customizable transliteration to ASCII
  8. * flexible defaults
  9. * bulk lookup
  10. * lambdas as translation data
  11. * custom key/scope separator
  12. * custom exception handlers
  13. * extensible architecture with a swappable backend
  14. Pluggable features:
  15. * Cache
  16. * Pluralization: lambda pluralizers stored as translation data
  17. * Locale fallbacks, RFC4647 compliant (optionally: RFC4646 locale validation)
  18. * Gettext support
  19. * Translation metadata
  20. Alternative backends:
  21. * Chain
  22. * ActiveRecord (optionally: ActiveRecord::Missing and ActiveRecord::StoreProcs)
  23. * KeyValue (uses active_support/json and cannot store procs)
  24. For more information and lots of resources see: "http://ruby-i18n.org/wiki":http://ruby-i18n.org/wiki
  25. h2. Installation
  26. gem install i18n
  27. h4. Rails version warning
  28. On Rails < 2.3.6 the method I18n.localize will fail with MissingInterpolationArgument (issue "20":http://github.com/svenfuchs/i18n/issues/issue/20). Upgrade to Rails 2.3.6 or higher (2.3.8 preferably) is recommended.
  29. h3. Installation on Rails < 2.3.5 (deprecated)
  30. Up to version 2.3.4 Rails will not accept i18n gems > 0.1.3. There is an unpacked
  31. gem inside of active_support/lib/vendor which gets loaded unless gem 'i18n', '~> 0.1.3'.
  32. This requirement is relaxed in "6da03653":http://github.com/rails/rails/commit/6da03653
  33. The new i18n gem can be loaded from vendor/plugins like this:
  34. <pre>
  35. def reload_i18n!
  36. raise "Move to i18n version 0.2.0 or greater" if Rails.version > "2.3.4"
  37. $:.grep(/i18n/).each { |path| $:.delete(path) }
  38. I18n::Backend.send :remove_const, "Simple"
  39. $: << Rails.root.join('vendor', 'plugins', 'i18n', 'lib').to_s
  40. end
  41. </pre>
  42. Then you can `reload_i18n!` inside an i18n initializer.
  43. h2. Tests
  44. You can run tests both with
  45. * `rake test` or just `rake`
  46. * run any test file directly, e.g. `ruby -Ilib -Itest test/api/simple_test.rb`
  47. * run all tests with `ruby -Ilib -Itest test/all.rb`
  48. You can run all tests against all Gemfiles with
  49. * `ruby test/run_all.rb`
  50. The structure of the test suite is a bit unusual as it uses modules to reuse
  51. particular tests in different test cases.
  52. The reason for this is that we need to enforce the I18n API across various
  53. combinations of extensions. E.g. the Simple backend alone needs to support
  54. the same API as any combination of feature and/or optimization modules included
  55. to the Simple backend. We test this by reusing the same API defition (implemented
  56. as test methods) in test cases with different setups.
  57. You can find the test cases that enforce the API in test/api. And you can find
  58. the API definition test methods in test/api/tests.
  59. All other test cases (e.g. as defined in test/backend, test/core\_ext) etc.
  60. follow the usual test setup and should be easy to grok.
  61. h2. Authors
  62. * "Sven Fuchs":http://www.artweb-design.de
  63. * "Joshua Harvey":http://www.workingwithrails.com/person/759-joshua-harvey
  64. * "Stephan Soller":http://www.arkanis-development.de
  65. * "Saimon Moore":http://saimonmoore.net
  66. * "Matt Aimonetti":http://railsontherun.com
  67. h2. Contributors
  68. http://github.com/svenfuchs/i18n/contributors
  69. h2. License
  70. MIT License. See the included MIT-LICENSE file.