morhekil-globalite 0.5.1

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