polish 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +25 -0
- data/Rakefile +56 -0
- data/TODO +5 -0
- data/init.rb +1 -0
- data/lib/polish.rb +104 -0
- data/lib/polish/action_view_ext/helpers/date_helper.rb +94 -0
- data/lib/polish/backend/advanced.rb +105 -0
- data/lib/polish/locale/actionview.yml +81 -0
- data/lib/polish/locale/activerecord.yml +27 -0
- data/lib/polish/locale/activesupport.yml +11 -0
- data/lib/polish/locale/datetime.yml +25 -0
- data/lib/polish/locale/pluralize.rb +16 -0
- data/lib/vendor/i18n/CHANGELOG.textile +57 -0
- data/lib/vendor/i18n/MIT-LICENSE +20 -0
- data/lib/vendor/i18n/README.textile +42 -0
- data/lib/vendor/i18n/Rakefile +21 -0
- data/lib/vendor/i18n/VERSION +1 -0
- data/lib/vendor/i18n/i18n.gemspec +141 -0
- data/lib/vendor/i18n/lib/i18n.rb +270 -0
- data/lib/vendor/i18n/lib/i18n/backend/base.rb +251 -0
- data/lib/vendor/i18n/lib/i18n/backend/cache.rb +71 -0
- data/lib/vendor/i18n/lib/i18n/backend/chain.rb +64 -0
- data/lib/vendor/i18n/lib/i18n/backend/fallbacks.rb +53 -0
- data/lib/vendor/i18n/lib/i18n/backend/gettext.rb +65 -0
- data/lib/vendor/i18n/lib/i18n/backend/pluralization.rb +56 -0
- data/lib/vendor/i18n/lib/i18n/backend/simple.rb +23 -0
- data/lib/vendor/i18n/lib/i18n/exceptions.rb +61 -0
- data/lib/vendor/i18n/lib/i18n/gettext.rb +25 -0
- data/lib/vendor/i18n/lib/i18n/helpers/gettext.rb +35 -0
- data/lib/vendor/i18n/lib/i18n/locale/fallbacks.rb +100 -0
- data/lib/vendor/i18n/lib/i18n/locale/tag.rb +27 -0
- data/lib/vendor/i18n/lib/i18n/locale/tag/parents.rb +24 -0
- data/lib/vendor/i18n/lib/i18n/locale/tag/rfc4646.rb +78 -0
- data/lib/vendor/i18n/lib/i18n/locale/tag/simple.rb +44 -0
- data/lib/vendor/i18n/lib/i18n/string.rb +95 -0
- data/lib/vendor/i18n/test/all.rb +5 -0
- data/lib/vendor/i18n/test/api/basics.rb +15 -0
- data/lib/vendor/i18n/test/api/interpolation.rb +85 -0
- data/lib/vendor/i18n/test/api/lambda.rb +52 -0
- data/lib/vendor/i18n/test/api/link.rb +47 -0
- data/lib/vendor/i18n/test/api/localization/date.rb +65 -0
- data/lib/vendor/i18n/test/api/localization/date_time.rb +63 -0
- data/lib/vendor/i18n/test/api/localization/lambda.rb +26 -0
- data/lib/vendor/i18n/test/api/localization/time.rb +63 -0
- data/lib/vendor/i18n/test/api/pluralization.rb +37 -0
- data/lib/vendor/i18n/test/api/translation.rb +51 -0
- data/lib/vendor/i18n/test/backend/cache/cache_test.rb +57 -0
- data/lib/vendor/i18n/test/backend/chain/api_test.rb +80 -0
- data/lib/vendor/i18n/test/backend/chain/chain_test.rb +64 -0
- data/lib/vendor/i18n/test/backend/fallbacks/api_test.rb +79 -0
- data/lib/vendor/i18n/test/backend/fallbacks/fallbacks_test.rb +29 -0
- data/lib/vendor/i18n/test/backend/pluralization/api_test.rb +81 -0
- data/lib/vendor/i18n/test/backend/pluralization/pluralization_test.rb +39 -0
- data/lib/vendor/i18n/test/backend/simple/all.rb +5 -0
- data/lib/vendor/i18n/test/backend/simple/api_test.rb +90 -0
- data/lib/vendor/i18n/test/backend/simple/lookup_test.rb +24 -0
- data/lib/vendor/i18n/test/backend/simple/setup.rb +147 -0
- data/lib/vendor/i18n/test/backend/simple/translations_test.rb +89 -0
- data/lib/vendor/i18n/test/fixtures/locales/de.po +61 -0
- data/lib/vendor/i18n/test/fixtures/locales/en.rb +3 -0
- data/lib/vendor/i18n/test/fixtures/locales/en.yml +3 -0
- data/lib/vendor/i18n/test/fixtures/locales/plurals.rb +112 -0
- data/lib/vendor/i18n/test/gettext/api_test.rb +78 -0
- data/lib/vendor/i18n/test/gettext/backend_test.rb +35 -0
- data/lib/vendor/i18n/test/i18n_exceptions_test.rb +97 -0
- data/lib/vendor/i18n/test/i18n_load_path_test.rb +23 -0
- data/lib/vendor/i18n/test/i18n_test.rb +163 -0
- data/lib/vendor/i18n/test/locale/fallbacks_test.rb +128 -0
- data/lib/vendor/i18n/test/locale/tag/rfc4646_test.rb +147 -0
- data/lib/vendor/i18n/test/locale/tag/simple_test.rb +35 -0
- data/lib/vendor/i18n/test/string_test.rb +94 -0
- data/lib/vendor/i18n/test/test_helper.rb +71 -0
- data/lib/vendor/i18n/test/with_options.rb +34 -0
- data/lib/vendor/i18n/vendor/po_parser.rb +329 -0
- data/spec/fixtures/en.yml +4 -0
- data/spec/fixtures/pl.yml +4 -0
- data/spec/i18n/locale/datetime_spec.rb +91 -0
- data/spec/i18n/locale/pluralization_spec.rb +41 -0
- data/spec/locale_spec.rb +124 -0
- data/spec/polish_spec.rb +141 -0
- data/spec/spec_helper.rb +4 -0
- metadata +138 -0
@@ -0,0 +1,61 @@
|
|
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!"
|
@@ -0,0 +1,112 @@
|
|
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
|
+
}
|
@@ -0,0 +1,78 @@
|
|
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
|
@@ -0,0 +1,35 @@
|
|
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
|
@@ -0,0 +1,97 @@
|
|
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
|
@@ -0,0 +1,23 @@
|
|
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
|
@@ -0,0 +1,163 @@
|
|
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
|