gettext_i18n_rails 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81637bb2a53f8a8ba80ce961392da2504560e78f
4
- data.tar.gz: 486b7f3fcbb883a32f87f0b1371f57b3db176409
3
+ metadata.gz: 5b639edb5db08cc33d5d8e91ea03aa2bb4b05f7b
4
+ data.tar.gz: 0bdd9275776ba4458410db76f8cd588ab67da765
5
5
  SHA512:
6
- metadata.gz: 8464136d5396b5f1a351933cbb613b4717f10d273c9a1f2cc61f2dbd3b94a9f3c1b834d77c52aebffce565a795c78d5760f9df236ebba132db0b9331433347c1
7
- data.tar.gz: 45be2a2509a1fec097d3205214d25294b9ac173747b9f68788eacefe1b04f6b21649dc20c3e0d960eb95ed2a87825be28fa0eba648f98a8461f7cd83b6df6f5e
6
+ metadata.gz: 45eb5bd57c4597d22fd44233211d244b32bd9a168ef495b1cf3482a11f5ae6f0a21baae09f4919ae561242f70a9add71bf1ea3fc9449fd902ec2150d6da54691
7
+ data.tar.gz: e79b893ecbadeeeb8fafdadded2aef8c4c7e3ced9e38694e0189d6bf105dc199adeb32c4f5e9f32c3a3b2844f78a588ee88a16c21fd99d8be3cc400dbd26da8a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gettext_i18n_rails (1.0.1)
4
+ gettext_i18n_rails (1.0.2)
5
5
  fast_gettext (>= 0.4.8)
6
6
 
7
7
  GEM
data/Readme.md CHANGED
@@ -34,6 +34,21 @@ Add `ruby_parser` if you want to find translations inside haml/slim files
34
34
  gem 'gettext', '>=3.0.2', :require => false, :group => :development
35
35
  gem 'ruby_parser', :require => false, :group => :development
36
36
 
37
+ ###### Add first language:
38
+ Add the first language using:
39
+
40
+ rake gettext:add_language[XX]
41
+
42
+ or
43
+
44
+ LANGUAGE=[XX] rake gettext:add_languange
45
+
46
+ where XX is the [ISO 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) 2-letter code for the language you want to create.
47
+
48
+ This will also create the `locale` directory (where the translations are being stored) and run `gettext:find` to find any strings marked for translation.
49
+
50
+ You can, of course, add more languages using the same command.
51
+
37
52
  #### Rails 2
38
53
 
39
54
  ##### As plugin:
@@ -202,6 +217,60 @@ lib/tasks/gettext.rake:
202
217
  end
203
218
  end
204
219
 
220
+ Customizing text domains setup task
221
+ ===================================
222
+
223
+ By default a single application text domain is created (named `app` or if you load the environment the value of `FastGettext.text_domain` is being used).
224
+
225
+ If you want to have multiple text domains or change the definition of the text domains in any way, you can do so by overriding the `:setup` task in a file like lib/tasks/gettext.rake:
226
+
227
+ # Remove the provided gettext setup task
228
+ Rake::Task["gettext:setup"].clear
229
+
230
+ namespace :gettext do
231
+ task :setup => [:environment] do
232
+ domains = Application.config.gettext["domains"]
233
+
234
+ domains.each do |domain, options|
235
+ files = Dir.glob(options["paths"])
236
+
237
+ GetText::Tools::Task.define do |task|
238
+ task.package_name = options["name"]
239
+ task.package_version = "1.0.0"
240
+ task.domain = options["name"]
241
+ task.po_base_directory = locale_path
242
+ task.mo_base_directory = locale_path
243
+ task.files = files
244
+ task.enable_description = false
245
+ task.msgmerge_options = gettext_msgmerge_options
246
+ task.xgettext_options = gettext_xgettext_options
247
+ end
248
+ end
249
+ end
250
+ end
251
+
252
+ Changing msgmerge and xgettext options
253
+ ======================================
254
+
255
+ The default options for parsing and create `.po` files are:
256
+
257
+ --sort-by-msgid --no-location --no-wrap
258
+
259
+ These options sort the translations by the msgid (original / source string), don't add location information in the po file and don't wrap long message lines into several lines.
260
+
261
+ If you want to override them you can put the following into an initializer like config/initializers/gettext.rb:
262
+
263
+ Rails.application.config.gettext_i18n_rails.msgmerge = %w[--no-location]
264
+ Rails.application.config.gettext_i18n_rails.xgettext = %w[--no-location]
265
+
266
+ or
267
+
268
+ Rails.application.config.gettext_i18n_rails.default_options = %w[--no-location]
269
+
270
+ to override both.
271
+
272
+ You can see the available options by running `rgettext -h` and `rxgettext -h`.
273
+
205
274
  Using your translations from javascript
206
275
  =======================================
207
276
 
@@ -17,33 +17,48 @@ namespace :gettext do
17
17
  Dir.glob("{app,lib,config,#{locale_path}}/**/*.{rb,erb,haml,slim}")
18
18
  end
19
19
 
20
+ def gettext_default_options
21
+ config = (Rails.application.config.gettext_i18n_rails.default_options if defined?(Rails.application))
22
+ config || %w[--sort-by-msgid --no-location --no-wrap]
23
+ end
24
+
25
+ def gettext_msgmerge_options
26
+ config = (Rails.application.config.gettext_i18n_rails.msgmerge if defined?(Rails.application))
27
+ config || gettext_default_options
28
+ end
29
+
30
+ def gettext_xgettext_options
31
+ config = (Rails.application.config.gettext_i18n_rails.xgettext if defined?(Rails.application))
32
+ config || gettext_default_options
33
+ end
34
+
20
35
  $LOAD_PATH << File.join(File.dirname(__FILE__),'..','..','lib') # needed when installed as plugin
21
36
 
22
37
  require "gettext_i18n_rails/haml_parser"
23
38
  require "gettext_i18n_rails/slim_parser"
24
39
 
25
- GetText::Tools::Task.define do |task|
26
- task.package_name = text_domain
27
- task.package_version = "1.0.0"
28
- task.domain = text_domain
29
- task.po_base_directory = locale_path
30
- task.mo_base_directory = locale_path
31
- task.files = files_to_translate
32
- task.enable_description = false
33
-
34
- default = %w[--sort-by-msgid --no-location --no-wrap]
35
- config = (Rails.application.config.gettext_i18n_rails.msgmerge if defined?(Rails.application))
36
- task.msgmerge_options = config || default
37
- config = (Rails.application.config.gettext_i18n_rails.xgettext if defined?(Rails.application))
38
- task.xgettext_options = config || default
40
+ task :setup => [:environment] do
41
+ GetText::Tools::Task.define do |task|
42
+ task.package_name = text_domain
43
+ task.package_version = "1.0.0"
44
+ task.domain = text_domain
45
+ task.po_base_directory = locale_path
46
+ task.mo_base_directory = locale_path
47
+ task.files = files_to_translate
48
+ task.enable_description = false
49
+ task.msgmerge_options = gettext_msgmerge_options
50
+ task.xgettext_options = gettext_xgettext_options
51
+ end
39
52
  end
40
53
 
41
- desc "Create mo-files for L10n"
42
- task :pack => [:environment, "gettext:gettext:mo:update"] do
54
+ desc "Create mo-files"
55
+ task :pack => [:setup] do
56
+ Rake::Task["gettext:mo:update"].invoke
43
57
  end
44
58
 
45
- desc "Update pot/po files."
46
- task :find => [:environment, "gettext:gettext:po:update"] do
59
+ desc "Update pot/po files"
60
+ task :find => [:setup] do
61
+ Rake::Task["gettext:po:update"].invoke
47
62
  end
48
63
 
49
64
  # This is more of an example, ignoring
@@ -1,3 +1,3 @@
1
1
  module GettextI18nRails
2
- Version = VERSION = '1.0.1'
2
+ Version = VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettext_i18n_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-05 00:00:00.000000000 Z
11
+ date: 2013-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fast_gettext
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  requirements: []
99
99
  rubyforge_project:
100
- rubygems_version: 2.0.6
100
+ rubygems_version: 2.0.3
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: Simple FastGettext Rails integration.