matta-globalite 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README ADDED
@@ -0,0 +1,199 @@
1
+ =Globalite
2
+
3
+
4
+ Globalite is meant to be a breed of the best internationalization/localization plugins available for Rails.
5
+
6
+ Globalite should provide you with a 3-in-1 solution:
7
+
8
+ * Easy UI localization.
9
+ * Rails localization. (Localization of the core functions from rails)
10
+ * Simple yet powerful solution for user content availability in multiple languages.
11
+
12
+ On top of that:
13
+ yml files are used for most of the localization, which makes Globalite a light and fast solution.
14
+ The Locale is set on the user's session making Globalite a perfect solution for multilingual support.
15
+ The developer can pass dynamic values to be used in the localization.
16
+
17
+
18
+ ==What's the difference between Globalite and the other existing l10n/i18n plugins?
19
+
20
+ Gibberish is a nice plugin but it doesn't handle locales, you can't have your application in British English and American English. I also don't really like the syntax :p I based the UI localization of Globalite on Chris' work on Gibberish.
21
+
22
+ Globalize is a great plugin but man, it's bloated... I would like to have something a bit lighter and easier to use. (less options, less setup time, less database usage). I decided to trim down Globalize to offer less options and fulfill the needs of most developers.
23
+
24
+ Also, Globalite doesn't have the concept of a base language. Mainly because I think that's a bad idea. If you use English as your base language and you need to fix a string in English(you did a typo), you will break all the other translations. That's why Globalite uses localization keys only.
25
+
26
+
27
+
28
+ ==Usage
29
+
30
+ ===installation:
31
+
32
+ script/plugin install http://globalite.googlecode.com/svn/trunk/
33
+ rename the vendor/plugins/trunk => vendor/plugins/globalite
34
+ or from your vendor/plugins folder:
35
+ svn checkout http://globalite.googlecode.com/svn/trunk/ globalite
36
+
37
+ ===UI Localization:
38
+
39
+ Create a lang folder at the root of your project. Add your localization files in the lang/ui folder if you want to localize your interface.
40
+
41
+ Declare the current locale or language in your environment.rb >
42
+ Globalite.language = :fr
43
+
44
+ Localize a key in your view >
45
+ :localization_key.l
46
+ or
47
+ :localization_key.localize
48
+
49
+
50
+ Easy, isn't?
51
+
52
+ Advanced users can also do more:
53
+
54
+ You can also pass an optional localization string only used if the localization is missing
55
+ :missing_localization_key.l("text used if the key is not localized yet")
56
+
57
+ You can also pass values to the localization, and the translator can do whatever he wants with them:
58
+ :welcome_user.l_with_args({:user => @user.name}) would render "Welcome Matt!"
59
+ Note that variables can be used in any order the translator wants
60
+
61
+
62
+ You can also use pluralization right in your translations:
63
+ geese_amount: we have pluralize{{geese_count}, goose, geese} in the farm!
64
+
65
+ In your view do the following:
66
+ :geese_amount.l_with_args({:geese_count => @geese.count})
67
+
68
+ Note that the pluralization form of your string is optional, you could use a translation like that too:
69
+ cow_amount: we have pluralize{{count}, cow} in the farm!
70
+
71
+ By pushing the pluralization to the translator, I believe we offer more flexibility so the translation can be smoother.
72
+ This solution was inspired by a discussion with Ivan:
73
+ "It's very difficult to just translate "prohibited this" and "from being saved" to Chinese, cause the resulting sentence will look like a machine translated one without making much sense. Not to mention Chinese handles pluralization differently, we pretty much don't have it. For example, we'll use the same word for "person" and "people", no difference. So to me, it makes sense just to replace the whole thing with one simple header message that says "Invalid attributes!" in Chinese."
74
+
75
+
76
+ ===Rails Localization:
77
+
78
+ Localize a time object by using a predefined format (defined in the date_helper_time_formats variable that you can find in globalite/lang/rails/[lang].yml)
79
+
80
+ Globalite.language = :fr
81
+ Time.now.l(:long)
82
+
83
+ Localize a date object by using a predefined format (defined in the date_helper_date_formats variable that you can find in globalite/lang/rails/[lang].yml)
84
+
85
+ Date.today.l
86
+
87
+ In your views, create a select box with a list of all countries(listed in the locale language):
88
+ country_options_for_select
89
+
90
+ In your views, create a select box with a list of all the months(listed in the locale language) with the current month selected:
91
+ select_month(Time.now)
92
+
93
+ In your views, create a set of html select-tags (one for year, month, day, hour, and minute):
94
+ select_datetime
95
+
96
+ In your views, create a set of html select-tags (one for year, month, and day):
97
+ select_date
98
+
99
+ Get a number returned in currency, for instance if the locale was set to 'fr' the returned value would be 123,00 € but if the locale was set to 'en-US' it would return $123.00
100
+ number_to_currency(123)
101
+
102
+ Get a distance of time in words localized.
103
+ distance_of_time_in_words(10.minutes.ago, Time.now)
104
+
105
+ Active record errors are automatically rendered in the locale language
106
+
107
+ ==Localize field names in validator messages
108
+
109
+ By default, here is the normal validation behavior:
110
+
111
+ Name cannot be empty (en)
112
+ Name nie może być puste(y,a) (pl)
113
+
114
+ However, Name should be replaced with 'Nazwa' in polish.
115
+
116
+ Consider the following example:
117
+
118
+ validates_presence_of :name, :email, :age
119
+
120
+ GlobaLite will try to use your yml language files entries using the following localization keys: name:, email:, age:.
121
+ Globalite will also try to replace model name from validation messages with localized version from yml file, i.e. the message below:
122
+
123
+ 8 errors prohibited this user from being saved
124
+ ^^^^
125
+
126
+ will be localized and 'user' will be replaced if 'user' key exists in yml language file.
127
+
128
+ If the plugin can't find any localizations, the original field name will be used.
129
+ You can get rid of field name in custom validation message with :message attribute.
130
+
131
+ validates_uniqueness_of :name, :message => '^my message'
132
+
133
+
134
+ ====Notes
135
+
136
+ Check on the tests in the spec folder for more examples. There's also a demo app available: http://globalite.googlecode.com/svn/sample/ui/
137
+
138
+ ==FAQ:
139
+
140
+ ===Why did you call your plugin 'Globalite'?
141
+
142
+ Globalize was already taken ;) More seriously, I was looking for a i18n/l10n solution for a project I was working on, after few hours testing Globalize, Josh http://joshknowles.com, Matt http://heidmotron.com/ and I http://railsontherun.com saw it wouldn't work for us. Since we only had the choice between very simple solutions and a complicated solution, I decided to make a "lite" version of Globalize ;)
143
+
144
+ ==TODO:
145
+
146
+ - Model i18n/l10n
147
+
148
+
149
+ ===Internationalization, Localization, Locale:
150
+
151
+ Internationalization refers to the process of modifying an application’s design so that it can support
152
+ locale differences like text orientation, currency, date and time format, sorting, and so forth. This can be done
153
+ by externalizing text strings into files or a database, and by developing currency and date formatting utilities.
154
+
155
+ Localization means adapting an application to a specific language or locale; for example, by translating
156
+ text into multiple languages. A locale is identified by the user’s language and country, and specifies how, for
157
+ example, numbers, currencies, and dates are displayed on the screen. The code for the US English locale is
158
+ en-US. Locales are specified by RFC 3066 and consist of two parts. The first is an ISO 639 language code and
159
+ uses lowercase letters. The second is usually an ISO 3166 country code in uppercase letters.
160
+ [from Ruby on Rails Commerce (Hellsten, Laine)]
161
+
162
+ ===CREDITS:
163
+
164
+ Some code was very influenced from different projects such as:
165
+
166
+ * Gibberish http://require.errtheblog.com/plugins/browser/gibberish written by Chris Wanstrath (http://errtheblog.com)
167
+ * Globalize http://www.globalize-rails.org written by too many people to list them here ;)
168
+ * LocalizationSimplified (L10n-simplified) written By Jesper Ronn-Jensen ( http://justaddwater.dk/ )
169
+
170
+
171
+ ===Author:
172
+
173
+ Matt Aimonetti http://railsontherun.com mattaimonetti AT gmail DOT com
174
+
175
+
176
+ ===Contributors:
177
+
178
+ Ivan Chang yuanhueichang AT gmail_DOT_com ( Chinese translation, help on the ActiveRecord msg error i18n/l10n)
179
+ Ralph von Der Heyden ralph AT rvdh_DOT_de (German translation)
180
+ jiman.ryu AT gmail http://jasonpa.tistory.com/ (bug fix)
181
+ Guillaume Belleguic guillaume.belleguic AT oceans DOT eu (Model error handling)
182
+ Marcus Derencius derencius AT gmail_dot_com (Brazilian Portuguese translation)
183
+ MrPrise (Hungarian localization)
184
+ Koen Punt (Dutch localization)
185
+ Mariano Ayesa (Spanish Spain and Argentina localization)
186
+ jyrkij http://github.com/jyrkij (Finnish)
187
+ Ilke Akdeniz (Turkish)
188
+ Dejan Dimic (Serbian)
189
+
190
+ your name here if you submit a patch :)
191
+
192
+
193
+ ===More info:
194
+
195
+ http://code.google.com/p/globalite/
196
+
197
+ http://railsontherun.com/globalite
198
+
199
+ Sample app: http://globalite.googlecode.com/svn/sample/ui/
@@ -0,0 +1,357 @@
1
+ locale_name: Deutsch (Deutschland)
2
+ # ActiveRecord::Errors.default_error_messages
3
+ error_message_inclusion: ist nicht in Liste gültiger Optionen enthalten.
4
+ error_message_exclusion: ist reserviert.
5
+ error_message_invalid: ist ungültig.
6
+ error_message_confirmation: entspricht nicht der Bestätigung.
7
+ error_message_accepted: muss akzeptiert werden.
8
+ error_message_empty: darf nicht leer sein.
9
+ error_message_blank: muss ausgefüllt werden.
10
+ error_message_too_long: ist zu lang (höchstens %d Zeichen).
11
+ error_message_too_short: ist zu kurz (mindestens is %d Zeichen).
12
+ error_message_wrong_length: hat die falsche Länge (%d Zeichen).
13
+ error_message_taken: ist bereits vergeben.
14
+ error_message_not_a_number: ist keine Zahl.
15
+
16
+ # used by ActionView::Helpers::DateHelper.distance_of_time_in_words
17
+ date_helper_less_than_x_seconds: weniger als %d Sekunden
18
+ date_helper_half_a_minute: eine halbe Minute
19
+ date_helper_less_than_a_minute: weniger als eine Minute
20
+ date_helper_one_minute: 1 Minute
21
+ date_helper_x_minutes: %d Minuten
22
+ date_helper_one_hour: etwa 1 Stunde
23
+ date_helper_x_hours: etwa %d Stunden
24
+ date_helper_one_day: 1 Tag
25
+ date_helper_x_days: %d Tage
26
+ date_helper_one_month: 1 Monat
27
+ date_helper_x_months: %d Monate
28
+ date_helper_one_year: 1 Jahr
29
+ date_helper_x_years: %d Jahre
30
+
31
+ # DON'T TRANSLATE, just order
32
+ date_helper_order: [:day, :month, :year] #default Rails is US ordered: :order => [:year, :month, :day]
33
+
34
+ date_helper_date_formats: # DON'T TRANSLATE, RE ORDER
35
+ default: "%d.%m.%Y"
36
+ short: "%e. %b"
37
+ long: "%e. %B %Y"
38
+
39
+ date_helper_time_formats: # DON'T TRANSLATE, RE ORDER
40
+ default: "%a, %d. %b %Y, %H:%M:%S %z"
41
+ short: "%d. %b, %H:%M"
42
+ long: "%d. %B %Y, %H:%M"
43
+
44
+ # added at the end of date if your date system doesn't use a 24 hours system
45
+ date_helper_am: am
46
+ date_helper_pm: pm
47
+
48
+ # used by ActionView::Helpers::NumberHelper.number_to_currency
49
+ number_helper_unit: "€"
50
+ number_helper_separator: "," #unit separator (between integer part and fraction part)
51
+ number_helper_delimiter: "." #delimiter between each group of thousands. Example: 1.234.567
52
+ number_helper_order: [ number, unit ]
53
+ #to support for instance French format, the order is different: Unit comes last (ex. "1.234,00 €")
54
+
55
+ # use by +Array#to_sentence()+
56
+ array_connector: 'und'
57
+ array_skip_last_comma: 'false'
58
+
59
+ # Active Record error messages:
60
+ active_record_helper_error_description: 'Es gab Probleme mit den folgenden Feldern:'
61
+ active_record_helper_header_message: Durch pluralize{{error_count}, Fehler, Fehler} konnte {failed_object} nicht gespeichert werden.
62
+
63
+ date_helper_month_names:
64
+ - # Leave that line
65
+ - # Leave that line
66
+ - Januar
67
+ - Februar
68
+ - März
69
+ - April
70
+ - Mai
71
+ - Juni
72
+ - Juli
73
+ - August
74
+ - September
75
+ - Oktober
76
+ - November
77
+ - Dezember
78
+
79
+ date_helper_abbr_month_names:
80
+ - # Leave that line
81
+ - # Leave that line
82
+ - Jan
83
+ - Feb
84
+ - Mar
85
+ - Apr
86
+ - Mai
87
+ - Jun
88
+ - Jul
89
+ - Aug
90
+ - Sep
91
+ - Okt
92
+ - Nov
93
+ - Dez
94
+
95
+ date_helper_day_names:
96
+ - Sonntag
97
+ - Montag
98
+ - Dienstag
99
+ - Mittwoch
100
+ - Donnerstag
101
+ - Freitag
102
+ - Samstag
103
+
104
+ date_helper_abbr_day_names:
105
+ - So
106
+ - Mo
107
+ - Di
108
+ - Mi
109
+ - Do
110
+ - Fr
111
+ - Sa
112
+
113
+ countries_list:
114
+ - Afghanistan
115
+ - Albanien
116
+ - Algerien
117
+ - Amerikanisch-Samoa
118
+ - Andorra
119
+ - Angola
120
+ - Anguilla
121
+ - Antarktis
122
+ - Antigua und Barbuda
123
+ - Argentinien
124
+ - Armenien
125
+ - Aruba
126
+ - Australien
127
+ - Österreich
128
+ - Aserbaidschan
129
+ - Bahamas
130
+ - Bahrain
131
+ - Bangladesch
132
+ - Barbados
133
+ - Belarus
134
+ - Belgien
135
+ - Belize
136
+ - Benin
137
+ - Bermuda
138
+ - Bhutan
139
+ - Bolivien
140
+ - Bosnien und Herzegowina
141
+ - Botsuana
142
+ - Bouvetinsel
143
+ - Brasilien
144
+ - Britisches Territorium im Indischen Ozean
145
+ - Brunei
146
+ - Bulgarien
147
+ - Burkina Faso
148
+ - Myanmar
149
+ - Burundi
150
+ - Kambodscha
151
+ - Kamerun
152
+ - Kanada
153
+ - Kap Verde
154
+ - Kaimaninseln
155
+ - Zentralafrikanische Republik
156
+ - Tschad
157
+ - Chile
158
+ - China
159
+ - Weihnachtsinsel
160
+ - Kokosinseln
161
+ - Kolumbien
162
+ - Komoren
163
+ - Kongo
164
+ - Demokratische Republik Kongo
165
+ - Cookinseln
166
+ - Costa Rica
167
+ - Elfenbeinküste
168
+ - Kroatien
169
+ - Kuba
170
+ - Zypern
171
+ - Tschechische Republik
172
+ - Dänemark
173
+ - Dschibuti
174
+ - Dominica
175
+ - Dominikanische Republik
176
+ - Osttimor
177
+ - Ecuador
178
+ - Ägypten
179
+ - El Salvador
180
+ - England
181
+ - Äquatorialguinea
182
+ - Eritrea
183
+ - Spanien
184
+ - Estland
185
+ - Äthiopien
186
+ - Falklandinseln
187
+ - Färöer
188
+ - Fidschi
189
+ - Finnland
190
+ - Frankreich
191
+ - Französisch-Guayana
192
+ - Französisch-Polynesien
193
+ - Französische Gebiete im südlichen Indischen Ozean
194
+ - Gabun
195
+ - Gambia
196
+ - Georgien
197
+ - Deutschland
198
+ - Ghana
199
+ - Gibraltar
200
+ - Großbritannien
201
+ - Griechenland
202
+ - Grönland
203
+ - Grenada
204
+ - Guadeloupe
205
+ - Guam
206
+ - Guatemala
207
+ - Guinea
208
+ - Guinea-Bissau
209
+ - Guyana
210
+ - Haiti
211
+ - Heard und McDonaldinseln
212
+ - Honduras
213
+ - Hongkong
214
+ - Ungarn
215
+ - Island
216
+ - Indien
217
+ - Indonesien
218
+ - Irland
219
+ - Israel
220
+ - Italien
221
+ - Iran
222
+ - Irak
223
+ - Jamaika
224
+ - Japan
225
+ - Jordanien
226
+ - Kasachstan
227
+ - Kenia
228
+ - Kiribati
229
+ - Nordkorea
230
+ - Südkorea
231
+ - Kuwait
232
+ - Kirgisistan
233
+ - Laos
234
+ - Lettland
235
+ - Libanon
236
+ - Lesotho
237
+ - Liberia
238
+ - Liechtenstein
239
+ - Litauen
240
+ - Luxemburg
241
+ - Macau
242
+ - Mazedonien
243
+ - Madagaskar
244
+ - Malawi
245
+ - Malaysia
246
+ - Malediven
247
+ - Mali
248
+ - Malta
249
+ - Marshallinseln
250
+ - Martinique
251
+ - Mauretanien
252
+ - Mauritius
253
+ - Mayotte
254
+ - Mexiko
255
+ - Mikronesien
256
+ - Moldawien
257
+ - Monaco
258
+ - Mongolei
259
+ - Montserrat
260
+ - Marokko
261
+ - Mosambik
262
+ - Myanmar
263
+ - Namibia
264
+ - Nauru
265
+ - Nepal
266
+ - Niederlande
267
+ - Niederländische Antillen
268
+ - Neukaledonien
269
+ - Neuseeland
270
+ - Nicaragua
271
+ - Niger
272
+ - Nigeria
273
+ - Niue
274
+ - Norfolkinsel
275
+ - Nordirland
276
+ - Nördliche Marianen
277
+ - Norwegen
278
+ - Oman
279
+ - Pakistan
280
+ - Palau
281
+ - Panama
282
+ - Papua-Neuguinea
283
+ - Paraguay
284
+ - Peru
285
+ - Philippinen
286
+ - Pitcairninseln
287
+ - Polen
288
+ - Portugal
289
+ - Puerto Rico
290
+ - Katar
291
+ - Réunion
292
+ - Rumänien
293
+ - Russische Föderation
294
+ - Ruanda
295
+ - St. Kitts und Nevis
296
+ - St. Lucia
297
+ - St. Vincent und die Grenadinen
298
+ - Samoa
299
+ - San Marino
300
+ - São Tomé und Príncipe
301
+ - Saudi-Arabien
302
+ - Schottland
303
+ - Senegal
304
+ - Serbien und Montenegro
305
+ - Seychellen
306
+ - Sierra Leone
307
+ - Singapur
308
+ - Slowakei
309
+ - Slowenien
310
+ - Salomonen
311
+ - Somalia
312
+ - Südafrika
313
+ - Südgeorgien und Südliche Sandwichinseln
314
+ - Republik Korea
315
+ - Spanien
316
+ - Sri Lanka
317
+ - St. Helena
318
+ - St.-Pierre und Miquelon
319
+ - Suriname
320
+ - Svalbard und Jan Mayen
321
+ - Swasiland
322
+ - Schweden
323
+ - Schweiz
324
+ - Taiwan
325
+ - Tadschikistan
326
+ - Tansania
327
+ - Thailand
328
+ - Togo
329
+ - Tokelau
330
+ - Tonga
331
+ - Trinidad
332
+ - Trinidad und Tobago
333
+ - Tunesien
334
+ - Türkei
335
+ - Turkmenistan
336
+ - Turks- und Caicosinseln
337
+ - Tuvalu
338
+ - Uganda
339
+ - Ukraine
340
+ - Vereinigte Arabische Emirate
341
+ - Vereinigtes Königreich
342
+ - Vereinigte Staaten
343
+ - Kleinere amerikanische Überseeinseln
344
+ - Uruguay
345
+ - Usbekistan
346
+ - Vanuatu
347
+ - Vatikanstadt
348
+ - Venezuela
349
+ - Vietnam
350
+ - Britische Jungferninseln
351
+ - Amerikanische Jungferninseln
352
+ - Wales
353
+ - Wallis und Futuna
354
+ - Westsahara
355
+ - Jemen
356
+ - Sambia
357
+ - Simbabwe