gettext-setup 0.31 → 0.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/lib/generate_metadata_pot.rb +2 -0
- data/lib/gettext-setup.rb +2 -0
- data/lib/gettext-setup/gettext_setup.rb +3 -1
- data/lib/gettext-setup/metadata_pot.rb +2 -0
- data/lib/gettext-setup/pot.rb +2 -0
- data/lib/tasks/gettext.rake +2 -0
- data/spec/fixtures/fixture_locales/test_strings.rb +2 -0
- data/spec/lib/gettext-setup/gettext_setup_spec.rb +1 -0
- data/spec/lib/gettext-setup/metadata_pot_spec.rb +2 -0
- data/spec/lib/gettext-setup/pot_spec.rb +5 -1
- data/spec/lib/tasks/gettext_rake_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 315986eb565027255b74f20b6280ac61bfc4fbde16f6a8834514479896d836ef
|
4
|
+
data.tar.gz: cf2cf5d708d1d9feec66908f939d512ed5b4e6cac31017c88bc0f5a7139e3ad2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92e1b0585eeec020a0d3cbb49c1b100cec89fa055af98c6a9f58edef7676e56f4dc29ca6704e60ab617b0e7de4c0ad2c28c2734ed49c84048a529188efc200cb
|
7
|
+
data.tar.gz: 39adfeed57383872989cce413967662f9a72cde9ebf768a261d6867d84a55fcf0055d1956064e5a4fdb72f2f4cc6ca4795a2210b5387f1754b11a40e7f973318
|
data/README.md
CHANGED
@@ -67,7 +67,7 @@ E.g. `n_("There is %{count} bicycle in %{city}", "There are %{count} bicycles in
|
|
67
67
|
|
68
68
|
Pluralization rules vary across languages. The pluralization rules are specified in the PO file and look something like this `Plural-Forms: nplurals=2; plural=(n > 1);`. This is the pluralization rule for German. It means that German has two pluralization rules. The first rule is `plural=n > 1)` and the second rule is all other counts.
|
69
69
|
|
70
|
-
Plurals are selected from the PO file by index.
|
70
|
+
Plurals are selected from the PO file by index.
|
71
71
|
|
72
72
|
Here's an example of how a pluralized string is handled in a PO file:
|
73
73
|
|
@@ -84,7 +84,7 @@ The `msgid_plural` is the plural version of the English source string.
|
|
84
84
|
|
85
85
|
The two `msgstr` lines show that German has two rules for pluralization. The indices map to the `Plural-Forms: nplurals=2; plural=(n > 1);` rule that we specified in the PO file. The `[0]` index represents `plural=(n > 1)` and the `[1]` index represents all other pluralization cases (in other words, when the count equals 0 or 1).
|
86
86
|
|
87
|
-
When Transifex generates a PO file for a specific language, it automatically adds the appropriate pluralization rules in the PO file.
|
87
|
+
When Transifex generates a PO file for a specific language, it automatically adds the appropriate pluralization rules in the PO file.
|
88
88
|
|
89
89
|
### Comments
|
90
90
|
To provide translators with some contextual information or instructions about a string, precede the string with a comment using `#. `. The comment gets pulled in to the POT file and will show up as a comment in Transifex.
|
@@ -99,7 +99,7 @@ E.g. `#. The placeholder in this string represents the name of a parameter.`
|
|
99
99
|
|
100
100
|
3. When a POT file is updated, the Transifex webhook pushes the new POT file to Transifex ready for translation. (If your POT file hasn't been added to the Transifex integration yet, you will need to get it added.)
|
101
101
|
|
102
|
-
4. When a PO file reaches 100% translated and reviewed, a webhook pushes it back to the source repo ready to be consumed by your app.
|
102
|
+
4. When a PO file reaches 100% translated and reviewed, a webhook pushes it back to the source repo ready to be consumed by your app.
|
103
103
|
|
104
104
|
5. Your app checks the user's locale settings (the browser settings for web apps, or the system settings for the CLI). If we support the user's preferred locale, the app will display strings in the user's language. Otherwise, it defaults to English.
|
105
105
|
|
@@ -113,3 +113,7 @@ This task will run within the gettext setup locales_path provided by GettextSetu
|
|
113
113
|
By default, the merged pot file is locales_path/project_name.pot. This can be overridden when calling the method by providing a chosen path.
|
114
114
|
|
115
115
|
Please note: Since the default merged file name is project_name.pot, it will override anything of that name within the locales directory.
|
116
|
+
|
117
|
+
## Making releases
|
118
|
+
|
119
|
+
Add the tag you wish to release (via the bot in the release channel is preferred) and then `gem build gettext-setup.gemspec` and then `gem push gettext-setup-<version>.gem`. (you will need to be an owner to push).
|
data/lib/gettext-setup.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'fast_gettext'
|
2
4
|
require 'yaml'
|
3
5
|
require 'locale'
|
@@ -23,7 +25,7 @@ module GettextSetup
|
|
23
25
|
GettextSetup.initialize_config(locales_path)
|
24
26
|
|
25
27
|
# Make the translation methods available everywhere
|
26
|
-
Object.
|
28
|
+
Object.include FastGettext::Translation
|
27
29
|
|
28
30
|
# Define our text domain, and set the path into our root. I would prefer to
|
29
31
|
# have something smarter, but we really want this up earlier even than our
|
data/lib/gettext-setup/pot.rb
CHANGED
data/lib/tasks/gettext.rake
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rspec/expectations'
|
2
4
|
require 'tmpdir'
|
3
5
|
require_relative '../../spec_helper.rb'
|
@@ -60,7 +62,7 @@ describe GettextSetup::Pot do
|
|
60
62
|
expect(contents).to match(/Fixture locales/)
|
61
63
|
expect(contents).to match(/docs@puppetlabs.com/)
|
62
64
|
expect(contents).to match(/Puppet, LLC/)
|
63
|
-
expect(contents).to match(/test_strings.rb:
|
65
|
+
expect(contents).to match(/test_strings.rb:3/)
|
64
66
|
end
|
65
67
|
it 'builds a POT file with :header_only' do
|
66
68
|
path = File.join(Dir.mktmpdir, 'new.pot')
|
@@ -82,6 +84,8 @@ describe GettextSetup::Pot do
|
|
82
84
|
expect { GettextSetup::Pot.generate_new_po('ja', Dir.mktmpdir, path, po_path) }.to raise_error(NoConfigFoundError)
|
83
85
|
end
|
84
86
|
it 'complains when no language is supplied' do
|
87
|
+
allow(ENV).to receive(:[]).and_call_original
|
88
|
+
allow(ENV).to receive(:[]).with('LANGUAGE').and_return(nil)
|
85
89
|
result = "You need to specify the language to add. Either 'LANGUAGE=eo rake gettext:po' or 'rake gettext:po[LANGUAGE]'\n"
|
86
90
|
expect do
|
87
91
|
GettextSetup::Pot.generate_new_po(nil, fixture_locales_path, Dir.mktmpdir, Dir.mktmpdir)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gettext-setup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.32'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fast_gettext
|
@@ -31,6 +31,9 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 3.0.2
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.3.0
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +41,9 @@ dependencies:
|
|
38
41
|
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: 3.0.2
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.3.0
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: locale
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,16 +62,16 @@ dependencies:
|
|
56
62
|
name: bundler
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- - "
|
65
|
+
- - ">="
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
67
|
+
version: '0'
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- - "
|
72
|
+
- - ">="
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
74
|
+
version: '0'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: rake
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|