gettext-setup 0.1 → 0.2
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.
- checksums.yaml +4 -4
- data/Gemfile +9 -2
- data/Gemfile.lock +33 -0
- data/Rakefile +32 -0
- data/gettext-setup.gemspec +1 -1
- data/spec/fixtures/locales/config.yaml +22 -0
- data/spec/fixtures/locales/de/sinatra-i18n.po +23 -0
- data/spec/fixtures/locales/sinatra-i18n.pot +25 -0
- data/spec/lib/gettext_setup_spec.rb +35 -0
- data/spec/spec_helper.rb +6 -0
- metadata +14 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07787a9c7da124afcaa7614a78bd98bf3576d351
|
4
|
+
data.tar.gz: 7a708cb4b855573826592059b4aaceea3cad75ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9de77313f2f1f4813da4dbdb8fcc48110b3a987c2866f25bde35856bac1915ce470a8f4a3d71cbb86387c0b307baead8e763bf1a214ccde23c4e32fc22312c70
|
7
|
+
data.tar.gz: 7e3e5ab9c9ff37d6e72829fe673426d9a5f2e38e5f663d3888fece67471584a228628adf573998f49f2ab78fc8800337281d098d745f669c749a25f66bcabacf
|
data/Gemfile
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'fast_gettext'
|
4
|
+
gem 'gettext', ">= 3.0.2"
|
4
5
|
|
5
6
|
gem 'rake', :require => false
|
6
7
|
|
7
|
-
group :
|
8
|
-
gem '
|
8
|
+
group :test do
|
9
|
+
gem 'rack-test'
|
10
|
+
gem 'rspec', '~> 2.13.0'
|
11
|
+
gem 'rspec-core', '~> 2.13.1'
|
12
|
+
gem 'rspec-expectations', '~> 2.13.0'
|
13
|
+
gem 'rspec-mocks', '~> 2.13.1'
|
14
|
+
gem 'simplecov'
|
15
|
+
gem 'webmock'
|
9
16
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,39 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
+
addressable (2.4.0)
|
5
|
+
crack (0.4.2)
|
6
|
+
safe_yaml (~> 1.0.0)
|
7
|
+
diff-lcs (1.2.5)
|
8
|
+
docile (1.1.5)
|
4
9
|
fast_gettext (1.0.0)
|
5
10
|
gettext (3.2.1)
|
6
11
|
locale (>= 2.0.5)
|
7
12
|
text (>= 1.3.0)
|
13
|
+
json (1.8.3-java)
|
8
14
|
locale (2.1.2)
|
15
|
+
rack (1.6.4)
|
16
|
+
rack-test (0.6.3)
|
17
|
+
rack (>= 1.0)
|
9
18
|
rake (10.4.2)
|
19
|
+
rspec (2.13.0)
|
20
|
+
rspec-core (~> 2.13.0)
|
21
|
+
rspec-expectations (~> 2.13.0)
|
22
|
+
rspec-mocks (~> 2.13.0)
|
23
|
+
rspec-core (2.13.1)
|
24
|
+
rspec-expectations (2.13.0)
|
25
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
26
|
+
rspec-mocks (2.13.1)
|
27
|
+
safe_yaml (1.0.4)
|
28
|
+
simplecov (0.10.0)
|
29
|
+
docile (~> 1.1.0)
|
30
|
+
json (~> 1.8)
|
31
|
+
simplecov-html (~> 0.10.0)
|
32
|
+
simplecov-html (0.10.0)
|
10
33
|
text (1.3.1)
|
34
|
+
webmock (1.20.4)
|
35
|
+
addressable (>= 2.3.6)
|
36
|
+
crack (>= 0.3.2)
|
11
37
|
|
12
38
|
PLATFORMS
|
13
39
|
ruby
|
@@ -15,4 +41,11 @@ PLATFORMS
|
|
15
41
|
DEPENDENCIES
|
16
42
|
fast_gettext
|
17
43
|
gettext (>= 3.0.2)
|
44
|
+
rack-test
|
18
45
|
rake
|
46
|
+
rspec (~> 2.13.0)
|
47
|
+
rspec-core (~> 2.13.1)
|
48
|
+
rspec-expectations (~> 2.13.0)
|
49
|
+
rspec-mocks (~> 2.13.1)
|
50
|
+
simplecov
|
51
|
+
webmock
|
data/Rakefile
CHANGED
@@ -1,5 +1,37 @@
|
|
1
1
|
require 'bundler/setup'
|
2
|
+
require 'rake'
|
2
3
|
|
3
4
|
require_relative './lib/gettext-setup/gettext_setup.rb'
|
4
5
|
|
5
6
|
import 'lib/tasks/gettext.rake'
|
7
|
+
|
8
|
+
namespace :bundler do
|
9
|
+
task :setup do
|
10
|
+
require 'bundler/setup'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Update i18n POT translations"
|
15
|
+
task :"spec-regen" do
|
16
|
+
require 'rake'
|
17
|
+
GettextSetup.initialize(File.absolute_path(File.join('spec', 'fixtures', 'locales'), File.dirname(__FILE__)))
|
18
|
+
Dir.chdir('spec/fixtures')
|
19
|
+
Rake.application['gettext:pot'].invoke
|
20
|
+
# No use in running these without Transifex integration to actually translate
|
21
|
+
# strings.
|
22
|
+
# Rake.application['gettext:po'].invoke('de')
|
23
|
+
end
|
24
|
+
|
25
|
+
if defined?(RSpec::Core::RakeTask)
|
26
|
+
namespace :spec do
|
27
|
+
require 'rspec/core'
|
28
|
+
require 'rspec/core/rake_task'
|
29
|
+
puts 'running'
|
30
|
+
|
31
|
+
desc 'Run all specs.'
|
32
|
+
RSpec::Core::RakeTask.new(:all => :"bundler:setup") do |t|
|
33
|
+
puts "iterating: #{t}"
|
34
|
+
t.pattern = 'spec/**/*_spec.rb'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/gettext-setup.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "gettext-setup"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.2"
|
8
8
|
spec.authors = ["Puppet"]
|
9
9
|
spec.email = ["info@puppet.com"]
|
10
10
|
spec.description = "A gem to ease i18n"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
# This is the project-specific configuration file for setting up
|
3
|
+
# fast_gettext for your project.
|
4
|
+
gettext:
|
5
|
+
# This is used for the name of the .pot and .po files; they will be
|
6
|
+
# called <project_name>.pot?
|
7
|
+
project_name: 'sinatra-i18n'
|
8
|
+
# This is used in comments in the .pot and .po files to indicate what
|
9
|
+
# project the files belong to and should bea little more desctiptive than
|
10
|
+
# <project_name>
|
11
|
+
package_name: Sinatra i18n demo
|
12
|
+
# The locale that the default messages in the .pot file are in
|
13
|
+
default_locale: en
|
14
|
+
# The email used for sending bug reports.
|
15
|
+
bugs_address: docs@puppetlabs.com
|
16
|
+
# The holder of the copyright.
|
17
|
+
copyright_holder: Puppet Labs, LLC.
|
18
|
+
# Patterns for +Dir.glob+ used to find all files that might contain
|
19
|
+
# translatable content, relative to the project root directory
|
20
|
+
source_files:
|
21
|
+
- 'test_translation.rb'
|
22
|
+
- '../lib/**/*.rb'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# German translations for Sinatra i18n demo package.
|
2
|
+
# Copyright (C) 2016 Puppet Labs, LLC.
|
3
|
+
# This file is distributed under the same license as the Sinatra i18n demo package.
|
4
|
+
# Automatically generated, 2016.
|
5
|
+
#
|
6
|
+
msgid ""
|
7
|
+
msgstr ""
|
8
|
+
"Project-Id-Version: Sinatra i18n demo \n"
|
9
|
+
"Report-Msgid-Bugs-To: docs@puppetlabs.com\n"
|
10
|
+
"POT-Creation-Date: 2016-04-05 10:39-0700\n"
|
11
|
+
"PO-Revision-Date: 2016-02-26 18:21-0800\n"
|
12
|
+
"Last-Translator: Automatically generated\n"
|
13
|
+
"Language-Team: none\n"
|
14
|
+
"Language: de\n"
|
15
|
+
"MIME-Version: 1.0\n"
|
16
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
17
|
+
"Content-Transfer-Encoding: 8bit\n"
|
18
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
19
|
+
|
20
|
+
#: ../app.rb:14
|
21
|
+
msgid "Hello, world!"
|
22
|
+
msgstr "Hallo, Welt!"
|
23
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SOME DESCRIPTIVE TITLE.
|
2
|
+
# Copyright (C) 2016 Puppet Labs, LLC.
|
3
|
+
# This file is distributed under the same license as the Sinatra i18n demo package.
|
4
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2016.
|
5
|
+
#
|
6
|
+
#, fuzzy
|
7
|
+
msgid ""
|
8
|
+
msgstr ""
|
9
|
+
"Project-Id-Version: Sinatra i18n demo init-11-ga552a06\n"
|
10
|
+
"\n"
|
11
|
+
"Report-Msgid-Bugs-To: docs@puppetlabs.com\n"
|
12
|
+
"POT-Creation-Date: 2016-06-07 17:38-0500\n"
|
13
|
+
"PO-Revision-Date: 2016-06-07 17:38-0500\n"
|
14
|
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
15
|
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
16
|
+
"Language: \n"
|
17
|
+
"MIME-Version: 1.0\n"
|
18
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
19
|
+
"Content-Transfer-Encoding: 8bit\n"
|
20
|
+
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
21
|
+
|
22
|
+
#. GettextSetup.initialize(File::join(File::dirname(File::dirname(__FILE__)), 'fixtures'))
|
23
|
+
#: ../../lib/gettext_setup_spec.rb:25
|
24
|
+
msgid "Hello, world!"
|
25
|
+
msgstr ""
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "rspec/expectations"
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
|
4
|
+
describe GettextSetup do
|
5
|
+
before(:each) do
|
6
|
+
GettextSetup.initialize(File::join(File::dirname(File::dirname(__FILE__)), 'fixtures', 'locales'))
|
7
|
+
end
|
8
|
+
let(:config) do
|
9
|
+
GettextSetup.config
|
10
|
+
end
|
11
|
+
context 'initialize' do
|
12
|
+
it "sets up correctly" do
|
13
|
+
# GettextSetup.initialize(File::join(File::dirname(File::dirname(__FILE__)), 'fixtures'))
|
14
|
+
GettextSetup.locales_path.should =~ /\/spec\/fixtures/
|
15
|
+
config['project_name'].should == 'sinatra-i18n'
|
16
|
+
config['package_name'].should == 'Sinatra i18n demo'
|
17
|
+
config['default_locale'].should == 'en'
|
18
|
+
respond_to?(:_).should == true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
context 'negotiate_locale' do
|
22
|
+
it "negotiates correctly" do
|
23
|
+
FastGettext.locale = GettextSetup.negotiate_locale('de')
|
24
|
+
FastGettext.locale.should == 'de'
|
25
|
+
_('Hello, world!').should == 'Hallo, Welt!'
|
26
|
+
end
|
27
|
+
it "chooses the default locale when no match is found" do
|
28
|
+
GettextSetup.negotiate_locale('no-match').should == config['default_locale']
|
29
|
+
end
|
30
|
+
it "chooses the language with the highest q value" do
|
31
|
+
GettextSetup.negotiate_locale('en;q=1, de;q=2').should == 'de'
|
32
|
+
GettextSetup.negotiate_locale('en;q=1, de;q=0').should == 'en'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
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.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,6 +55,11 @@ files:
|
|
55
55
|
- lib/gettext-setup/gettext_setup.rb
|
56
56
|
- lib/tasks/gettext.rake
|
57
57
|
- locales/config-sample.yaml
|
58
|
+
- spec/fixtures/locales/config.yaml
|
59
|
+
- spec/fixtures/locales/de/sinatra-i18n.po
|
60
|
+
- spec/fixtures/locales/sinatra-i18n.pot
|
61
|
+
- spec/lib/gettext_setup_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
58
63
|
homepage: https://github.com/puppetlabs/gettext-setup-gem
|
59
64
|
licenses:
|
60
65
|
- ASL2
|
@@ -75,9 +80,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
80
|
version: '0'
|
76
81
|
requirements: []
|
77
82
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.4.
|
83
|
+
rubygems_version: 2.4.5
|
79
84
|
signing_key:
|
80
85
|
specification_version: 4
|
81
86
|
summary: A gem to ease internationalization with fast_gettext
|
82
|
-
test_files:
|
87
|
+
test_files:
|
88
|
+
- spec/fixtures/locales/config.yaml
|
89
|
+
- spec/fixtures/locales/de/sinatra-i18n.po
|
90
|
+
- spec/fixtures/locales/sinatra-i18n.pot
|
91
|
+
- spec/lib/gettext_setup_spec.rb
|
92
|
+
- spec/spec_helper.rb
|
83
93
|
has_rdoc:
|