i18n_check_translations 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/.rvmrc +62 -0
- data/CHANGELOG +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +57 -0
- data/Rakefile +1 -0
- data/i18n_check_translations.gemspec +23 -0
- data/lib/i18n_check_translations.rb +163 -0
- data/lib/i18n_check_translations/version.rb +3 -0
- data/lib/tasks/i18n_check_translations.rake +29 -0
- data/spec/i18n_check_translations_spec.rb +73 -0
- data/spec/spec_helper.rb +1 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MzdiMDZmMzVhMThhZmRiMzkwYjdiNzRlMWFlMmMyMDM1NDc2YzIyYQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NmJmOGIwNTBkM2MzYjEwYjI4M2ZkOGY4YmU3ODQzM2UwMmYzNzhlOQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NThmNjcwNjZmOTI0ZjcxMjNjNDM1NGNhNjkwZGNjYjE5YTQzZmY5NWM5OTU4
|
10
|
+
NzFhMTk0YjUyZWQ1N2Y4MzkwNWIwNDU3OGEyMjJlOGNiNGFhMmE0YmQwZGI4
|
11
|
+
NjFhZThlYzc3ODA1MThiMThiM2Y0OWRhODhkODQxZWJjYWM0YmQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTI2MjM0NDkzODdjZGRmNWI2YjdmMTg3ZmNiZGMxYmNhYTM2MzdhM2VmZDNj
|
14
|
+
NTQ1MTM0ZmNkNGY2MDJkYmY1ZmFkM2I0NjlkMmNkNmU5OTQxNmM5MWVmY2U0
|
15
|
+
MTY4YWQzNzMxZDc0MWRhOTFmYjE2ZWZlMmRkMzMxMDVlNzllY2Q=
|
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p327@i18n_check_translations"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.25.17 (stable)" # 1.10.1 seems like a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | __rvm_awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
|
27
|
+
do
|
28
|
+
if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
|
29
|
+
then \. "${__hook}" || true
|
30
|
+
fi
|
31
|
+
done
|
32
|
+
unset __hook
|
33
|
+
if (( ${rvm_use_flag:=1} >= 2 )) # display only when forced
|
34
|
+
then
|
35
|
+
if [[ $- == *i* ]] # check for interactive shells
|
36
|
+
then printf "%b" "Using: $(tput setaf 2 2>/dev/null)$GEM_HOME$(tput sgr0 2>/dev/null)
|
37
|
+
" # show the user the ruby and gemset they are using in green
|
38
|
+
else printf "%b" "Using: $GEM_HOME
|
39
|
+
" # don't use colors in non-interactive shells
|
40
|
+
fi
|
41
|
+
fi
|
42
|
+
else
|
43
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
44
|
+
rvm --create "$environment_id" || {
|
45
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
46
|
+
return 1
|
47
|
+
}
|
48
|
+
fi
|
49
|
+
|
50
|
+
# If you use bundler, this might be useful to you:
|
51
|
+
# if [[ -s Gemfile ]] && {
|
52
|
+
# ! builtin command -v bundle >/dev/null ||
|
53
|
+
# builtin command -v bundle | GREP_OPTIONS="" \grep $rvm_path/bin/bundle >/dev/null
|
54
|
+
# }
|
55
|
+
# then
|
56
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
57
|
+
# gem install bundler
|
58
|
+
# fi
|
59
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
60
|
+
# then
|
61
|
+
# bundle install | GREP_OPTIONS="" \grep -vE '^Using|Your bundle is complete'
|
62
|
+
# fi
|
data/CHANGELOG
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
v1.0.0. First Release
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Panayotis Matsinopoulos
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# I18nCheckTranslations
|
2
|
+
|
3
|
+
It can help you find out which translations are missing from your Rails translations files.
|
4
|
+
So, it is basically a development utility.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'i18n_check_translations'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install i18n_check_translations
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Try on the command line:
|
23
|
+
|
24
|
+
rake i18n:check[en,nl]
|
25
|
+
|
26
|
+
It will generate the file `i18n_check_translations.csv` with all the `en` (English) keys found in your translation files
|
27
|
+
that reside in the directory tree `config/locales`. For each key, will hold the translation in English, the translation in `nl`,
|
28
|
+
or a string starting from `translation missing` if the translation is missing, and the file that the translation is/was supposed
|
29
|
+
to be.
|
30
|
+
|
31
|
+
If you try:
|
32
|
+
|
33
|
+
rake i18n:check[en,nl,true]
|
34
|
+
|
35
|
+
it will raise a `StandardError` exception when it will find a case in which the translation is missing.
|
36
|
+
|
37
|
+
If you try:
|
38
|
+
|
39
|
+
rake i18n:check[en,nl,false,filename]
|
40
|
+
|
41
|
+
it will generate the file with name `filename` and save the results in it.
|
42
|
+
|
43
|
+
If you try:
|
44
|
+
|
45
|
+
rake i18n::check[en]
|
46
|
+
|
47
|
+
or, in order words, if you omit the destination translation, task will run once for every available locale and will generate
|
48
|
+
a corresponding file. For example, if your available locales (excluding English in the example) were `:nl` and `:gr` you
|
49
|
+
would get the output in `i18n_check_translations-nl.csv` and in `i18n_check_translations-gr.csv`.
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
1. Fork it ( http://github.com/<my-github-username>/i18n_check_translations/fork )
|
54
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
55
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
56
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'i18n_check_translations/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "i18n_check_translations"
|
8
|
+
spec.version = I18nCheckTranslations::VERSION
|
9
|
+
spec.authors = ["Panayotis Matsinopoulos"]
|
10
|
+
spec.email = ["panayotis@matsinopoulos.gr"]
|
11
|
+
spec.summary = %q{Checks your consistency of your translations and can be helpful to find missing ones.}
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib", File.join("lib", "tasks")]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require "i18n_check_translations/version"
|
2
|
+
load 'i18n_check_translations.rake'
|
3
|
+
require 'csv'
|
4
|
+
|
5
|
+
module I18nCheckTranslations
|
6
|
+
# @param basic_locale {Symbol} e.g.: :en, :nl, :gr
|
7
|
+
# @param check_on_locale {Symbol} e.g.: :en, :nl, :gr
|
8
|
+
# @param raise_error_if_missing {true|false with default nil}
|
9
|
+
#
|
10
|
+
# @return {Hash} The result of processing the locales files for +basic_locale+ and trying to translate
|
11
|
+
# all the keys to the +check_on_locale+. See example below.
|
12
|
+
#
|
13
|
+
# It takes all the translation keys for the +basic_locale+ and tries to translate them
|
14
|
+
# to +check_on_locale+. For those that are missing translations, it either write the
|
15
|
+
# error or raises and Exception.
|
16
|
+
#
|
17
|
+
# Usage example:
|
18
|
+
#
|
19
|
+
# 1) result = I18nCheckTranslations.check :en, :nl
|
20
|
+
# will take all the *.en.yml files from config/locales and will build a
|
21
|
+
# a Hash with all the translation keys and their values on the :nl locale
|
22
|
+
# For example:
|
23
|
+
#
|
24
|
+
# {"en.customer.first_name" => {:translation => "Voornaam",
|
25
|
+
# :basic_local_translation => "First Name",
|
26
|
+
# :localization_file => "/config/locales/customers/nl.yml"}}
|
27
|
+
# If the translation is missing for :nl, then you are going to see on :translation something that
|
28
|
+
# starts with "translation missing"
|
29
|
+
#
|
30
|
+
# 2) result = I18nCheckTranslations.check :en, :nl, true
|
31
|
+
#
|
32
|
+
# Same as (1), but it will raise an error if a translation is missing
|
33
|
+
#
|
34
|
+
def self.check(basic_locale, check_on_locale, raise_error_if_missing = false)
|
35
|
+
result = {}
|
36
|
+
|
37
|
+
disable_fallbacks # if fallbacks are enabled, then missing translations will not be missing.
|
38
|
+
|
39
|
+
previous_locale = I18n.locale # save the current locale in order to restore it at the end of the process
|
40
|
+
I18n.locale = check_on_locale
|
41
|
+
|
42
|
+
Dir.glob(File.join(Rails.root, 'config', 'locales', '**', "*#{basic_locale}.yml")).each do |localization_file|
|
43
|
+
hash_input = YAML.load_file localization_file
|
44
|
+
|
45
|
+
paths = hash_traverse hash_input # big stuff of the work is done here to build all the translation keys from a file.
|
46
|
+
|
47
|
+
paths.each do |key, translation|
|
48
|
+
key_to_translate = key.gsub /^#{basic_locale.to_s}\./, '' # - remove the "en." from "en.customer.first_name"
|
49
|
+
new_key = "#{check_on_locale}.#{key_to_translate}" # - and make it "nl.customer.first_name" to index the Hash result
|
50
|
+
new_translation = I18n.translate key_to_translate # - do the translation
|
51
|
+
|
52
|
+
result[new_key] = {:translation => new_translation,
|
53
|
+
:basic_locale_translation => translation,
|
54
|
+
:localization_file => dest_localization_file(localization_file, basic_locale, check_on_locale)}
|
55
|
+
|
56
|
+
raise StandardError.new("Missing translation! #{result[new_key].inspect}") if new_translation.start_with?('translation missing') && raise_error_if_missing
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
I18n.locale = previous_locale # restore locale
|
61
|
+
|
62
|
+
enable_fallbacks
|
63
|
+
|
64
|
+
result
|
65
|
+
end
|
66
|
+
|
67
|
+
# Same as +I18nCheckTranslations.check+ but takes as input the +filename+ that will be used
|
68
|
+
# to save the results into a csv file.
|
69
|
+
#
|
70
|
+
def self.check_and_dump(filename, basic_locale, check_on_locale, raise_error_if_missing = false)
|
71
|
+
result = check(basic_locale, check_on_locale, raise_error_if_missing)
|
72
|
+
CSV.open filename, 'wb', :force_quotes => true do |csv|
|
73
|
+
csv << ['KEY', 'BASIC TRANSLATION', 'TRANSLATION', 'LOCALIZATION FILE']
|
74
|
+
result.each do |k, v|
|
75
|
+
csv << [k, v[:basic_locale_translation], v[:translation], v[:localization_file]]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
# We build the destination localization file from the source localication file.
|
83
|
+
#
|
84
|
+
# Hence, given a source file: 'config/locales/customers/en.yml'
|
85
|
+
# a basic locale: :en
|
86
|
+
# a check_on_locale: :nl
|
87
|
+
#
|
88
|
+
# becomes 'config/locales/customers/nl.yml'
|
89
|
+
#
|
90
|
+
# We also take care to remove any Rails root prefix. Makes the path to file
|
91
|
+
# easier to read.
|
92
|
+
#
|
93
|
+
def self.dest_localization_file(source_localization_file, basic_locale, check_on_locale)
|
94
|
+
source_localization_file.gsub(/#{Rails.root}/, '').gsub(/#{basic_locale}.yml$/, "#{check_on_locale}.yml")
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.disable_fallbacks
|
98
|
+
I18n.available_locales.each do |al|
|
99
|
+
I18n.fallbacks.merge!({al => [al]})
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.enable_fallbacks
|
104
|
+
I18n.available_locales.each do |al|
|
105
|
+
I18n.fallbacks.merge!({al => [al, I18n.default_locale]})
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Takes hashes like this:
|
110
|
+
#
|
111
|
+
# hash = {:en => {:hello => 'Hello',
|
112
|
+
# :world => 'World',
|
113
|
+
# :wonderful => {:another => "wonderful",
|
114
|
+
# :what => "world"},
|
115
|
+
# :what_to => {:do_it => {:i_will_not => 'what is that?',
|
116
|
+
# :you_will => 'another one'},
|
117
|
+
# :redo_it => 'hello redo it'}
|
118
|
+
# },
|
119
|
+
# :gr => {:there => 'hello 2',
|
120
|
+
# :again => {:what => 'again what on earth'}}
|
121
|
+
# }
|
122
|
+
#
|
123
|
+
# and returns a Hash like:
|
124
|
+
#
|
125
|
+
# {
|
126
|
+
# 'en.hello' => 'Hello',
|
127
|
+
# 'en.world' => 'World',
|
128
|
+
# 'en.wonderful.another' => 'wonderful',
|
129
|
+
# 'en.wonderful.what' => 'world',
|
130
|
+
# 'en.what_to.do_it.i_will_not' => 'what is that?',
|
131
|
+
# 'en.what_to.do_it.you_will' => 'another one',
|
132
|
+
# 'en.what_to.redo_it' => 'hello redo it',
|
133
|
+
#
|
134
|
+
# 'gr.there' => 'hello 2',
|
135
|
+
# 'gr.again.what' => 'again what on earth'
|
136
|
+
# }
|
137
|
+
#
|
138
|
+
def self.hash_traverse(hash)
|
139
|
+
parents = []
|
140
|
+
paths = {}
|
141
|
+
hash.keys.each do |k|
|
142
|
+
paths = hash_traverse_root(hash, k, parents, paths)
|
143
|
+
end
|
144
|
+
paths
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.hash_traverse_root(hash, k, parents, paths)
|
148
|
+
if hash[k].is_a?(Hash)
|
149
|
+
parents.push(k)
|
150
|
+
hash = hash[k]
|
151
|
+
hash.each do |k, v|
|
152
|
+
hash_traverse_root(hash, k, parents, paths)
|
153
|
+
end
|
154
|
+
parents.pop
|
155
|
+
elsif hash[k].is_a?(String)
|
156
|
+
parents.push(k)
|
157
|
+
path = parents.join(".")
|
158
|
+
paths[path] = hash[k]
|
159
|
+
parents.pop
|
160
|
+
end
|
161
|
+
paths
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'i18n_check_translations'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
desc "Check your locales for consistency and missing translations"
|
5
|
+
namespace :i18n do
|
6
|
+
task :check, [:basic_locale, :check_on_locale, :raise_error_if_missing, :filename] => :environment do |t, args|
|
7
|
+
basic_locale = args[:basic_locale]
|
8
|
+
check_on_locale = args[:check_on_locale]
|
9
|
+
raise_error_if_missing = args[:raise_error_if_missing].present? ? args[:raise_error_if_missing] == 'true' : false
|
10
|
+
filename = args[:filename]
|
11
|
+
|
12
|
+
basic_locale = I18n.default_locale if basic_locale.nil?
|
13
|
+
basic_locale = basic_locale.to_sym
|
14
|
+
|
15
|
+
check_on_locale = :all if check_on_locale.blank?
|
16
|
+
check_on_locale = check_on_locale.to_sym
|
17
|
+
|
18
|
+
filename = File.join(Rails.root, 'i18n_check_translations.csv') if filename.nil?
|
19
|
+
|
20
|
+
if check_on_locale == :all
|
21
|
+
I18n.available_locales.select {|al| al != basic_locale}.each do |dest_locale|
|
22
|
+
new_filename = filename.gsub /\.csv$/, "-#{dest_locale}.csv"
|
23
|
+
I18nCheckTranslations.check_and_dump(new_filename, basic_locale, dest_locale, raise_error_if_missing)
|
24
|
+
end
|
25
|
+
else
|
26
|
+
I18nCheckTranslations.check_and_dump(filename, basic_locale, check_on_locale, raise_error_if_missing)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe I18nCheckTranslations do
|
4
|
+
describe '.hash_traverse' do
|
5
|
+
shared_examples 'successful traversal' do
|
6
|
+
it 'successfully traverses' do
|
7
|
+
result = I18nCheckTranslations.send :hash_traverse, hash
|
8
|
+
|
9
|
+
expect(result).to eq(expected_result)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
context 'given hash case 1' do
|
13
|
+
let(:hash) do
|
14
|
+
{:en => {:hello => 'Hello',
|
15
|
+
:world => 'World',
|
16
|
+
:wonderful => {:another => "wonderful",
|
17
|
+
:what => "world"},
|
18
|
+
:what_to => {:do_it => {:i_will_not => 'what is that?',
|
19
|
+
:you_will => 'another one'},
|
20
|
+
:redo_it => 'hello redo it'}
|
21
|
+
},
|
22
|
+
:gr => {:there => 'hello 2',
|
23
|
+
:again => {:what => 'again what on earth'}}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
let(:expected_result) do
|
27
|
+
{
|
28
|
+
'en.hello' => 'Hello',
|
29
|
+
'en.world' => 'World',
|
30
|
+
'en.wonderful.another' => 'wonderful',
|
31
|
+
'en.wonderful.what' => 'world',
|
32
|
+
'en.what_to.do_it.i_will_not' => 'what is that?',
|
33
|
+
'en.what_to.do_it.you_will' => 'another one',
|
34
|
+
'en.what_to.redo_it' => 'hello redo it',
|
35
|
+
|
36
|
+
'gr.there' => 'hello 2',
|
37
|
+
'gr.again.what' => 'again what on earth'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
it_behaves_like 'successful traversal'
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'given hash case 2' do
|
44
|
+
let(:hash) do
|
45
|
+
{:en => {:hello => 'Hello'}}
|
46
|
+
end
|
47
|
+
let(:expected_result) do
|
48
|
+
{
|
49
|
+
'en.hello' => 'Hello'
|
50
|
+
}
|
51
|
+
end
|
52
|
+
it_behaves_like 'successful traversal'
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'given hash case 3' do
|
56
|
+
let(:hash) do
|
57
|
+
{:en => {:hello => {:hello2 => {:hello3 => {:hello4 => 'Hello 4'},
|
58
|
+
:hello31 => 'Hello 31'},
|
59
|
+
:hello21 => 'Hello 21'},
|
60
|
+
:hello1 => 'Hello 1'}}
|
61
|
+
end
|
62
|
+
let(:expected_result) do
|
63
|
+
{
|
64
|
+
'en.hello.hello2.hello3.hello4' => 'Hello 4',
|
65
|
+
'en.hello.hello2.hello31' => 'Hello 31',
|
66
|
+
'en.hello.hello21' => 'Hello 21',
|
67
|
+
'en.hello1' => 'Hello 1'
|
68
|
+
}
|
69
|
+
end
|
70
|
+
it_behaves_like 'successful traversal'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'i18n_check_translations'
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: i18n_check_translations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Panayotis Matsinopoulos
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- panayotis@matsinopoulos.gr
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .rvmrc
|
64
|
+
- CHANGELOG
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- i18n_check_translations.gemspec
|
70
|
+
- lib/i18n_check_translations.rb
|
71
|
+
- lib/i18n_check_translations/version.rb
|
72
|
+
- lib/tasks/i18n_check_translations.rake
|
73
|
+
- spec/i18n_check_translations_spec.rb
|
74
|
+
- spec/spec_helper.rb
|
75
|
+
homepage: ''
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
- lib/tasks
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.2.2
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Checks your consistency of your translations and can be helpful to find missing
|
100
|
+
ones.
|
101
|
+
test_files:
|
102
|
+
- spec/i18n_check_translations_spec.rb
|
103
|
+
- spec/spec_helper.rb
|