Hello community,
here is the log from the commit of package rubygem-gettext-setup for
openSUSE:Factory checked in at 2017-09-26 21:13:48
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-gettext-setup (Old)
and /work/SRC/openSUSE:Factory/.rubygem-gettext-setup.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-gettext-setup"
Tue Sep 26 21:13:48 2017 rev:11 rq:520438 version:0.28
Changes:
--------
---
/work/SRC/openSUSE:Factory/rubygem-gettext-setup/rubygem-gettext-setup.changes
2017-06-08 15:02:04.530878128 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-gettext-setup.new/rubygem-gettext-setup.changes
2017-09-26 21:14:35.029035346 +0200
@@ -1,0 +2,12 @@
+Sun Sep 3 09:03:19 UTC 2017 - [email protected]
+
+- updated to version 0.28
+ no changelog found
+
+-------------------------------------------------------------------
+Thu Aug 3 19:17:06 UTC 2017 - [email protected]
+
+- updated to version 0.26
+ no changelog found
+
+-------------------------------------------------------------------
Old:
----
gettext-setup-0.25.gem
New:
----
gettext-setup-0.28.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-gettext-setup.spec ++++++
--- /var/tmp/diff_new_pack.msElKM/_old 2017-09-26 21:14:36.580817184 +0200
+++ /var/tmp/diff_new_pack.msElKM/_new 2017-09-26 21:14:36.584816622 +0200
@@ -24,7 +24,7 @@
#
Name: rubygem-gettext-setup
-Version: 0.25
+Version: 0.28
Release: 0
%define mod_name gettext-setup
%define mod_full_name %{mod_name}-%{version}
++++++ gettext-setup-0.25.gem -> gettext-setup-0.28.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2017-05-30 20:09:42.000000000 +0200
+++ new/README.md 2017-09-01 23:10:50.000000000 +0200
@@ -99,3 +99,14 @@
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.
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.
+
+## Merge Pot files rake task
+
+The rake task that merges .pot files is present for the internationalisation
of a module. This task uses 'msgcat', which is only natively present on OSes
that are GNU based. For running this task locally on another OS you will need
to download the gettext pkg and install it locally:
+https://pkgs.org/download/gettext
+
+This task will run within the gettext setup locales_path provided by
GettextSetup. The result will be a merged pot file created from all pot files
kept in this location.
+
+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.
+
+Please note: Since the default merged file name is project_name.pot, it will
override anything of that name within the locales directory.
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/generate_metadata_pot.rb
new/lib/generate_metadata_pot.rb
--- old/lib/generate_metadata_pot.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/generate_metadata_pot.rb 2017-09-01 23:10:50.000000000 +0200
@@ -0,0 +1 @@
+require 'metadata_pot/metadata_pot'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/gettext-setup/gettext_setup.rb
new/lib/gettext-setup/gettext_setup.rb
--- old/lib/gettext-setup/gettext_setup.rb 2017-05-30 20:09:42.000000000
+0200
+++ new/lib/gettext-setup/gettext_setup.rb 2017-09-01 23:10:50.000000000
+0200
@@ -98,7 +98,7 @@
explicit = Dir.glob(File.absolute_path('*/*.po', locales_path)).map do |x|
File.basename(File.dirname(x))
end
- (explicit + [default_locale]).uniq
+ ([default_locale] + explicit).uniq
end
# Given an HTTP Accept-Language header return the locale with the highest
@@ -112,6 +112,10 @@
available_locales = accept_header.split(',').map do |locale|
pair = locale.strip.split(';q=')
pair << '1.0' unless pair.size == 2
+ # Ignore everything but the language itself; that means that we treat
+ # 'de' and 'de-DE' identical, and would use the 'de' message catalog
+ # for both.
+ pair[0] = pair[0].split('-')[0]
pair[0] = FastGettext.default_locale if pair[0] == '*'
pair
end.sort_by do |(_, qvalue)|
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/gettext-setup/pot.rb new/lib/gettext-setup/pot.rb
--- old/lib/gettext-setup/pot.rb 2017-05-30 20:09:42.000000000 +0200
+++ new/lib/gettext-setup/pot.rb 2017-09-01 23:10:50.000000000 +0200
@@ -50,9 +50,14 @@
return true
end
- def self.generate_new_pot(locales_path = GettextSetup.locales_path, path =
nil)
+ # @param [:locales_path] opts
+ # The directory for the locales.
+ # @param [:target_path] opts
+ # The output path for the new POT file.
+ def self.generate_new_pot(opts = {})
+ locales_path = opts[:locales_path] || GettextSetup.locales_path
GettextSetup.initialize(locales_path)
- path ||= pot_file_path
+ target_path = opts[:target_path] || pot_file_path
config = GettextSetup.config
package_name = config['package_name']
bugs_address = config['bugs_address']
@@ -60,7 +65,7 @@
# Done this way to allow the user to enter an empty string in the config.
comments_tag = config.key?('comments_tag') ? config['comments_tag'] :
'TRANSLATORS'
version = `git describe`
- system("rxgettext -o #{path} --no-wrap --sort-by-file " \
+ system("rxgettext -o #{target_path} --no-wrap --sort-by-file " \
"--add-comments#{comments_tag.to_s == '' ? '' : '=' +
comments_tag} --msgid-bugs-address '#{bugs_address}' " \
"--package-name '#{package_name}' " \
"--package-version '#{version}' " \
@@ -72,11 +77,10 @@
def self.generate_new_po(language, locales_path =
GettextSetup.locales_path,
pot_file = nil, po_file = nil)
GettextSetup.initialize(locales_path)
+ language ||= ENV['LANGUAGE']
pot_file ||= GettextSetup::Pot.pot_file_path
po_file ||= GettextSetup::Pot.po_file_path(language)
- language ||= ENV['LANGUAGE']
-
# Let's do some pre-verification of the environment.
if language.nil?
puts "You need to specify the language to add. Either 'LANGUAGE=eo
rake gettext:po' or 'rake gettext:po[LANGUAGE]'"
@@ -117,13 +121,13 @@
if !File.exist? path
puts 'No existing POT file, generating new'
- result = GettextSetup::Pot.generate_new_pot(locales_path, path)
+ result = GettextSetup::Pot.generate_new_pot(locales_path:
locales_path, target_path: path)
puts "POT file #{path} has been generated" if result
result
else
old_pot = path + '.old'
File.rename(path, old_pot)
- result = GettextSetup::Pot.generate_new_pot(locales_path, path)
+ result = GettextSetup::Pot.generate_new_pot(locales_path:
locales_path, target_path: path)
if !result
puts 'POT creation failed'
result
@@ -138,5 +142,34 @@
end
end
end
+
+ # @param [:locales_path] opts
+ # The directory for the locales.
+ def self.merge(opts = {})
+ locales_path = opts[:locales_path] || GettextSetup.locales_path
+ GettextSetup.initialize(locales_path)
+ target_filename = GettextSetup.config['project_name'] + '.pot'
+ target_path = File.expand_path(target_filename, locales_path)
+ oldpot_dir = File.expand_path('oldpot', locales_path)
+ oldpot_path = File.expand_path("oldpot/old_#{target_filename}",
locales_path)
+
+ if File.exist? target_path
+ FileUtils.mkdir_p(oldpot_dir)
+ begin
+ FileUtils.mv(target_path, oldpot_path)
+ rescue
+ raise "There was a problem creating .pot backup #{oldpot_path},
merge failed."
+ end
+ puts "Warning - #{target_filename} already exists and will be
relocated to oldpot/old_#{target_filename}."
+ end
+
+ locales_glob = Dir.glob("#{locales_path}/*.pot")
+ cmd = "msgcat #{locales_glob.join(' ')} -o #{target_path}"
+ _, _, _, wait = Open3.popen3(cmd)
+ exitstatus = wait.value
+ raise 'PO files failed to merge' unless exitstatus.success?
+ puts "PO files have been successfully merged, #{target_filename} has
been created."
+ exitstatus
+ end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/tasks/gettext.rake new/lib/tasks/gettext.rake
--- old/lib/tasks/gettext.rake 2017-05-30 20:09:42.000000000 +0200
+++ new/lib/tasks/gettext.rake 2017-09-01 23:10:50.000000000 +0200
@@ -18,11 +18,12 @@
end
desc 'Generate POT file'
- task :pot do
+ task :pot, [:target_path] do |_, args|
begin
- result = GettextSetup::Pot.generate_new_pot
- if result
- puts "POT file #{GettextSetup::Pot.pot_file_path} has been generated"
+ target_path = args.target_path
+ if GettextSetup::Pot.generate_new_pot(target_path: target_path)
+ target_path = GettextSetup::Pot.pot_file_path if target_path.nil?
+ puts "POT file #{target_path} has been generated"
else
exit 1
end
@@ -52,6 +53,16 @@
exit 1 unless result
rescue GettextSetup::NoConfigFoundError => e
puts e.message
+ end
+ end
+
+ desc 'Merge all Pot files within locales folder'
+ task :merge do
+ begin
+ result = GettextSetup::Pot.merge
+ exit 1 unless result
+ rescue GettextSetup::NoConfigFoundError => e
+ puts e.message
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/locales/config-sample.yaml
new/locales/config-sample.yaml
--- old/locales/config-sample.yaml 2017-05-30 20:09:42.000000000 +0200
+++ new/locales/config-sample.yaml 2017-09-01 23:10:50.000000000 +0200
@@ -6,7 +6,7 @@
# called <project_name>.pot?
project_name: 'sinatra-i18n'
# This is used in comments in the .pot and .po files to indicate what
- # project the files belong to and should bea little more desctiptive than
+ # project the files belong to and should bea little more descriptive than
# <project_name>
package_name: Sinatra i18n demo
# The locale that the default messages in the .pot file are in
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2017-05-30 20:09:42.000000000 +0200
+++ new/metadata 2017-09-01 23:10:50.000000000 +0200
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: gettext-setup
version: !ruby/object:Gem::Version
- version: '0.25'
+ version: '0.28'
platform: ruby
authors:
- Puppet
autorequire:
bindir: bin
cert_chain: []
-date: 2017-05-30 00:00:00.000000000 Z
+date: 2017-09-01 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: fast_gettext
@@ -81,20 +81,6 @@
- !ruby/object:Gem::Version
version: '0'
- !ruby/object:Gem::Dependency
- name: rack-test
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: '0'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: '0'
-- !ruby/object:Gem::Dependency
name: rspec
requirement: !ruby/object:Gem::Requirement
requirements:
@@ -165,20 +151,6 @@
- !ruby/object:Gem::Version
version: '0'
- !ruby/object:Gem::Dependency
- name: webmock
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: '0'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: '0'
-- !ruby/object:Gem::Dependency
name: rubocop
requirement: !ruby/object:Gem::Requirement
requirements:
@@ -201,6 +173,7 @@
files:
- LICENSE
- README.md
+- lib/generate_metadata_pot.rb
- lib/gettext-setup.rb
- lib/gettext-setup/gettext_setup.rb
- lib/gettext-setup/metadata_pot.rb
@@ -215,6 +188,7 @@
- spec/fixtures/locales/config.yaml
- spec/fixtures/locales/de/sinatra-i18n.po
- spec/fixtures/locales/sinatra-i18n.pot
+- spec/fixtures/merge_locales/config.yaml
- spec/fixtures/spec_locales/config.yaml
- spec/fixtures/spec_locales/sinatra-i18n.pot
- spec/fixtures/string_changes/add.pot
@@ -250,7 +224,7 @@
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.2.2
+rubygems_version: 2.5.2
signing_key:
specification_version: 4
summary: A gem to ease internationalization with fast_gettext
@@ -262,6 +236,7 @@
- spec/fixtures/locales/config.yaml
- spec/fixtures/locales/de/sinatra-i18n.po
- spec/fixtures/locales/sinatra-i18n.pot
+- spec/fixtures/merge_locales/config.yaml
- spec/fixtures/spec_locales/config.yaml
- spec/fixtures/spec_locales/sinatra-i18n.pot
- spec/fixtures/string_changes/add.pot
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/fixtures/merge_locales/config.yaml
new/spec/fixtures/merge_locales/config.yaml
--- old/spec/fixtures/merge_locales/config.yaml 1970-01-01 01:00:00.000000000
+0100
+++ new/spec/fixtures/merge_locales/config.yaml 2017-09-01 23:10:50.000000000
+0200
@@ -0,0 +1,21 @@
+---
+# This is the project-specific configuration file for setting up
+# fast_gettext for your project.
+gettext:
+ # This is used for the name of the .pot and .po files; they will be
+ # called <project_name>.pot?
+ project_name: 'merge_locales'
+ # This is used in comments in the .pot and .po files to indicate what
+ # project the files belong to and should bea little more desctiptive than
+ # <project_name>
+ package_name: Merge locales
+ # The locale that the default messages in the .pot file are in
+ default_locale: en
+ # The email used for sending bug reports.
+ bugs_address: [email protected]
+ # The holder of the copyright.
+ copyright_holder: Puppet, LLC.
+ # Patterns for +Dir.glob+ used to find all files that might contain
+ # translatable content, relative to the project root directory
+ source_files:
+ - 'spec/fixtures/merge_locales/*.rb'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/lib/gettext-setup/gettext_setup_spec.rb
new/spec/lib/gettext-setup/gettext_setup_spec.rb
--- old/spec/lib/gettext-setup/gettext_setup_spec.rb 2017-05-30
20:09:42.000000000 +0200
+++ new/spec/lib/gettext-setup/gettext_setup_spec.rb 2017-09-01
23:10:50.000000000 +0200
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
require 'rspec/expectations'
require_relative '../../spec_helper'
@@ -35,6 +36,10 @@
expect(GettextSetup.negotiate_locale('en;q=1, de;q=2')).to eq('de')
expect(GettextSetup.negotiate_locale('en;q=1, de;q=0')).to eq('en')
end
+ it 'ignores country variant' do
+ expect(GettextSetup.negotiate_locale('en;q=1, de-DE;q=2')).to eq('de')
+ expect(GettextSetup.negotiate_locale('en;q=1, de-DE;q=0')).to eq('en')
+ end
it 'chooses the first value when q values are equal' do
expect(GettextSetup.negotiate_locale('de;q=1, en;q=1')).to eq('de')
end
@@ -65,11 +70,11 @@
expect(GettextSetup.candidate_locales).to include('en')
GettextSetup.clear
begin
- old_locale = ENV['LANG']
- ENV['LANG'] = 'de_DE'
+ old_locale = Locale.current
+ Locale.current = 'de_DE'
expect(GettextSetup.candidate_locales).to eq('de_DE,de,en')
ensure
- ENV['LANG'] = old_locale
+ Locale.current = old_locale
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/lib/gettext-setup/pot_spec.rb
new/spec/lib/gettext-setup/pot_spec.rb
--- old/spec/lib/gettext-setup/pot_spec.rb 2017-05-30 20:09:42.000000000
+0200
+++ new/spec/lib/gettext-setup/pot_spec.rb 2017-09-01 23:10:50.000000000
+0200
@@ -18,6 +18,10 @@
File.join(File.dirname(__FILE__), '../../fixtures/locales')
end
+ def merge_locales_path
+ File.join(File.dirname(__FILE__), '../../fixtures/merge_locales')
+ end
+
describe 'string_changes?', if: msgcmp_present? do
old_pot = File.absolute_path('../../fixtures/string_changes/old.pot',
File.dirname(__FILE__))
@@ -45,12 +49,12 @@
context 'generate_new_pot' do
it "fails when GettextSetup can't find a config.yaml" do
path = File.join(Dir.mktmpdir, 'empty.pot')
- expect { GettextSetup::Pot.generate_new_pot(Dir.mktmpdir, path) }.to
raise_error(NoConfigFoundError)
+ expect { GettextSetup::Pot.generate_new_pot(locales_path: Dir.mktmpdir,
target_path: path) }.to raise_error(NoConfigFoundError)
end
it 'builds a POT file' do
path = File.join(Dir.mktmpdir, 'new.pot')
expect do
- GettextSetup::Pot.generate_new_pot(fixture_locales_path, path)
+ GettextSetup::Pot.generate_new_pot(locales_path: fixture_locales_path,
target_path: path)
end.to output('').to_stdout # STDOUT is determined in `update_pot`.
contents = File.read(path)
expect(contents).to match(/Fixture locales/)
@@ -144,4 +148,59 @@
expect(new_contents).to eq(contents)
end
end
+ context 'Merge pot files' do
+ # setup
+ before :all do
+ { 'ruby' => 'ruby.pot', 'puppet' => 'puppet.pot', 'metadata' =>
'metadata.pot' }.each do |pot_type, pot_name|
+ File.open(File.join(merge_locales_path, pot_name), 'w') do |file|
+ file.write <<-EOF
+ # Copyright (C) 2017 Puppet, Inc.
+ # This file is distributed under the same license as the puppetlabs-mysql
package.
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2017.
+ #
+ #, fuzzy
+ msgid ""
+ msgstr ""
+ "Project-Id-Version: puppetlabs-mysql 3.11.0-30-g4cc0bbf\\n"
+ "Report-Msgid-Bugs-To: [email protected]\\n"
+ "POT-Creation-Date: 2017-08-26 21:30+0100\\n"
+ "PO-Revision-Date: 2017-08-26 21:30+0100\\n"
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
+ "Language-Team: LANGUAGE <[email protected]>\\n"
+ "MIME-Version: 1.0\\n"
+ "Content-Type: text/plain; charset=UTF-8\\n"
+ "Content-Transfer-Encoding: 8bit\\n"
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"
+
+ #: ../lib/puppet/parser/functions/mysql_strip_hash.rb:11
+ msgid "this is a #{pot_type} string"
+ msgstr ""
+ EOF
+ end
+ end
+ end
+ it 'merges pot files' do
+ expect do
+ GettextSetup::Pot.merge(locales_path: merge_locales_path)
+ end.to output(%r{PO files have been successfully merged}).to_stdout
+ contents = File.read(File.join(merge_locales_path,
GettextSetup.config['project_name'] + '.pot'))
+ expect(contents).to match(%r{.*\"this is a metadata string\".*})
+ expect(contents).to match(%r{.*\"this is a puppet string\".*})
+ expect(contents).to match(%r{.*\"this is a ruby string\".*})
+ end
+
+ it 'creates an oldpot file if one already exists' do
+ expect do
+ GettextSetup::Pot.merge(locales_path: merge_locales_path)
+ end.to output("Warning - merge_locales.pot already exists and will be
relocated to oldpot/old_merge_locales.pot.\nPO files have been successfully
merged, merge_locales.pot has been created.\n").to_stdout
+ file = File.expand_path('oldpot/old_merge_locales.pot',
merge_locales_path)
+ expect(File.exist?(file)).to be true
+ end
+
+ # cleanup
+ after :all do
+ FileUtils.rm(Dir.glob("#{merge_locales_path}/*.pot"))
+ FileUtils.rm_rf("#{merge_locales_path}/oldpot")
+ end
+ end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/lib/tasks/gettext_rake_spec.rb
new/spec/lib/tasks/gettext_rake_spec.rb
--- old/spec/lib/tasks/gettext_rake_spec.rb 2017-05-30 20:09:42.000000000
+0200
+++ new/spec/lib/tasks/gettext_rake_spec.rb 2017-09-01 23:10:50.000000000
+0200
@@ -9,6 +9,7 @@
tmp_locales = File.expand_path('../../fixtures/tmp_locales',
File.dirname(__FILE__))
fixture_locales = File.expand_path('../../fixtures/fixture_locales',
File.dirname(__FILE__))
tmp_pot_path = File.expand_path('sinatra-i18n.pot', tmp_locales)
+ merge_locales = File.expand_path('../../fixtures/merge_locales',
File.dirname(__FILE__))
before :each do
FileUtils.rm_r(tmp_locales, force: true)
@@ -40,6 +41,14 @@
end.to raise_error(SystemExit)
end
end
+ context Rake::Task['gettext:pot'] do
+ it 'outputs correctly, when passing a filename' do
+ expect do
+ GettextSetup.initialize(tmp_locales)
+ subject.invoke(File.expand_path('bill.pot', tmp_locales))
+ end.to output(/POT file .+\/spec\/fixtures\/tmp_locales\/bill.pot has
been generated/).to_stdout
+ end
+ end
context Rake::Task['gettext:metadata_pot'] do
it 'outputs correctly' do
expect do
@@ -99,5 +108,21 @@
subject.invoke
end.to raise_error(SystemExit)
end
+ end
+
+ context Rake::Task['gettext:merge'] do
+ it 'outputs correctly' do
+ expect do
+ GettextSetup.initialize(merge_locales)
+ subject.invoke
+ end.to output(/PO files have been successfully merged/).to_stdout
+ end
+ it 'exits 1 on error' do
+ allow(GettextSetup::Pot).to receive(:merge).and_return(false)
+ expect do
+ GettextSetup.initialize(merge_locales)
+ subject.invoke
+ end.to raise_error(SystemExit)
+ end
end
end