polish 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/.gitignore +2 -0
  2. data/Gemfile +14 -0
  3. data/README.md +9 -10
  4. data/Rakefile +25 -46
  5. data/VERSION +1 -0
  6. data/lib/polish.rb +5 -64
  7. data/lib/polish/locale/actionview.yml +5 -1
  8. data/lib/polish/locale/activerecord.yml +6 -1
  9. data/lib/polish/locale/datetime.rb +44 -0
  10. data/lib/polish/locale/datetime.yml +6 -15
  11. data/lib/polish/locale/pluralize.rb +16 -11
  12. data/lib/polish/proxies.rb +45 -0
  13. data/lib/proxies.rb +2 -0
  14. data/polish.gemspec +75 -0
  15. data/rails/init.rb +1 -0
  16. data/spec/fixtures/en.yml +2 -1
  17. data/spec/i18n/locale/datetime_spec.rb +30 -13
  18. data/spec/locale_spec.rb +23 -10
  19. data/spec/polish_spec.rb +11 -59
  20. data/spec/proxies_spec.rb +66 -0
  21. data/spec/spec_helper.rb +2 -0
  22. metadata +44 -79
  23. data/init.rb +0 -1
  24. data/lib/polish/backend/advanced.rb +0 -107
  25. data/lib/vendor/i18n/CHANGELOG.textile +0 -57
  26. data/lib/vendor/i18n/MIT-LICENSE +0 -20
  27. data/lib/vendor/i18n/README.textile +0 -42
  28. data/lib/vendor/i18n/Rakefile +0 -21
  29. data/lib/vendor/i18n/VERSION +0 -1
  30. data/lib/vendor/i18n/i18n.gemspec +0 -141
  31. data/lib/vendor/i18n/lib/i18n.rb +0 -270
  32. data/lib/vendor/i18n/lib/i18n/backend/base.rb +0 -251
  33. data/lib/vendor/i18n/lib/i18n/backend/cache.rb +0 -71
  34. data/lib/vendor/i18n/lib/i18n/backend/chain.rb +0 -64
  35. data/lib/vendor/i18n/lib/i18n/backend/fallbacks.rb +0 -53
  36. data/lib/vendor/i18n/lib/i18n/backend/gettext.rb +0 -65
  37. data/lib/vendor/i18n/lib/i18n/backend/pluralization.rb +0 -56
  38. data/lib/vendor/i18n/lib/i18n/backend/simple.rb +0 -23
  39. data/lib/vendor/i18n/lib/i18n/exceptions.rb +0 -61
  40. data/lib/vendor/i18n/lib/i18n/gettext.rb +0 -25
  41. data/lib/vendor/i18n/lib/i18n/helpers/gettext.rb +0 -35
  42. data/lib/vendor/i18n/lib/i18n/locale/fallbacks.rb +0 -100
  43. data/lib/vendor/i18n/lib/i18n/locale/tag.rb +0 -27
  44. data/lib/vendor/i18n/lib/i18n/locale/tag/parents.rb +0 -24
  45. data/lib/vendor/i18n/lib/i18n/locale/tag/rfc4646.rb +0 -78
  46. data/lib/vendor/i18n/lib/i18n/locale/tag/simple.rb +0 -44
  47. data/lib/vendor/i18n/lib/i18n/string.rb +0 -95
  48. data/lib/vendor/i18n/test/all.rb +0 -5
  49. data/lib/vendor/i18n/test/api/basics.rb +0 -15
  50. data/lib/vendor/i18n/test/api/interpolation.rb +0 -85
  51. data/lib/vendor/i18n/test/api/lambda.rb +0 -52
  52. data/lib/vendor/i18n/test/api/link.rb +0 -47
  53. data/lib/vendor/i18n/test/api/localization/date.rb +0 -65
  54. data/lib/vendor/i18n/test/api/localization/date_time.rb +0 -63
  55. data/lib/vendor/i18n/test/api/localization/lambda.rb +0 -26
  56. data/lib/vendor/i18n/test/api/localization/time.rb +0 -63
  57. data/lib/vendor/i18n/test/api/pluralization.rb +0 -37
  58. data/lib/vendor/i18n/test/api/translation.rb +0 -51
  59. data/lib/vendor/i18n/test/backend/cache/cache_test.rb +0 -57
  60. data/lib/vendor/i18n/test/backend/chain/api_test.rb +0 -80
  61. data/lib/vendor/i18n/test/backend/chain/chain_test.rb +0 -64
  62. data/lib/vendor/i18n/test/backend/fallbacks/api_test.rb +0 -79
  63. data/lib/vendor/i18n/test/backend/fallbacks/fallbacks_test.rb +0 -29
  64. data/lib/vendor/i18n/test/backend/pluralization/api_test.rb +0 -81
  65. data/lib/vendor/i18n/test/backend/pluralization/pluralization_test.rb +0 -39
  66. data/lib/vendor/i18n/test/backend/simple/all.rb +0 -5
  67. data/lib/vendor/i18n/test/backend/simple/api_test.rb +0 -90
  68. data/lib/vendor/i18n/test/backend/simple/lookup_test.rb +0 -24
  69. data/lib/vendor/i18n/test/backend/simple/setup.rb +0 -147
  70. data/lib/vendor/i18n/test/backend/simple/translations_test.rb +0 -89
  71. data/lib/vendor/i18n/test/fixtures/locales/de.po +0 -61
  72. data/lib/vendor/i18n/test/fixtures/locales/en.rb +0 -3
  73. data/lib/vendor/i18n/test/fixtures/locales/en.yml +0 -3
  74. data/lib/vendor/i18n/test/fixtures/locales/plurals.rb +0 -112
  75. data/lib/vendor/i18n/test/gettext/api_test.rb +0 -78
  76. data/lib/vendor/i18n/test/gettext/backend_test.rb +0 -35
  77. data/lib/vendor/i18n/test/i18n_exceptions_test.rb +0 -97
  78. data/lib/vendor/i18n/test/i18n_load_path_test.rb +0 -23
  79. data/lib/vendor/i18n/test/i18n_test.rb +0 -163
  80. data/lib/vendor/i18n/test/locale/fallbacks_test.rb +0 -128
  81. data/lib/vendor/i18n/test/locale/tag/rfc4646_test.rb +0 -147
  82. data/lib/vendor/i18n/test/locale/tag/simple_test.rb +0 -35
  83. data/lib/vendor/i18n/test/string_test.rb +0 -94
  84. data/lib/vendor/i18n/test/test_helper.rb +0 -71
  85. data/lib/vendor/i18n/test/with_options.rb +0 -34
  86. data/lib/vendor/i18n/vendor/po_parser.rb +0 -329
@@ -1,61 +0,0 @@
1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
- # This file is distributed under the same license as the PACKAGE package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
- #
6
- #, fuzzy
7
- msgid ""
8
- msgstr ""
9
- "Project-Id-Version: version 0.0.1\n"
10
- "POT-Creation-Date: 2009-02-26 19:50+0100\n"
11
- "PO-Revision-Date: 2009-02-18 14:53+0100\n"
12
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
- "Language-Team: LANGUAGE <LL@li.org>\n"
14
- "MIME-Version: 1.0\n"
15
- "Content-Type: text/plain; charset=UTF-8\n"
16
- "Content-Transfer-Encoding: 8bit\n"
17
- "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
18
-
19
- # #: app/helpers/translation_helper.rb:3
20
- # msgid "%{relative_time} ago"
21
- # msgstr "vor %{relative_time}"
22
-
23
- #: app/views/cars/show.html.erb:5
24
- msgid "Axis"
25
- msgid_plural "Axis"
26
- msgstr[0] "Achse"
27
- msgstr[1] "Achsen"
28
-
29
- #: app/controllers/cars_controller.rb:47
30
- msgid "Car was successfully created."
31
- msgstr "Auto wurde erfolgreich gespeichert"
32
-
33
- #: app/controllers/cars_controller.rb:64
34
- msgid "Car was successfully updated."
35
- msgstr "Auto wurde erfolgreich aktualisiert"
36
-
37
- #: app/views/cars/show.html.erb:1 locale/model_attributes.rb:3
38
- msgid "Car|Model"
39
- msgstr "Modell"
40
-
41
- #: app/views/cars/show.html.erb:3 locale/model_attributes.rb:4
42
- msgid "Car|Wheels count"
43
- msgstr "Räderzahl"
44
-
45
- #: app/views/cars/show.html.erb:7
46
- msgid "Created"
47
- msgstr "Erstellt"
48
-
49
- #: app/views/cars/show.html.erb:9
50
- msgid "Month"
51
- msgstr "Monat"
52
-
53
- #: locale/model_attributes.rb:2
54
- msgid "car"
55
- msgstr "Auto"
56
-
57
- #: locale/testlog_phrases.rb:2
58
- msgid "this is a dynamic translation which was found thorugh gettext_test_log!"
59
- msgstr ""
60
- "Dies ist eine dynamische Übersetzung, die durch gettext_test_log "
61
- "gefunden wurde!"
@@ -1,3 +0,0 @@
1
- # encoding: utf-8
2
-
3
- { :en => { :fuh => { :bah => "bas" } } }
@@ -1,3 +0,0 @@
1
- en:
2
- foo:
3
- bar: baz
@@ -1,112 +0,0 @@
1
- # encoding: utf-8
2
-
3
- {
4
- :af => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
5
- :am => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
6
- :ar => { :i18n => { :pluralize => lambda { |n| n == 0 ? :zero : n == 1 ? :one : n == 2 ? :two : (3..10).include?(n % 100) ? :few : (11..99).include?(n % 100) ? :many : :other } } },
7
- :az => { :i18n => { :pluralize => lambda { |n| :other } } },
8
- :be => { :i18n => { :pluralize => lambda { |n| n % 10 == 1 && n % 100 != 11 ? :one : (2..4).include?(n % 10) && !(12..14).include?(n % 100) ? :few : n % 10 == 0 || (5..9).include?(n % 10) || (11..14).include?(n % 100) ? :many : :other } } },
9
- :bg => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
10
- :bh => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
11
- :bn => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
12
- :bo => { :i18n => { :pluralize => lambda { |n| :other } } },
13
- :bs => { :i18n => { :pluralize => lambda { |n| n % 10 == 1 && n % 100 != 11 ? :one : (2..4).include?(n % 10) && !(12..14).include?(n % 100) ? :few : n % 10 == 0 || (5..9).include?(n % 10) || (11..14).include?(n % 100) ? :many : :other } } },
14
- :ca => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
15
- :cs => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : (2..4).include?(n) ? :few : :other } } },
16
- :cy => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : n == 2 ? :two : n == 8 || n == 11 ? :many : :other } } },
17
- :da => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
18
- :de => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
19
- :dz => { :i18n => { :pluralize => lambda { |n| :other } } },
20
- :el => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
21
- :en => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
22
- :eo => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
23
- :es => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
24
- :et => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
25
- :eu => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
26
- :fa => { :i18n => { :pluralize => lambda { |n| :other } } },
27
- :fi => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
28
- :fil => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
29
- :fo => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
30
- :fr => { :i18n => { :pluralize => lambda { |n| n && n != 2 ? :one : :other } } },
31
- :fur => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
32
- :fy => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
33
- :ga => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } },
34
- :gl => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
35
- :gu => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
36
- :guw => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
37
- :ha => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
38
- :he => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
39
- :hi => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
40
- :hr => { :i18n => { :pluralize => lambda { |n| n % 10 == 1 && n % 100 != 11 ? :one : (2..4).include?(n % 10) && !(12..14).include?(n % 100) ? :few : n % 10 == 0 || (5..9).include?(n % 10) || (11..14).include?(n % 100) ? :many : :other } } },
41
- :hu => { :i18n => { :pluralize => lambda { |n| :other } } },
42
- :id => { :i18n => { :pluralize => lambda { |n| :other } } },
43
- :is => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
44
- :it => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
45
- :iw => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
46
- :ja => { :i18n => { :pluralize => lambda { |n| :other } } },
47
- :jv => { :i18n => { :pluralize => lambda { |n| :other } } },
48
- :ka => { :i18n => { :pluralize => lambda { |n| :other } } },
49
- :km => { :i18n => { :pluralize => lambda { |n| :other } } },
50
- :kn => { :i18n => { :pluralize => lambda { |n| :other } } },
51
- :ko => { :i18n => { :pluralize => lambda { |n| :other } } },
52
- :ku => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
53
- :lb => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
54
- :ln => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
55
- :lt => { :i18n => { :pluralize => lambda { |n| n % 10 == 1 && !(11..19).include?(n % 100) ? :one : (2..9).include?(n % 10) && !(11..19).include?(n % 100) ? :few : :other } } },
56
- :lv => { :i18n => { :pluralize => lambda { |n| n == 0 ? :zero : n % 10 == 1 && n % 100 != 11 ? :one : :other } } },
57
- :mg => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
58
- :mk => { :i18n => { :pluralize => lambda { |n| n % 10 == 1 ? :one : :other } } },
59
- :ml => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
60
- :mn => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
61
- :mo => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : n == 0 ? :few : :other } } },
62
- :mr => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
63
- :ms => { :i18n => { :pluralize => lambda { |n| :other } } },
64
- :mt => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : n == 0 || (2..10).include?(n % 100) ? :few : (11..19).include?(n % 100) ? :many : :other } } },
65
- :my => { :i18n => { :pluralize => lambda { |n| :other } } },
66
- :nah => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
67
- :nb => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
68
- :ne => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
69
- :nl => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
70
- :nn => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
71
- :no => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
72
- :nso => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
73
- :om => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
74
- :or => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
75
- :pa => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
76
- :pap => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
77
- :pl => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : (2..4).include?(n % 10) && !(12..14).include?(n % 100) && !(22..24).include?(n % 100) ? :few : :other } } },
78
- :ps => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
79
- :pt => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
80
- :"pt-PT" => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
81
- :ro => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : n == 0 ? :few : :other } } },
82
- :ru => { :i18n => { :pluralize => lambda { |n| n % 10 == 1 && n % 100 != 11 ? :one : (2..4).include?(n % 10) && !(12..14).include?(n % 100) ? :few : n % 10 == 0 || (5..9).include?(n % 10) || (11..14).include?(n % 100) ? :many : :other } } },
83
- :se => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } },
84
- :sh => { :i18n => { :pluralize => lambda { |n| n % 10 == 1 && n % 100 != 11 ? :one : (2..4).include?(n % 10) && !(12..14).include?(n % 100) ? :few : n % 10 == 0 || (5..9).include?(n % 10) || (11..14).include?(n % 100) ? :many : :other } } },
85
- :sk => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : (2..4).include?(n) ? :few : :other } } },
86
- :sl => { :i18n => { :pluralize => lambda { |n| n % 100 == 1 ? :one : n % 100 == 2 ? :two : (3..4).include?(n % 100) ? :few : :other } } },
87
- :sma => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } },
88
- :smi => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } },
89
- :smj => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } },
90
- :smn => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } },
91
- :sms => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } },
92
- :so => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
93
- :sq => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
94
- :sr => { :i18n => { :pluralize => lambda { |n| n % 10 == 1 && n % 100 != 11 ? :one : (2..4).include?(n % 10) && !(12..14).include?(n % 100) ? :few : n % 10 == 0 || (5..9).include?(n % 10) || (11..14).include?(n % 100) ? :many : :other } } },
95
- :sv => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
96
- :sw => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
97
- :ta => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
98
- :te => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
99
- :th => { :i18n => { :pluralize => lambda { |n| :other } } },
100
- :ti => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
101
- :tk => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
102
- :tl => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
103
- :to => { :i18n => { :pluralize => lambda { |n| :other } } },
104
- :tr => { :i18n => { :pluralize => lambda { |n| :other } } },
105
- :uk => { :i18n => { :pluralize => lambda { |n| n % 10 == 1 && n % 100 != 11 ? :one : (2..4).include?(n % 10) && !(12..14).include?(n % 100) ? :few : n % 10 == 0 || (5..9).include?(n % 10) || (11..14).include?(n % 100) ? :many : :other } } },
106
- :ur => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } },
107
- :vi => { :i18n => { :pluralize => lambda { |n| :other } } },
108
- :wa => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } },
109
- :yo => { :i18n => { :pluralize => lambda { |n| :other } } },
110
- :zh => { :i18n => { :pluralize => lambda { |n| :other } } },
111
- :zu => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } }
112
- }
@@ -1,78 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
4
- require 'i18n/backend/gettext'
5
- require 'i18n/helpers/gettext'
6
-
7
- include I18n::Helpers::Gettext
8
-
9
- class I18nGettextApiTest < Test::Unit::TestCase
10
- def setup
11
- I18n.locale = :en
12
- I18n.backend.store_translations :de, {
13
- 'Hi Gettext!' => 'Hallo Gettext!',
14
- 'Sentence 1. Sentence 2.' => 'Satz 1. Satz 2.',
15
- "An apple#{I18n::Gettext::PLURAL_SEPARATOR}{{count}} apples" => { :one => 'Ein Apfel', :other => '{{count}} Äpfel' },
16
- :special => { 'An apple' => { :one => 'Ein spezieller Apfel', :other => '{{count}} spezielle Äpfel' } },
17
- :foo => { :bar => { :baz => 'baz-de' } }
18
- }
19
- end
20
-
21
- def test_helper_uses_msg_as_default
22
- assert_equal 'Hi Gettext!', _('Hi Gettext!')
23
- end
24
-
25
- def test_helper_uses_msg_as_key
26
- I18n.locale = :de
27
- assert_equal 'Hallo Gettext!', _('Hi Gettext!')
28
- end
29
-
30
- def test_helper_uses_msg_containing_dots_as_default
31
- assert_equal 'Sentence 1. Sentence 2.', _('Sentence 1. Sentence 2.')
32
- end
33
-
34
- def test_helper_uses_msg_containing_dots_as_key
35
- I18n.locale = :de
36
- assert_equal 'Satz 1. Satz 2.', _('Sentence 1. Sentence 2.')
37
- end
38
-
39
- def test_sgettext_defaults_to_the_last_token_of_a_scoped_msgid
40
- assert_equal 'baz', sgettext('foo|bar|baz')
41
- end
42
-
43
- def test_sgettext_looks_up_a_scoped_translation
44
- I18n.locale = :de
45
- assert_equal 'baz-de', sgettext('foo|bar|baz')
46
- end
47
-
48
- def test_pgettext_defaults_to_msgid
49
- assert_equal 'baz', pgettext('foo|bar', 'baz', '|')
50
- end
51
-
52
- def test_pgettext_looks_up_a_scoped_translation
53
- I18n.locale = :de
54
- assert_equal 'baz-de', pgettext('foo|bar', 'baz', '|')
55
- end
56
-
57
- def test_ngettext_looks_up_msg_id_as_default_singular
58
- assert_equal 'An apple', ngettext('An apple', '{{count}} apples', 1)
59
- end
60
-
61
- def test_ngettext_looks_up_msg_id_plural_as_default_plural
62
- assert_equal '2 apples', ngettext('An apple', '{{count}} apples', 2)
63
- end
64
-
65
- def test_ngettext_looks_up_msg_id_as_singular
66
- I18n.locale = :de
67
- assert_equal 'Ein Apfel', ngettext('An apple', '{{count}} apples', 1)
68
- end
69
-
70
- def test_ngettext_looks_up_msg_id_as_singular
71
- I18n.locale = :de
72
- assert_equal '2 Äpfel', ngettext('An apple', '{{count}} apples', 2)
73
- end
74
-
75
- def test_nsgettext_looks_up_msg_id_as_default_singular
76
- assert_equal 'A special apple', nsgettext('special|A special apple', '{{count}} special apples', 1, '|')
77
- end
78
- end
@@ -1,35 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
4
- require 'i18n/backend/gettext'
5
- require 'i18n/helpers/gettext'
6
-
7
- include I18n::Helpers::Gettext
8
-
9
- class I18nGettextBackendTest < Test::Unit::TestCase
10
- def setup
11
- I18n.locale = :en
12
- I18n.load_path = [locales_dir + '/de.po']
13
- I18n.backend.meta_class.send(:include, I18n::Backend::Gettext)
14
- end
15
-
16
- def teardown
17
- I18n.load_path = nil
18
- I18n.backend = nil
19
- end
20
-
21
- def test_backend_loads_po_file
22
- I18n.backend.send(:init_translations)
23
- assert I18n.backend.send(:translations)[:de][:"Axis\001Axis"]
24
- end
25
-
26
- def test_looks_up_translation
27
- I18n.locale = :de
28
- assert_equal 'Auto', _('car')
29
- end
30
-
31
- def test_pluralizes_entry
32
- I18n.locale = :de
33
- assert_equal 'Achsen', ngettext('Axis', 'Axis', 2)
34
- end
35
- end
@@ -1,97 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/test_helper')
4
-
5
- class I18nExceptionsTest < Test::Unit::TestCase
6
- def test_invalid_locale_stores_locale
7
- force_invalid_locale
8
- rescue I18n::ArgumentError => e
9
- assert_nil e.locale
10
- end
11
-
12
- def test_invalid_locale_message
13
- force_invalid_locale
14
- rescue I18n::ArgumentError => e
15
- assert_equal 'nil is not a valid locale', e.message
16
- end
17
-
18
- def test_missing_translation_data_stores_locale_key_and_options
19
- force_missing_translation_data
20
- rescue I18n::ArgumentError => e
21
- options = {:scope => :bar}
22
- assert_equal 'de', e.locale
23
- assert_equal :foo, e.key
24
- assert_equal options, e.options
25
- end
26
-
27
- def test_missing_translation_data_message
28
- force_missing_translation_data
29
- rescue I18n::ArgumentError => e
30
- assert_equal 'translation missing: de, bar, foo', e.message
31
- end
32
-
33
- def test_invalid_pluralization_data_stores_entry_and_count
34
- force_invalid_pluralization_data
35
- rescue I18n::ArgumentError => e
36
- assert_equal [:bar], e.entry
37
- assert_equal 1, e.count
38
- end
39
-
40
- def test_invalid_pluralization_data_message
41
- force_invalid_pluralization_data
42
- rescue I18n::ArgumentError => e
43
- assert_equal 'translation data [:bar] can not be used with :count => 1', e.message
44
- end
45
-
46
- def test_missing_interpolation_argument_stores_key_and_string
47
- assert_raises(I18n::MissingInterpolationArgument) { force_missing_interpolation_argument }
48
- force_missing_interpolation_argument
49
- rescue I18n::ArgumentError => e
50
- # assert_equal :bar, e.key
51
- assert_equal "{{bar}}", e.string
52
- end
53
-
54
- def test_missing_interpolation_argument_message
55
- force_missing_interpolation_argument
56
- rescue I18n::ArgumentError => e
57
- assert_equal 'missing interpolation argument in "{{bar}}" ({:baz=>"baz"} given)', e.message
58
- end
59
-
60
- def test_reserved_interpolation_key_stores_key_and_string
61
- force_reserved_interpolation_key
62
- rescue I18n::ArgumentError => e
63
- assert_equal :scope, e.key
64
- assert_equal "{{scope}}", e.string
65
- end
66
-
67
- def test_reserved_interpolation_key_message
68
- force_reserved_interpolation_key
69
- rescue I18n::ArgumentError => e
70
- assert_equal 'reserved key :scope used in "{{scope}}"', e.message
71
- end
72
-
73
- private
74
- def force_invalid_locale
75
- I18n.backend.translate nil, :foo
76
- end
77
-
78
- def force_missing_translation_data
79
- I18n.backend.store_translations 'de', :bar => nil
80
- I18n.backend.translate 'de', :foo, :scope => :bar
81
- end
82
-
83
- def force_invalid_pluralization_data
84
- I18n.backend.store_translations 'de', :foo => [:bar]
85
- I18n.backend.translate 'de', :foo, :count => 1
86
- end
87
-
88
- def force_missing_interpolation_argument
89
- I18n.backend.store_translations 'de', :foo => "{{bar}}"
90
- I18n.backend.translate 'de', :foo, :baz => 'baz'
91
- end
92
-
93
- def force_reserved_interpolation_key
94
- I18n.backend.store_translations 'de', :foo => "{{scope}}"
95
- I18n.backend.translate 'de', :foo, :baz => 'baz'
96
- end
97
- end
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/test_helper')
4
-
5
- class I18nLoadPathTest < Test::Unit::TestCase
6
- # include Tests::Backend::Simple::Setup::Base
7
-
8
- def setup
9
- I18n.locale = :en
10
- I18n.backend = I18n::Backend::Simple.new
11
- backend_store_translations(:en, :foo => {:bar => 'bar', :baz => 'baz'})
12
- end
13
-
14
- def test_nested_load_paths_do_not_break_locale_loading
15
- I18n.load_path = [[locales_dir + '/en.yml']]
16
- assert_equal "baz", I18n.t(:'foo.bar')
17
- end
18
-
19
- def test_adding_arrays_of_filenames_to_load_path_do_not_break_locale_loading
20
- I18n.load_path << Dir[locales_dir + '/*.{rb,yml}']
21
- assert_equal "baz", I18n.t(:'foo.bar')
22
- end
23
- end
@@ -1,163 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/test_helper')
4
-
5
- class I18nTest < Test::Unit::TestCase
6
- def setup
7
- I18n.backend.store_translations :'en', {
8
- :currency => {
9
- :format => {
10
- :separator => '.',
11
- :delimiter => ',',
12
- }
13
- }
14
- }
15
- end
16
-
17
- def test_uses_simple_backend_set_by_default
18
- assert I18n.backend.is_a?(I18n::Backend::Simple)
19
- end
20
-
21
- def test_can_set_backend
22
- assert_nothing_raised { I18n.backend = self }
23
- assert_equal self, I18n.backend
24
- I18n.backend = I18n::Backend::Simple.new
25
- end
26
-
27
- def test_uses_en_us_as_default_locale_by_default
28
- assert_equal :en, I18n.default_locale
29
- end
30
-
31
- def test_can_set_default_locale
32
- assert_nothing_raised { I18n.default_locale = 'de' }
33
- assert_equal :de, I18n.default_locale
34
- I18n.default_locale = :en
35
- end
36
-
37
- def test_uses_default_locale_as_locale_by_default
38
- assert_equal I18n.default_locale, I18n.locale
39
- end
40
-
41
- def test_can_set_locale_to_thread_current
42
- assert_nothing_raised { I18n.locale = 'de' }
43
- assert_equal :de, I18n.locale
44
- assert_equal :de, Thread.current[:locale]
45
- I18n.locale = :en
46
- end
47
-
48
- def test_defaults_to_dot_as_separator
49
- assert_equal '.', I18n.default_separator
50
- end
51
-
52
- def test_can_set_default_separator
53
- assert_nothing_raised { I18n.default_separator = "\001" }
54
- I18n.default_separator = '.' # revert it
55
- end
56
-
57
- def test_normalize_keys
58
- assert_equal [:en, :foo, :bar], I18n.send(:normalize_translation_keys, :en, :bar, :foo)
59
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.send(:normalize_translation_keys, :en, :'baz.buz', :'foo.bar')
60
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.send(:normalize_translation_keys, :en, 'baz.buz', 'foo.bar')
61
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.send(:normalize_translation_keys, :en, %w(baz buz), %w(foo bar))
62
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.send(:normalize_translation_keys, :en, [:baz, :buz], [:foo, :bar])
63
- end
64
-
65
- def test_uses_passed_separator_to_normalize_keys
66
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.send(:normalize_translation_keys, :en, :'baz|buz', :'foo|bar', '|')
67
- end
68
-
69
- def test_can_set_exception_handler
70
- assert_nothing_raised { I18n.exception_handler = :custom_exception_handler }
71
- I18n.exception_handler = :default_exception_handler # revert it
72
- end
73
-
74
- def test_uses_custom_exception_handler
75
- I18n.exception_handler = :custom_exception_handler
76
- I18n.expects(:custom_exception_handler)
77
- I18n.translate :bogus
78
- I18n.exception_handler = :default_exception_handler # revert it
79
- end
80
-
81
- def test_delegates_translate_to_backend
82
- I18n.backend.expects(:translate).with 'de', :foo, {}
83
- I18n.translate :foo, :locale => 'de'
84
- end
85
-
86
- def test_delegates_localize_to_backend
87
- I18n.backend.expects(:localize).with 'de', :whatever, :default
88
- I18n.localize :whatever, :locale => 'de'
89
- end
90
-
91
- def test_translate_given_no_locale_uses_i18n_locale
92
- I18n.backend.expects(:translate).with :en, :foo, {}
93
- I18n.translate :foo
94
- end
95
-
96
- def test_translate_on_nested_symbol_keys_works
97
- assert_equal ".", I18n.t(:'currency.format.separator')
98
- end
99
-
100
- def test_translate_with_nested_string_keys_works
101
- assert_equal ".", I18n.t('currency.format.separator')
102
- end
103
-
104
- def test_translate_with_array_as_scope_works
105
- assert_equal ".", I18n.t(:separator, :scope => %w(currency format))
106
- end
107
-
108
- def test_translate_with_array_containing_dot_separated_strings_as_scope_works
109
- assert_equal ".", I18n.t(:separator, :scope => ['currency.format'])
110
- end
111
-
112
- def test_translate_with_key_array_and_dot_separated_scope_works
113
- assert_equal [".", ","], I18n.t(%w(separator delimiter), :scope => 'currency.format')
114
- end
115
-
116
- def test_translate_with_dot_separated_key_array_and_scope_works
117
- assert_equal [".", ","], I18n.t(%w(format.separator format.delimiter), :scope => 'currency')
118
- end
119
-
120
- def test_translate_with_options_using_scope_works
121
- I18n.backend.expects(:translate).with('de', :precision, :scope => :"currency.format")
122
- I18n.with_options :locale => 'de', :scope => :'currency.format' do |locale|
123
- locale.t :precision
124
- end
125
- end
126
-
127
- # def test_translate_given_no_args_raises_missing_translation_data
128
- # assert_equal "translation missing: en, no key", I18n.t
129
- # end
130
-
131
- def test_translate_given_a_bogus_key_raises_missing_translation_data
132
- assert_equal "translation missing: en, bogus", I18n.t(:bogus)
133
- end
134
-
135
- def test_localize_nil_raises_argument_error
136
- assert_raises(I18n::ArgumentError) { I18n.l nil }
137
- end
138
-
139
- def test_localize_object_raises_argument_error
140
- assert_raises(I18n::ArgumentError) { I18n.l Object.new }
141
- end
142
-
143
- def test_proc_exception_handler
144
- I18n.exception_handler = Proc.new { |exception, locale, key, options|
145
- "No exception here! [Proc handler]"
146
- }
147
- assert_equal "No exception here! [Proc handler]", I18n.translate(:test_proc_handler)
148
- ensure
149
- I18n.exception_handler = :default_exception_handler
150
- end
151
-
152
- def test_class_exception_handler
153
- I18n.exception_handler = Class.new do
154
- def call(exception, locale, key, options)
155
- "No exception here! [Class handler]"
156
- end
157
- end.new
158
- assert_equal "No exception here! [Class handler]", I18n.translate(:test_class_handler)
159
- ensure
160
- I18n.exception_handler = :default_exception_handler
161
- end
162
-
163
- end