fast_gettext 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +9 -0
- data/Readme.md +261 -0
- data/lib/fast_gettext/translation_repository/base.rb +1 -1
- data/lib/fast_gettext/version.rb +1 -1
- metadata +4 -4
- data/lib/fast_gettext/vendor/README.rdoc +0 -236
- data/lib/fast_gettext/vendor/empty.mo +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e950168f5c4906388182c1519f94dca382b9f8d
|
4
|
+
data.tar.gz: 87ccd2d74b9fa75d793ddd567dd29958c65ad5d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 555d77cfd028831010bea1e5f8b71f23dbd83ffee91577539da106246a2398e70fa80d4a433c5a7310ffe62d9cfe8e5ce1ac19c5f5c843675a759825a6a1b66f
|
7
|
+
data.tar.gz: ac3553f888f29ac7cd7903c03a11806510af5c77a129344480bb3d45f07c67b4d80579c67fa62967b70549b7e8daa7019e5663085a052d858b54b275c33ea654
|
data/CHANGELOG
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
0.9.0 -- reworked internals of caching to be plugable
|
2
|
+
0.7.0 -- set_locale resets to default locale if none of the available locales was tried to set
|
3
|
+
0.6.0 -- plurals use singular translations as fallack e.g. you translated 'Axis' then n_('Axis','Axis',1) would return the translation for 'Axis' if no plural translation was found
|
4
|
+
0.4.14 -- "" is translated as "", not as gettext meta information
|
5
|
+
0.4.0 -- pluralisation_rules is no longer stored in each repository, only retrived. Added Chain and Logger repository.
|
6
|
+
0.3.6 -- FastGettext.default_locale=
|
7
|
+
0.3.5 -- FastGettext.default_text_domain=
|
8
|
+
0.3.4 -- Exceptions are thrown, not returned when translating without text domain
|
9
|
+
0.3 -- pluralisation methods accept/return n plural forms, contrary to singular/plural before
|
data/Readme.md
ADDED
@@ -0,0 +1,261 @@
|
|
1
|
+
FastGettext
|
2
|
+
===========
|
3
|
+
GetText but 3.5 x faster, 560 x less memory, simple, clean namespace (7 vs 34) and threadsafe!
|
4
|
+
|
5
|
+
It supports multiple backends (.mo, .po, .yml files, Database(ActiveRecord + any other), Chain, Loggers) and can easily be extended.
|
6
|
+
|
7
|
+
[Example Rails application](https://github.com/grosser/gettext_i18n_rails_example)
|
8
|
+
|
9
|
+
Comparison
|
10
|
+
==========
|
11
|
+
<table>
|
12
|
+
<tr>
|
13
|
+
<td></td>
|
14
|
+
<td width="100">Hash</td>
|
15
|
+
<td width="150">FastGettext</td>
|
16
|
+
<td width="100">GetText</td>
|
17
|
+
<td width="100">ActiveSupport I18n::Simple</td>
|
18
|
+
</tr>
|
19
|
+
<tr>
|
20
|
+
<td>Speed*</td>
|
21
|
+
<td>0.82s</td>
|
22
|
+
<td>1.36s</td>
|
23
|
+
<td>4.88s</td>
|
24
|
+
<td>21.77s</td>
|
25
|
+
</tr>
|
26
|
+
<tr>
|
27
|
+
<td>RAM*</td>
|
28
|
+
<td>4K</td>
|
29
|
+
<td>8K</td>
|
30
|
+
<td>4480K</td>
|
31
|
+
<td>10100K</td>
|
32
|
+
</tr>
|
33
|
+
<tr>
|
34
|
+
<td>Included backends</td>
|
35
|
+
<td></td>
|
36
|
+
<td>db, yml, mo, po, logger, chain</td>
|
37
|
+
<td>mo</td>
|
38
|
+
<td>yml (db/key-value/po/chain in other I18n backends)</td>
|
39
|
+
</tr>
|
40
|
+
</table>
|
41
|
+
<small>*50.000 translations with ruby enterprise 1.8.6 through `rake benchmark`</small>
|
42
|
+
|
43
|
+
Setup
|
44
|
+
=====
|
45
|
+
### 1. Install
|
46
|
+
|
47
|
+
sudo gem install fast_gettext
|
48
|
+
|
49
|
+
### 2. Add a translation repository
|
50
|
+
|
51
|
+
From mo files (traditional/default)
|
52
|
+
|
53
|
+
FastGettext.add_text_domain('my_app',:path => 'locale')
|
54
|
+
|
55
|
+
Or po files (less maintenance than mo)
|
56
|
+
|
57
|
+
FastGettext.add_text_domain('my_app',:path => 'locale', :type => :po)
|
58
|
+
# :ignore_fuzzy => true to not use fuzzy translations
|
59
|
+
# :report_warning => false to hide warnings about obsolete/fuzzy translations
|
60
|
+
|
61
|
+
Or yaml files (use I18n syntax/indentation)
|
62
|
+
|
63
|
+
FastGettext.add_text_domain('my_app', :path => 'config/locales', :type => :yaml)
|
64
|
+
|
65
|
+
Or database (scaleable, good for many locales/translators)
|
66
|
+
|
67
|
+
# db access is cached <-> only first lookup hits the db
|
68
|
+
require "fast_gettext/translation_repository/db"
|
69
|
+
FastGettext::TranslationRepository::Db.require_models #load and include default models
|
70
|
+
FastGettext.add_text_domain('my_app', :type => :db, :model => TranslationKey)
|
71
|
+
|
72
|
+
### 3. Choose text domain and locale for translation
|
73
|
+
Do this once in every Thread. (e.g. Rails -> ApplicationController)
|
74
|
+
|
75
|
+
FastGettext.text_domain = 'my_app'
|
76
|
+
FastGettext.available_locales = ['de','en','fr','en_US','en_UK'] # only allow these locales to be set (optional)
|
77
|
+
FastGettext.locale = 'de'
|
78
|
+
|
79
|
+
### 4. Start translating
|
80
|
+
|
81
|
+
include FastGettext::Translation
|
82
|
+
_('Car') == 'Auto'
|
83
|
+
_('not-found') == 'not-found'
|
84
|
+
s_('Namespace|not-found') == 'not-found'
|
85
|
+
n_('Axis','Axis',3) == 'Achsen' #German plural of Axis
|
86
|
+
_('Hello %{name}!') % {:name => "Pete"} == 'Hello Pete!'
|
87
|
+
|
88
|
+
|
89
|
+
Managing translations
|
90
|
+
============
|
91
|
+
### mo/po-files
|
92
|
+
Generate .po or .mo files using GetText parser (example tasks at [gettext_i18n_rails](http://github.com/grosser/gettext_i18n_rails))
|
93
|
+
|
94
|
+
Tell Gettext where your .mo or .po files lie, e.g. for locale/de/my_app.po and locale/de/LC_MESSAGES/my_app.mo
|
95
|
+
|
96
|
+
FastGettext.add_text_domain('my_app',:path=>'locale')
|
97
|
+
|
98
|
+
Use the [original GetText](http://github.com/mutoh/gettext) to create and manage po/mo-files.
|
99
|
+
(Work on a po/mo parser & reader that is easier to use has started, contributions welcome @ [get_pomo](http://github.com/grosser/get_pomo) )
|
100
|
+
|
101
|
+
###Database
|
102
|
+
[Example migration for ActiveRecord](http://github.com/grosser/fast_gettext/blob/master/examples/db/migration.rb)<br/>
|
103
|
+
The default plural seperator is `||||` but you may overwrite it (or suggest a better one..).
|
104
|
+
|
105
|
+
This is usable with any model DataMapper/Sequel or any other(non-database) backend, the only thing you need to do is respond to the self.translation(key, locale) call.
|
106
|
+
If you want to use your own models, have a look at the [default models](http://github.com/grosser/fast_gettext/tree/master/lib/fast_gettext/translation_repository/db_models) to see what you want/need to implement.
|
107
|
+
|
108
|
+
To manage translations via a Web GUI, use a [Rails application and the translation_db_engine](http://github.com/grosser/translation_db_engine)
|
109
|
+
|
110
|
+
Rails
|
111
|
+
=======================
|
112
|
+
Try the [gettext_i18n_rails plugin](http://github.com/grosser/gettext_i18n_rails), it simplifies the setup.<br/>
|
113
|
+
Try the [translation_db_engine](http://github.com/grosser/translation_db_engine), to manage your translations in a db.
|
114
|
+
|
115
|
+
Setting `available_locales`,`text_domain` or `locale` will not work inside the `evironment.rb`,
|
116
|
+
since it runs in a different thread then e.g. controllers, so set them inside your application_controller.
|
117
|
+
|
118
|
+
#environment.rb after initializers
|
119
|
+
Object.send(:include,FastGettext::Translation)
|
120
|
+
FastGettext.add_text_domain('accounting',:path=>'locale')
|
121
|
+
FastGettext.add_text_domain('frontend',:path=>'locale')
|
122
|
+
...
|
123
|
+
|
124
|
+
#application_controller.rb
|
125
|
+
class ApplicationController ...
|
126
|
+
include FastGettext::Translation
|
127
|
+
before_filter :set_locale
|
128
|
+
def set_locale
|
129
|
+
FastGettext.available_locales = ['de','en',...]
|
130
|
+
FastGettext.text_domain = 'frontend'
|
131
|
+
FastGettext.set_locale(params[:locale] || session[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'])
|
132
|
+
session[:locale] = I18n.locale = FastGettext.locale
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
Advanced features
|
137
|
+
=================
|
138
|
+
### Abnormal pluralisation
|
139
|
+
Plurals are selected by index, think of it as `['car', 'cars'][index]`<br/>
|
140
|
+
A pluralisation rule decides which form to use e.g. in english its `count == 1 ? 0 : 1`.<br/>
|
141
|
+
If you have any languages that do not fit this rule, you have to add a custom pluralisation rule.
|
142
|
+
|
143
|
+
Via Ruby:
|
144
|
+
|
145
|
+
FastGettext.pluralisation_rule = lamda{|count| count > 5 ? 1 : (count > 2 ? 0 : 2)}
|
146
|
+
|
147
|
+
Via mo/pofile:
|
148
|
+
|
149
|
+
Plural-Forms: nplurals=2; plural=n==2?3:4;
|
150
|
+
|
151
|
+
[Plural expressions for all languages](http://translate.sourceforge.net/wiki/l10n/pluralforms).
|
152
|
+
|
153
|
+
###default_text_domain
|
154
|
+
If you only use one text domain, setting `FastGettext.default_text_domain = 'app'`
|
155
|
+
is sufficient and no more `text_domain=` is needed
|
156
|
+
|
157
|
+
###default_locale
|
158
|
+
If the simple rule of "first `availble_locale` or 'en'" is not suficcient for you, set `FastGettext.default_locale = 'de'`.
|
159
|
+
|
160
|
+
###default_available_locales
|
161
|
+
Fallback when no available_locales are set
|
162
|
+
|
163
|
+
###Chains
|
164
|
+
You can use any number of repositories to find a translation. Simply add them to a chain and when
|
165
|
+
the first cannot translate a given key, the next is asked and so forth.
|
166
|
+
|
167
|
+
repos = [
|
168
|
+
FastGettext::TranslationRepository.build('new', :path=>'....'),
|
169
|
+
FastGettext::TranslationRepository.build('old', :path=>'....')
|
170
|
+
]
|
171
|
+
FastGettext.add_text_domain 'combined', :type=>:chain, :chain=>repos
|
172
|
+
|
173
|
+
###Logger
|
174
|
+
When you want to know which keys could not be translated or were used, add a Logger to a Chain:
|
175
|
+
|
176
|
+
repos = [
|
177
|
+
FastGettext::TranslationRepository.build('app', :path=>'....')
|
178
|
+
FastGettext::TranslationRepository.build('logger', :type=>:logger, :callback=>lamda{|key_or_array_of_ids| ... }),
|
179
|
+
}
|
180
|
+
FastGettext.add_text_domain 'combined', :type=>:chain, :chain=>repos
|
181
|
+
|
182
|
+
If the Logger is in position #1 it will see all translations, if it is in position #2 it will only see the unfound.
|
183
|
+
Unfound may not always mean missing, if you choose not to translate a word because the key is a good translation, it will appear nevertheless.
|
184
|
+
A lambda or anything that responds to `call` will do as callback. A good starting point may be `examples/missing_translations_logger.rb`.
|
185
|
+
|
186
|
+
###Plugins
|
187
|
+
Want a xml version ?
|
188
|
+
Write your own TranslationRepository!
|
189
|
+
|
190
|
+
#fast_gettext/translation_repository/xxx.rb
|
191
|
+
module FastGettext
|
192
|
+
module TranslationRepository
|
193
|
+
class Wtf
|
194
|
+
define initialize(name,options), [key], plural(*keys) and
|
195
|
+
either inherit from TranslationRepository::Base or define available_locales and pluralisation_rule
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
###Multi domain support
|
201
|
+
|
202
|
+
If you have more than one gettext domain, there are two sets of functions
|
203
|
+
available:
|
204
|
+
|
205
|
+
include FastGettext::TranslationMultidomain
|
206
|
+
|
207
|
+
d_("domainname", "string") # finds 'string' in domain domainname
|
208
|
+
dn_("domainname", "string", "strings", 1) # ditto
|
209
|
+
# etc.
|
210
|
+
|
211
|
+
These are helper methods so you don't need to write:
|
212
|
+
|
213
|
+
FastGettext.text_domain = "domainname"
|
214
|
+
_("string")
|
215
|
+
|
216
|
+
It is useful in Rails plugins in the views for example. The second set of
|
217
|
+
functions are D functions which search for string in _all_ domains. If there
|
218
|
+
are multiple translations in different domains, it returns them in random
|
219
|
+
order (depends on the Ruby hash implementation):
|
220
|
+
|
221
|
+
include FastGettext::TranslationMultidomain
|
222
|
+
|
223
|
+
D_("string") # finds 'string' in any domain
|
224
|
+
# etc.
|
225
|
+
|
226
|
+
FAQ
|
227
|
+
===
|
228
|
+
- [Problems with ActiveRecord messages?](http://wiki.github.com/grosser/fast_gettext/activerecord)
|
229
|
+
- [Iconv require error in 1.9.2](http://exceptionz.wordpress.com/2010/02/03/how-to-fix-the-iconv-require-error-in-ruby-1-9)
|
230
|
+
|
231
|
+
|
232
|
+
TODO
|
233
|
+
====
|
234
|
+
- Add a fallback for Iconv.conv in ruby 1.9.4 -> lib/fast_gettext/vendor/iconv
|
235
|
+
- YML backend that reads ActiveSupport::I18n files
|
236
|
+
|
237
|
+
Author
|
238
|
+
======
|
239
|
+
Mo/Po-file parsing from Masao Mutoh, see vendor/README
|
240
|
+
|
241
|
+
### [Contributors](http://github.com/grosser/fast_gettext/contributors)
|
242
|
+
- [geekq](http://www.innoq.com/blog/vd)
|
243
|
+
- [Matt Sanford](http://blog.mzsanford.com)
|
244
|
+
- [Antonio Terceiro](http://softwarelivre.org/terceiro)
|
245
|
+
- [J. Pablo Fernández](http://pupeno.com)
|
246
|
+
- Rudolf Gavlas
|
247
|
+
- [Ramón Cahenzli](http://www.psy-q.ch)
|
248
|
+
- [Rainux Luo](http://rainux.org)
|
249
|
+
- [Dmitry Borodaenko](https://github.com/angdraug)
|
250
|
+
- [Kouhei Sutou](https://github.com/kou)
|
251
|
+
- [Hoang Nghiem](https://github.com/hoangnghiem)
|
252
|
+
- [Costa Shapiro](https://github.com/costa)
|
253
|
+
- [Jamie Dyer](https://github.com/kernow)
|
254
|
+
- [Stephan Kulow](https://github.com/coolo)
|
255
|
+
- [Fotos Georgiadis](https://github.com/fotos)
|
256
|
+
- [Lukáš Zapletal](https://github.com/lzap)
|
257
|
+
|
258
|
+
[Michael Grosser](http://grosser.it)<br/>
|
259
|
+
michael@grosser.it<br/>
|
260
|
+
License: MIT, some vendor parts under the same license terms as Ruby (see headers)<br/>
|
261
|
+
[![Build Status](https://travis-ci.org/grosser/fast_gettext.png)](https://travis-ci.org/grosser/fast_gettext)
|
@@ -37,7 +37,7 @@ module FastGettext
|
|
37
37
|
|
38
38
|
def find_files_in_locale_folders(relative_file_path,path)
|
39
39
|
path ||= "locale"
|
40
|
-
raise "path #{path}
|
40
|
+
raise "path #{path} could not be found!" unless File.exist?(path)
|
41
41
|
|
42
42
|
@files = {}
|
43
43
|
Dir[File.join(path,'*')].each do |locale_folder|
|
data/lib/fast_gettext/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_gettext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -114,6 +114,8 @@ executables: []
|
|
114
114
|
extensions: []
|
115
115
|
extra_rdoc_files: []
|
116
116
|
files:
|
117
|
+
- CHANGELOG
|
118
|
+
- Readme.md
|
117
119
|
- lib/fast_gettext.rb
|
118
120
|
- lib/fast_gettext/cache.rb
|
119
121
|
- lib/fast_gettext/mo_file.rb
|
@@ -130,8 +132,6 @@ files:
|
|
130
132
|
- lib/fast_gettext/translation_repository/mo.rb
|
131
133
|
- lib/fast_gettext/translation_repository/po.rb
|
132
134
|
- lib/fast_gettext/translation_repository/yaml.rb
|
133
|
-
- lib/fast_gettext/vendor/README.rdoc
|
134
|
-
- lib/fast_gettext/vendor/empty.mo
|
135
135
|
- lib/fast_gettext/vendor/iconv.rb
|
136
136
|
- lib/fast_gettext/vendor/mofile.rb
|
137
137
|
- lib/fast_gettext/vendor/poparser.rb
|
@@ -1,236 +0,0 @@
|
|
1
|
-
= Ruby-GetText-Package
|
2
|
-
|
3
|
-
Ruby-GetText-Package is a Localization(L10n) library and tool
|
4
|
-
which is modeled after the GNU gettext package.
|
5
|
-
|
6
|
-
This library translates original messages to localized
|
7
|
-
messages using client-side locale information(environment
|
8
|
-
variable or CGI variable).
|
9
|
-
|
10
|
-
The tools for developers support creating, useing, and modifying
|
11
|
-
localized message files(message catalogs).
|
12
|
-
|
13
|
-
((*Rails*))
|
14
|
-
Rails support has been removed.
|
15
|
-
Rails / ActiveRecord specific code now lives in gettext_rails and gettext_activerecord.
|
16
|
-
|
17
|
-
== Website
|
18
|
-
* homepage[http://www.yotabanana.com/hiki/ruby-gettext.html]
|
19
|
-
* on rubyforge[http://gettext/rubyforge.org/]
|
20
|
-
* on github[http://github.com/gettext/]
|
21
|
-
|
22
|
-
== Features
|
23
|
-
* Simple APIs(similar to GNU gettext)
|
24
|
-
|
25
|
-
* rgettext creates po-files from
|
26
|
-
* ruby scripts
|
27
|
-
* glade-2 XML file(.glade)
|
28
|
-
* ERB file(.rhtml, .erb)
|
29
|
-
* Anything (with your own parsers)
|
30
|
-
* The po-files are compatible to GNU gettext.
|
31
|
-
|
32
|
-
* rmsgfmt creates a mo-file from a po-file.
|
33
|
-
The mo-file is compatible to GNU gettext(msgfmt).
|
34
|
-
|
35
|
-
* textdomain's scope is adapt to ruby class/module mechanism.
|
36
|
-
* A class/module can have plural textdomains.
|
37
|
-
* a message is looked up in its class/module and ancestors.
|
38
|
-
|
39
|
-
* CGI support (gettext/cgi)
|
40
|
-
* Locale is retrieved from client informations
|
41
|
-
(HTTP_ACCEPT_LANGUAGE, HTTP_ACCEPT_CHARSET, QUERY_STRING(lang), Cookies(lang)).
|
42
|
-
|
43
|
-
* String%() is extended to use named argument such as <tt>%{foo}" %{:foo => 1}</tt>.
|
44
|
-
Notes that Ruby-1.9.x supports this format by itself.
|
45
|
-
|
46
|
-
== Requirements
|
47
|
-
* {Ruby 1.8.3 or later}[http://www.ruby-lang.org]
|
48
|
-
* {Rubygems}[http://www.rubygems.org/]
|
49
|
-
* {locale gem}[http://rubyforge.org/projects/locale/]
|
50
|
-
* $ gem install locale
|
51
|
-
* (for development only)
|
52
|
-
* {GNU gettext 0.10.35 or later}[http://www.gnu.org/software/gettext/gettext.html]
|
53
|
-
* {Racc-1.4.3 or later}[http://www.ruby-lang.org/raa/list.rhtml?name=racc]
|
54
|
-
* (for compiling src/rmsgfmt.ry only)
|
55
|
-
|
56
|
-
== Install
|
57
|
-
* Uninstall old gettext if exists.
|
58
|
-
(sudo/su on POSIX system)
|
59
|
-
gem uninstall gettext
|
60
|
-
|
61
|
-
* gem
|
62
|
-
#from github (edge/unstable)
|
63
|
-
(sudo/su on POSIX system)
|
64
|
-
gem install locale
|
65
|
-
gem install mutoh-gettext -s http://gems.github.com/
|
66
|
-
|
67
|
-
#from rubyforge (stable)
|
68
|
-
(sudo/su on POSIX system)
|
69
|
-
gem install locale
|
70
|
-
gem install gettext
|
71
|
-
|
72
|
-
* download tar-ball
|
73
|
-
# De-Compress archive and enter its top directory.
|
74
|
-
(sudo/su on POSIX system)
|
75
|
-
ruby setup.rb
|
76
|
-
|
77
|
-
You can also install files in your favorite directory by
|
78
|
-
supplying setup.rb some options. Try <tt>ruby setup.rb --help</tt>.
|
79
|
-
|
80
|
-
== Usage
|
81
|
-
===Translation
|
82
|
-
- _: Basic translation method
|
83
|
-
Translates the message.
|
84
|
-
_("Hello")
|
85
|
-
|
86
|
-
The gettext methods comes in 3 combinable flavors
|
87
|
-
- n: Pluralized
|
88
|
-
Returns singular or plural form, depending on how many you have.
|
89
|
-
n_("Apple", "%{num} Apples", 3)
|
90
|
-
n_(["Apple", "%{num} Apples"], 3)
|
91
|
-
|
92
|
-
- p: context aware
|
93
|
-
A context is a prefix to your translation, usefull when one word has different meanings, depending on its context.
|
94
|
-
p_("Printer","Open") <=> p_("File","Open")
|
95
|
-
is the same as s_("Printer|Open") <=> s_("File|Open")
|
96
|
-
|
97
|
-
- s: without context
|
98
|
-
If a translation could not be found, return the msgid without context.
|
99
|
-
s_("Printer|Open") => "Öffnen" #translation found
|
100
|
-
s_("Printer|Open") => "Open" #translation not found
|
101
|
-
|
102
|
-
- combinations
|
103
|
-
np_("Fruit", "Apple", "%{num} Apples", 3)
|
104
|
-
ns_("Fruit|Apple","%{num} Apples", 3)
|
105
|
-
|
106
|
-
np_(["Fruit","Apple","%{num} Apples"], 3)
|
107
|
-
ns_(["Fruit|Apple","%{num} Apples"], 3)
|
108
|
-
|
109
|
-
- N_, Nn_: Makes dynamic translation messages readable for the gettext parser.
|
110
|
-
<tt>_(fruit)</tt> cannot be understood by the gettext parser. To help the parser find all your translations,
|
111
|
-
you can add <tt>fruit = N_("Apple")</tt> which does not translate, but tells the parser: "Apple" needs translation.
|
112
|
-
|
113
|
-
fruit = N_("Apple") # same as fruit = "Apple"
|
114
|
-
_(fruit) # does a normal translation
|
115
|
-
|
116
|
-
fruits = Nn_("Apple", "%{num} Apples")
|
117
|
-
n_(fruits, 3)
|
118
|
-
|
119
|
-
=== Locale / Domain
|
120
|
-
GetText stores the locale your are using
|
121
|
-
GetText.locale = "en_US" # translate into english from now on
|
122
|
-
GetText.locale # => en_US
|
123
|
-
Or
|
124
|
-
include GetText
|
125
|
-
set_locale "en_US"
|
126
|
-
|
127
|
-
Each locale can have different sets of translations (text domains) (e.g. Financial terms + Human-resource terms)
|
128
|
-
GetText.bindtextdomain('financial')
|
129
|
-
Or
|
130
|
-
include GetText
|
131
|
-
bindtextdomain('financial')
|
132
|
-
|
133
|
-
For more details and options, have a look at the samples folder or
|
134
|
-
consult the tutorial[http://www.yotabanana.com/hiki/ruby-gettext-howto.html].
|
135
|
-
|
136
|
-
|
137
|
-
== License
|
138
|
-
This program is licenced under the same licence as Ruby.
|
139
|
-
(See the file 'COPYING'.)
|
140
|
-
|
141
|
-
* mofile.rb
|
142
|
-
* Copyright (C) 2001-2009 Masao Mutoh <mutoh at highwhay.ne.jp>
|
143
|
-
* Copyright (C) 2001,2002 Masahiro Sakai <s01397ms at sfc.keio.ac.jp>
|
144
|
-
|
145
|
-
* gettext.rb
|
146
|
-
* Copyright (C) 2001-2009 Masao Mutoh <mutoh at highwhay.ne.jp>
|
147
|
-
* Copyright (C) 2001,2002 Masahiro Sakai <s01397ms at sfc.keio.ac.jp>
|
148
|
-
|
149
|
-
* rgettext
|
150
|
-
* Copyright (C) 2001-2009 Masao Mutoh <mutoh at highwhay.ne.jp>
|
151
|
-
* Copyright (C) 2001,2002 Yasushi Shoji <yashi at atmark-techno.com>
|
152
|
-
|
153
|
-
* setup.rb
|
154
|
-
* Copyright (C) 2000-2005 Minero Aoki <aamine at loveruby.net>
|
155
|
-
* This file is released under LGPL. See the top of the install.rb.
|
156
|
-
|
157
|
-
* Others
|
158
|
-
* Copyright (C) 2001-2009 Masao Mutoh <mutoh at highwhay.ne.jp>
|
159
|
-
|
160
|
-
|
161
|
-
== Translators
|
162
|
-
* Bosnian(bs) - Sanjin Sehic <saserr at gmail.com>
|
163
|
-
* Bulgarian(bg) - Sava Chankov <sava.chankov at gmail.com>
|
164
|
-
* Catalan(ca) - Ramon Salvadó <rsalvado at gnuine.com>
|
165
|
-
* Chinese(Simplified)(zh_CN)
|
166
|
-
* Yang Bob <bob.yang.dev at gmail.com> (current)
|
167
|
-
* Yingfeng <blogyingfeng at gmail.com>
|
168
|
-
* Chinese(Traditional)(zh_TW)
|
169
|
-
* Yang Bob <bob.yang.dev at gmail.com> (current)
|
170
|
-
* LIN CHUNG-YI <xmarsh at gmail.com>
|
171
|
-
* Croatian(hr) - Sanjin Sehic <saserr at gmail.com>
|
172
|
-
* Czech(cs) - Karel Miarka <kajism at yahoo.com>
|
173
|
-
* Dutch(nl) - Menno Jonkers <ruby-gettext at jonkers.com>
|
174
|
-
* Esperanto(eo) - Malte Milatz <malte at gmx-topmail.de>
|
175
|
-
* Estonian(et) - Erkki Eilonen <erkki at itech.ee>
|
176
|
-
* French(fr)
|
177
|
-
* Vincent Isambart <vincent.isambart at gmail.com> (current)
|
178
|
-
* David Sulc <davidsulc at gmail.com>
|
179
|
-
* Laurent Sansonetti <laurent.sansonetti at gmail.com>
|
180
|
-
* German(de)
|
181
|
-
* Patrick Lenz <patrick at limited-overload.de> (current)
|
182
|
-
* Detlef Reichl <detlef.reichl at gmx.org>
|
183
|
-
* Sven Herzberg <herzi at abi02.de>
|
184
|
-
* Sascha Ebach <se at digitale-wertschoepfung.de>
|
185
|
-
* Greek(el) - Vassilis Rizopoulos <damphyr at gmx.net>
|
186
|
-
* Hungarian(hu) - Tamás Tompa <tompata at gmail.com>
|
187
|
-
* Italian(it)
|
188
|
-
* Marco Lazzeri <marco.lazzeri at gmail.com>
|
189
|
-
* Gabriele Renzi <surrender_it at yahoo.it>
|
190
|
-
* Japanese(ja) - Masao Mutoh <mutoh at highway.ne.jp>
|
191
|
-
* Korean(ko) - Gyoung-Yoon Noh <nohmad at gmail.com>
|
192
|
-
* Latvian(lv) - Aivars Akots <aivars.akots at gmail.com>
|
193
|
-
* Norwegian(nb) - Runar Ingebrigtsen <runar at mopo.no>
|
194
|
-
* Portuguese(Brazil)(pt_BR)
|
195
|
-
* Antonio S. de A. Terceiro <terceiro at softwarelivre.org> (current)
|
196
|
-
* Joao Pedrosa <joaopedrosa at gmail.com>
|
197
|
-
* Russian(ru) - Yuri Kozlov <kozlov.y at gmail.com>
|
198
|
-
* Serbian(sr) - Slobodan Paunović" <slobodan.paunovic at gmail.com>
|
199
|
-
* Spanish(es)
|
200
|
-
* David Espada <davinci at escomposlinux.org> (current)
|
201
|
-
* David Moreno Garza <damog at damog.net>
|
202
|
-
* Swedish(sv) - Nikolai Weibull <mailing-lists.ruby-talk at rawuncut.elitemail.org>
|
203
|
-
* Ukrainian(ua) - Alex Rootoff <rootoff at pisem.net>
|
204
|
-
* Vietnamese(vi) - Ngoc Dao Thanh <ngocdaothanh at gmail.com>
|
205
|
-
|
206
|
-
== Status of translations
|
207
|
-
* Bosnian(bs) - 1.90.0 (old)
|
208
|
-
* Bulgarian(bg) - 2.0.0pre1 (new)
|
209
|
-
* Catalan(ca) - 2.0.0pre1
|
210
|
-
* Croatian(hr) - 1.90.0 (old)
|
211
|
-
* Chinese(zh_CN) - 2.0.0pre1
|
212
|
-
* Chinese(zh_TW) - 2.0.0pre1
|
213
|
-
* Czech(cs) - 1.9.0 (old)
|
214
|
-
* Dutch(nl) - 1.90.0 (old)
|
215
|
-
* English(default) - 1.90.0 (old)
|
216
|
-
* Esperanto(eo) - 2.0.0pre1
|
217
|
-
* Estonian(et) - 2.0.0pre1
|
218
|
-
* French(fr) - 2.0.0pre1
|
219
|
-
* German(de) - 2.0.0pre1
|
220
|
-
* Greek(el) - 2.0.0pre1
|
221
|
-
* Hungarian(hu) - 2.0.0pre1
|
222
|
-
* Italian(it) - 1.6.0 (old)
|
223
|
-
* Japanese(ja) - 2.0.0pre1
|
224
|
-
* Korean(ko) - 1.9.0 (old)
|
225
|
-
* Latvian(lv) - 2.0.0pre1 (new)
|
226
|
-
* Norwegian(nb) - 2.0.0pre1
|
227
|
-
* Portuguese(Brazil)(pt_BR) - 2.0.0pre1
|
228
|
-
* Russian(ru) - 2.0.0pre1
|
229
|
-
* Serbian(sr) - 1.91.0 (old)
|
230
|
-
* Spanish(es) - 2.0.0pre1
|
231
|
-
* Swedish(sv) - 0.8.0 (too much old)
|
232
|
-
* Ukrainian(ua) - 2.0.0pre1
|
233
|
-
* Vietnamese(vi) - 2.0.0pre1
|
234
|
-
|
235
|
-
== Maintainer
|
236
|
-
Masao Mutoh <mutoh at highway.ne.jp>
|
Binary file
|