Hello community,
here is the log from the commit of package rubygem-gettext-setup for
openSUSE:Factory checked in at 2019-06-18 14:57:41
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-gettext-setup (Old)
and /work/SRC/openSUSE:Factory/.rubygem-gettext-setup.new.4811 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-gettext-setup"
Tue Jun 18 14:57:41 2019 rev:12 rq:709790 version:0.30
Changes:
--------
---
/work/SRC/openSUSE:Factory/rubygem-gettext-setup/rubygem-gettext-setup.changes
2017-09-26 21:14:35.029035346 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-gettext-setup.new.4811/rubygem-gettext-setup.changes
2019-06-18 14:57:51.405348235 +0200
@@ -1,0 +2,12 @@
+Tue Feb 13 05:29:45 UTC 2018 - [email protected]
+
+- updated to version 0.30
+ no changelog found
+
+-------------------------------------------------------------------
+Sun Dec 3 19:17:43 UTC 2017 - [email protected]
+
+- updated to version 0.29
+ no changelog found
+
+-------------------------------------------------------------------
Old:
----
gettext-setup-0.28.gem
New:
----
gettext-setup-0.30.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-gettext-setup.spec ++++++
--- /var/tmp/diff_new_pack.3Ci7sm/_old 2019-06-18 14:57:53.129347204 +0200
+++ /var/tmp/diff_new_pack.3Ci7sm/_new 2019-06-18 14:57:53.177347175 +0200
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-gettext-setup
#
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -24,7 +24,7 @@
#
Name: rubygem-gettext-setup
-Version: 0.28
+Version: 0.30
Release: 0
%define mod_name gettext-setup
%define mod_full_name %{mod_name}-%{version}
@@ -33,7 +33,7 @@
BuildRequires: %{rubygem gem2rpm}
BuildRequires: ruby-macros >= 5
Url: https://github.com/puppetlabs/gettext-setup-gem
-Source: http://rubygems.org/gems/%{mod_full_name}.gem
+Source: https://rubygems.org/gems/%{mod_full_name}.gem
Source1: gem2rpm.yml
Summary: A gem to ease internationalization with fast_gettext
License: Apache-2.0
++++++ gettext-setup-0.28.gem -> gettext-setup-0.30.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2017-09-01 23:10:50.000000000 +0200
+++ new/README.md 2018-02-12 19:21:38.000000000 +0100
@@ -1,6 +1,6 @@
# gettext-setup gem
-This is a simple gem to set up i18n for Ruby projects (including
[Sinatra](www.sinatrarb.com/) web apps) using gettext and fast gettext.
+This is a simple gem to set up i18n for Ruby projects (including
[Sinatra](http://www.sinatrarb.com/) web apps) using gettext and fast gettext.
This project sets the default locale to English. If the user has set a
different locale in their browser preferences, and we support the user's
preferred locale, strings and data formatting will be customized for that
locale.
@@ -16,34 +16,34 @@
## Setup for your project
-These are the poignant bits of this example that you need to replicate in
-your project:
+These are the poignant bits of this example that you need to replicate in your
project:
1. Add `gem 'gettext-setup'` to your `Gemfile`.
-1. Copy `locales/config-sample.yaml` to your project and put it into a
+2. Copy `locales/config-sample.yaml` to your project and put it into a
`locales` directory as `config.yaml`.
-1. Edit `locales/config.yaml` and make the necessary changes for your
- project
-1. Add these three lines to your `Rakefile`, ensuring the `locales`
- directory is found by the last line:
-```
- spec = Gem::Specification.find_by_name 'gettext-setup'
- load "#{spec.gem_dir}/lib/tasks/gettext.rake"
- GettextSetup.initialize(File.absolute_path('locales',
File.dirname(__FILE__)))
-```
-1. Add these lines at the start of your app (`app.rb` for server-side, the
executable binary for CLI applications):
- `require 'gettext-setup'`
- `GettextSetup.initialize(File.absolute_path('locales',
File.dirname(__FILE__)))`
- (Note that the second line may require modification to find the `locales`
directory.
-1. For client-side applications, add this line:
- `GettextSetup.negotiate_locale!(GettextSetup.candidate_locales)`
-1. For server-side applications, add these lines:
-```
- before do
- GettextSetup.negotiate_locale!(env["HTTP_ACCEPT_LANGUAGE"])
- end
-```
-
+3. Edit `locales/config.yaml` and make the necessary changes for your project
+4. Add these three lines to your `Rakefile`, ensuring the `locales` directory
is found by the last line:
+ ```ruby
+ spec = Gem::Specification.find_by_name 'gettext-setup'
+ load "#{spec.gem_dir}/lib/tasks/gettext.rake"
+ GettextSetup.initialize(File.absolute_path('locales',
File.dirname(__FILE__)))
+ ```
+5. Add these lines at the start of your app (`app.rb` for server-side, the
executable binary for CLI applications):
+ ```ruby
+ require 'gettext-setup'
+ GettextSetup.initialize(File.absolute_path('locales',
File.dirname(__FILE__)))
+ ```
+ Note that the second line may require modification to find the `locales`
directory.
+6. For client-side applications, add this line:
+ ```ruby
+ GettextSetup.negotiate_locale!(GettextSetup.candidate_locales)
+ ```
+7. For server-side applications, add these lines:
+ ```ruby
+ before do
+ GettextSetup.negotiate_locale!(env["HTTP_ACCEPT_LANGUAGE"])
+ end
+ ```
## Writing translatable code
### Use full sentences
@@ -67,13 +67,16 @@
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.
-Plurals are selected from the PO file by index. Here's an example of how a
-pluralized string is handled in a PO file:
+Plurals are selected from the PO file by index.
+
+Here's an example of how a pluralized string is handled in a PO file:
-`msgid "%{count} file"
-`msgid_plural "%{count} files"
-`msgstr[0] "%{count} Dateien"
-`msgstr[1] "%{count} Datei"
+```
+msgid "%{count} file"
+msgid_plural "%{count} files"
+msgstr[0] "%{count} Dateien"
+msgstr[1] "%{count} Datei"
+```
The `msgid` is the singular version of the English source string that's pulled
in to the POT file and PO from the code file.
@@ -102,11 +105,11 @@
## 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:
+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.
+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/gettext-setup/gettext_setup.rb
new/lib/gettext-setup/gettext_setup.rb
--- old/lib/gettext-setup/gettext_setup.rb 2017-09-01 23:10:50.000000000
+0200
+++ new/lib/gettext-setup/gettext_setup.rb 2018-02-12 19:21:38.000000000
+0100
@@ -1,5 +1,3 @@
-# -*- encoding: utf-8 -*-
-
require 'fast_gettext'
require 'yaml'
require 'locale'
@@ -13,7 +11,6 @@
@config = nil
@translation_repositories = {}
- FastGettext.default_available_locales = []
# `locales_path` should include:
# - config.yaml
@@ -23,11 +20,7 @@
# valid `options` fields:
# :file_format - one of the supported backends for fast_gettext (e.g. :po,
:mo, :yaml, etc.)
def self.initialize(locales_path = 'locales', options = {})
- config_path = File.absolute_path('config.yaml', locales_path)
- File.exist?(config_path) || raise(NoConfigFoundError, config_path)
-
- @config = YAML.load_file(config_path)['gettext']
- @locales_path = locales_path
+ GettextSetup.initialize_config(locales_path)
# Make the translation methods available everywhere
Object.send(:include, FastGettext::Translation)
@@ -42,13 +35,27 @@
FastGettext.add_text_domain('master_domain', type: :chain, chain:
@translation_repositories.values)
FastGettext.default_text_domain = 'master_domain'
- # Likewise, be explicit in our default language choice.
+ # Likewise, be explicit in our default language choice. Available locales
+ # must be set prior to setting the default_locale since default locale must
+ # available.
+ FastGettext.default_available_locales =
(FastGettext.default_available_locales || []) | locales
FastGettext.default_locale = default_locale
- FastGettext.default_available_locales =
FastGettext.default_available_locales | locales
Locale.set_default(default_locale)
end
+ # Sets up the config class variables.
+ #
+ # Call this without calling initialize when you only need to deal with the
+ # translation files and you don't need runtime translation.
+ def self.initialize_config(locales_path = 'locales')
+ config_path = File.absolute_path('config.yaml', locales_path)
+ File.exist?(config_path) || raise(NoConfigFoundError, config_path)
+
+ @config = YAML.load_file(config_path)['gettext']
+ @locales_path = locales_path
+ end
+
def self.config?
raise NoConfigFoundError, File.join(locales_path, 'config.yaml') unless
@config
@config
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/gettext-setup/metadata_pot.rb
new/lib/gettext-setup/metadata_pot.rb
--- old/lib/gettext-setup/metadata_pot.rb 2017-09-01 23:10:50.000000000
+0200
+++ new/lib/gettext-setup/metadata_pot.rb 2018-02-12 19:21:38.000000000
+0100
@@ -1,5 +1,3 @@
-# -*- encoding: utf-8 -*-
-
require 'erb'
require 'json'
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-09-01 23:10:50.000000000 +0200
+++ new/lib/gettext-setup/pot.rb 2018-02-12 19:21:38.000000000 +0100
@@ -1,7 +1,6 @@
-# -*- encoding: utf-8 -*-
-
require 'open3'
require 'English'
+require 'tempfile'
module GettextSetup
module Pot
@@ -54,10 +53,18 @@
# The directory for the locales.
# @param [:target_path] opts
# The output path for the new POT file.
+ # @param [:header_only] opts
+ # Set to true to create a .pot file with only a header
def self.generate_new_pot(opts = {})
locales_path = opts[:locales_path] || GettextSetup.locales_path
- GettextSetup.initialize(locales_path)
+ GettextSetup.initialize_config(locales_path)
target_path = opts[:target_path] || pot_file_path
+ input_files = if opts[:header_only]
+ tmpfile = Tempfile.new('gettext-setup.tmp')
+ tmpfile.path
+ else
+ files_to_translate.join(' ')
+ end
config = GettextSetup.config
package_name = config['package_name']
bugs_address = config['bugs_address']
@@ -69,14 +76,15 @@
"--add-comments#{comments_tag.to_s == '' ? '' : '=' +
comments_tag} --msgid-bugs-address '#{bugs_address}' " \
"--package-name '#{package_name}' " \
"--package-version '#{version}' " \
- "--copyright-holder='#{copyright_holder}'
--copyright-year=#{Time.now.year} " +
- files_to_translate.join(' '))
+ "--copyright-holder='#{copyright_holder}'
--copyright-year=#{Time.now.year} " \
+ "#{input_files}")
+ tmpfile.unlink if tmpfile
$CHILD_STATUS.success?
end
def self.generate_new_po(language, locales_path =
GettextSetup.locales_path,
pot_file = nil, po_file = nil)
- GettextSetup.initialize(locales_path)
+ GettextSetup.initialize_config(locales_path)
language ||= ENV['LANGUAGE']
pot_file ||= GettextSetup::Pot.pot_file_path
po_file ||= GettextSetup::Pot.po_file_path(language)
@@ -116,7 +124,7 @@
end
def self.update_pot(locales_path = GettextSetup.locales_path, path = nil)
- GettextSetup.initialize(locales_path)
+ GettextSetup.initialize_config(locales_path)
path ||= pot_file_path
if !File.exist? path
@@ -147,7 +155,7 @@
# The directory for the locales.
def self.merge(opts = {})
locales_path = opts[:locales_path] || GettextSetup.locales_path
- GettextSetup.initialize(locales_path)
+ GettextSetup.initialize_config(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)
@@ -156,9 +164,9 @@
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."
+ FileUtils.cp(target_path, oldpot_path)
+ rescue Errno::ENOENT => e
+ raise "There was a problem creating .pot backup #{oldpot_path},
merge failed: #{e.message}"
end
puts "Warning - #{target_filename} already exists and will be
relocated to oldpot/old_#{target_filename}."
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-09-01 23:10:50.000000000 +0200
+++ new/lib/tasks/gettext.rake 2018-02-12 19:21:38.000000000 +0100
@@ -1,5 +1,3 @@
-# -*- encoding: utf-8 -*-
-
require_relative '../gettext-setup/gettext_setup'
require_relative '../gettext-setup/pot'
require_relative '../gettext-setup/metadata_pot'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2017-09-01 23:10:50.000000000 +0200
+++ new/metadata 2018-02-12 19:21:38.000000000 +0100
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: gettext-setup
version: !ruby/object:Gem::Version
- version: '0.28'
+ version: '0.30'
platform: ruby
authors:
- Puppet
autorequire:
bindir: bin
cert_chain: []
-date: 2017-09-01 00:00:00.000000000 Z
+date: 2018-02-12 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: fast_gettext
@@ -137,7 +137,7 @@
- !ruby/object:Gem::Version
version: '3.1'
- !ruby/object:Gem::Dependency
- name: simplecov
+ name: rubocop
requirement: !ruby/object:Gem::Requirement
requirements:
- - ">="
@@ -151,7 +151,7 @@
- !ruby/object:Gem::Version
version: '0'
- !ruby/object:Gem::Dependency
- name: rubocop
+ name: simplecov
requirement: !ruby/object:Gem::Requirement
requirements:
- - ">="
@@ -224,7 +224,7 @@
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.5.2
+rubygems_version: 2.5.1
signing_key:
specification_version: 4
summary: A gem to ease internationalization with fast_gettext
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-09-01
23:10:50.000000000 +0200
+++ new/spec/lib/gettext-setup/gettext_setup_spec.rb 2018-02-12
19:21:38.000000000 +0100
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
require 'rspec/expectations'
require_relative '../../spec_helper'
@@ -11,6 +10,15 @@
before(:each) do
GettextSetup.initialize(locales_path)
end
+ after(:each) do
+ FastGettext.default_text_domain = nil
+ FastGettext.default_available_locales = nil
+ FastGettext.default_locale = nil
+
+ FastGettext.text_domain = nil
+ FastGettext.available_locales = nil
+ FastGettext.locale = nil
+ end
let(:config) do
GettextSetup.config
end
@@ -80,7 +88,7 @@
end
context 'multiple locales' do
# locales/ loads the de locale and fixture_locales/ loads the jp locale
- before(:all) do
+ before(:each) do
GettextSetup.initialize(fixture_locales_path)
end
it 'can aggregate locales across projects' do
@@ -96,7 +104,7 @@
end
end
context 'translation repository chain' do
- before(:all) do
+ before(:each) do
GettextSetup.initialize(fixture_locales_path)
end
it 'chain is not nil' do
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-09-01 23:10:50.000000000
+0200
+++ new/spec/lib/gettext-setup/pot_spec.rb 2018-02-12 19:21:38.000000000
+0100
@@ -62,6 +62,17 @@
expect(contents).to match(/Puppet, LLC/)
expect(contents).to match(/test_strings.rb:1/)
end
+ it 'builds a POT file with :header_only' do
+ path = File.join(Dir.mktmpdir, 'new.pot')
+ expect do
+ GettextSetup::Pot.generate_new_pot(locales_path: fixture_locales_path,
target_path: path, header_only: true)
+ end.to output('').to_stdout # STDOUT is determined in `update_pot`
+ contents = File.read(path)
+ expect(contents).to_not match(/Hello, world/)
+ expect(contents).to match(/Fixture locales/)
+ expect(contents).to match(/[email protected]/)
+ expect(contents).to match(/Puppet, LLC/)
+ end
end
context 'generate_new_po' do
@@ -153,7 +164,7 @@
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
+ file.write <<-POT
# Copyright (C) 2017 Puppet, Inc.
# This file is distributed under the same license as the puppetlabs-mysql
package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2017.
@@ -175,7 +186,7 @@
#: ../lib/puppet/parser/functions/mysql_strip_hash.rb:11
msgid "this is a #{pot_type} string"
msgstr ""
- EOF
+ POT
end
end
end