i18n-tasks 0.2.19 → 0.2.20
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/CHANGES.md +5 -1
- data/LICENSE.txt +1 -1
- data/README.md +51 -39
- data/doc/img/i18n-usages.png +0 -0
- data/i18n-tasks.gemspec +1 -1
- data/lib/i18n/tasks.rb +7 -2
- data/lib/i18n/tasks/base_task.rb +2 -4
- data/lib/i18n/tasks/configuration.rb +2 -4
- data/lib/i18n/tasks/data/adapter/json_adapter.rb +22 -0
- data/lib/i18n/tasks/data/adapter/yaml_adapter.rb +21 -0
- data/lib/i18n/tasks/data/file_system.rb +13 -0
- data/lib/i18n/tasks/data/storage/file_storage.rb +105 -0
- data/lib/i18n/tasks/data/yaml.rb +6 -65
- data/lib/i18n/tasks/data_traversal.rb +2 -2
- data/lib/i18n/tasks/fill_tasks.rb +2 -11
- data/lib/i18n/tasks/ignore_keys.rb +3 -1
- data/lib/i18n/tasks/key.rb +60 -0
- data/lib/i18n/tasks/key_group.rb +65 -0
- data/lib/i18n/tasks/missing_keys.rb +51 -18
- data/lib/i18n/tasks/reports/base.rb +8 -4
- data/lib/i18n/tasks/reports/spreadsheet.rb +8 -8
- data/lib/i18n/tasks/reports/terminal.rb +39 -16
- data/lib/i18n/tasks/scanners/base_scanner.rb +36 -2
- data/lib/i18n/tasks/scanners/pattern_scanner.rb +9 -7
- data/lib/i18n/tasks/translation_data.rb +4 -1
- data/lib/i18n/tasks/unused_keys.rb +9 -7
- data/lib/i18n/tasks/{source_keys.rb → used_keys.rb} +5 -6
- data/lib/i18n/tasks/version.rb +1 -1
- data/lib/tasks/i18n-tasks.rake +24 -20
- data/spec/file_system_data_spec.rb +68 -0
- data/spec/fixtures/config/i18n-tasks.yml +2 -2
- data/spec/i18n_tasks_spec.rb +5 -5
- data/spec/key_group_spec.rb +48 -0
- data/spec/used_keys_spec.rb +22 -0
- metadata +17 -7
- data/lib/i18n/tasks/untranslated_keys.rb +0 -50
- data/spec/yaml_adapter_spec.rb +0 -33
@@ -1,50 +0,0 @@
|
|
1
|
-
module I18n::Tasks::UntranslatedKeys
|
2
|
-
# Get all the missing translations as an array of missing keys as hashes with the following options:
|
3
|
-
# :locale
|
4
|
-
# :key
|
5
|
-
# :type — :blank, :missing, or :eq_base
|
6
|
-
# :base_value — translation value in base locale if one is present
|
7
|
-
# @param [Array] locales - locales for which to return missing keys
|
8
|
-
# @return [Array<Hash{Symbol => String,Symbol,nil}>]
|
9
|
-
def untranslated_keys(locales = nil)
|
10
|
-
locales ||= self.locales
|
11
|
-
sort_key_infos(keys_not_in_base_info + keys_eq_base_info(locales) + keys_blank_in_locale_info(locales))
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [Array<Hash{Symbol => String,Symbol,nil}>]
|
15
|
-
def keys_not_in_base_info
|
16
|
-
sort_key_infos keys_to_info(keys_not_in_base, locale: base_locale, type: :none)
|
17
|
-
end
|
18
|
-
|
19
|
-
# @return [Array<Hash{Symbol => String,Symbol,nil}>]
|
20
|
-
def keys_eq_base_info(locales = nil)
|
21
|
-
locales ||= non_base_locales
|
22
|
-
sort_key_infos (locales - [base_locale]).inject([]) { |result, locale|
|
23
|
-
result + keys_to_info(keys_eq_base(locale), locale: locale, type: :eq_base)
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
# @return [Array<Hash{Symbol => String,Symbol,nil}>]
|
28
|
-
def keys_blank_in_locale_info(locales = nil)
|
29
|
-
locales ||= self.locales
|
30
|
-
sort_key_infos locales.inject([]) { |result, locale|
|
31
|
-
result + keys_to_info(keys_blank_in_locale(locale), locale: locale, type: :blank)
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
# sort first by locale, then by type
|
36
|
-
# @return Array{Hash}
|
37
|
-
def sort_key_infos(keys)
|
38
|
-
keys.sort { |a, b|
|
39
|
-
by = [:locale, :type, :key].detect { |by| a[by] != b[by] }
|
40
|
-
a[by] <=> b[by]
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
protected
|
45
|
-
|
46
|
-
# convert the keys to a list of hashes with {key, base_value, *info}
|
47
|
-
def keys_to_info(keys, info = {})
|
48
|
-
keys.map { |key| {key: key, base_value: t(base_locale, key)}.merge(info) }
|
49
|
-
end
|
50
|
-
end
|
data/spec/yaml_adapter_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'YAML adapter' do
|
4
|
-
describe 'options' do
|
5
|
-
let!(:data) { I18n::Tasks::Data::Yaml.new }
|
6
|
-
after { TestCodebase.teardown }
|
7
|
-
|
8
|
-
it 'reads' do
|
9
|
-
data.config = {read: ['a.yml', '{b,c}.yml']}
|
10
|
-
TestCodebase.setup(
|
11
|
-
'a.yml' => {en: {a: 1}}.stringify_keys.to_yaml,
|
12
|
-
'b.yml' => {en: {b: 1}}.stringify_keys.to_yaml,
|
13
|
-
'c.yml' => {en: {c: 1}}.stringify_keys.to_yaml
|
14
|
-
)
|
15
|
-
TestCodebase.in_test_app_dir {
|
16
|
-
data[:en].should == {a: 1, b: 1, c: 1}
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'writes' do
|
21
|
-
data.config = {read: 'a.yml', write: [['{:}.*', '\1.%{locale}.yml']]}
|
22
|
-
keys = {'a' => {'b' => 'c'}, 'x' => 'y'}
|
23
|
-
locale_data = {'pizza' => keys, 'sushi' => keys}
|
24
|
-
TestCodebase.setup
|
25
|
-
TestCodebase.in_test_app_dir {
|
26
|
-
data[:en] = locale_data
|
27
|
-
files = %w(pizza.en.yml sushi.en.yml)
|
28
|
-
Dir['*.yml'].sort.should == files.sort
|
29
|
-
files.each { |f| YAML.load_file(f)['en'].should == {File.basename(f, '.en.yml') => keys} }
|
30
|
-
}
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|