i18n-docs 0.0.9 → 0.1.1
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 +5 -5
- data/.codeclimate.yml +4 -0
- data/.github/workflows/ci.yml +21 -0
- data/.gitignore +6 -1
- data/.rubocop.yml +11 -0
- data/.rubocop_todo.yml +50 -0
- data/Gemfile +8 -2
- data/README.md +87 -7
- data/Rakefile +22 -11
- data/i18n-docs.gemspec +13 -9
- data/lib/i18n-docs.rb +6 -13
- data/lib/{localch_i18n → i18n_docs}/csv_to_yaml.rb +26 -21
- data/lib/{localch_i18n → i18n_docs}/missing_keys_finder.rb +18 -21
- data/lib/{localch_i18n → i18n_docs}/translation_file_export.rb +18 -26
- data/lib/{localch_i18n → i18n_docs}/translations.rb +10 -10
- data/lib/i18n_docs/version.rb +3 -0
- data/lib/tasks/store_translations.rake +22 -31
- data/test/fixtures/config.yml +1 -1
- data/test/fixtures/error.csv +3 -0
- data/test/test_helper.rb +5 -7
- data/test/unit/csv_to_yaml_test.rb +41 -24
- data/test/unit/translation_file_export_test.rb +16 -20
- data/test/unit/translations_test.rb +16 -16
- metadata +47 -15
- data/lib/localch_i18n/version.rb +0 -3
- data/tasks/test.rake +0 -9
@@ -1,12 +1,10 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# Order of method calls
|
3
2
|
# download_files
|
4
3
|
# store_translations
|
5
4
|
# clean_up
|
6
5
|
#
|
7
|
-
module
|
6
|
+
module I18nDocs
|
8
7
|
class Translations
|
9
|
-
|
10
8
|
attr_accessor :locales, :tmp_folder, :config_file, :csv_files
|
11
9
|
|
12
10
|
def initialize(config_file = nil, tmp_folder = nil)
|
@@ -26,14 +24,14 @@ module LocalchI18n
|
|
26
24
|
|
27
25
|
def load_config
|
28
26
|
@settings = {}
|
29
|
-
@settings = YAML.load_file(config_file) if File.
|
27
|
+
@settings = YAML.load_file(config_file) if File.exist?(config_file)
|
30
28
|
end
|
31
29
|
|
32
30
|
def download_files
|
33
31
|
files = @settings['files']
|
34
32
|
files.each do |target_file, url|
|
35
|
-
#ensure .yml filename
|
36
|
-
target_file
|
33
|
+
# ensure .yml filename
|
34
|
+
target_file += '.yml' if target_file !~ /\.yml$/
|
37
35
|
# download file to tmp directory
|
38
36
|
tmp_file = File.basename(target_file).gsub('.yml', '.csv')
|
39
37
|
tmp_file = File.join(@tmp_folder, tmp_file)
|
@@ -54,7 +52,7 @@ module LocalchI18n
|
|
54
52
|
|
55
53
|
def clean_up
|
56
54
|
# remove all tmp files
|
57
|
-
@csv_files.each do |
|
55
|
+
@csv_files.each do |_target_file, csv_file|
|
58
56
|
File.unlink(csv_file)
|
59
57
|
end
|
60
58
|
end
|
@@ -62,12 +60,14 @@ module LocalchI18n
|
|
62
60
|
def download(url, destination_file)
|
63
61
|
puts "Download '#{url}' to '#{destination_file}'"
|
64
62
|
doc_data = open(url).read.force_encoding('UTF-8')
|
63
|
+
if (subs = @settings['substitutions'])
|
64
|
+
subs.each do |sub|
|
65
|
+
doc_data.gsub! sub['from'], sub['to']
|
66
|
+
end
|
67
|
+
end
|
65
68
|
File.open(destination_file, 'w') do |dst|
|
66
69
|
dst.write(doc_data)
|
67
70
|
end
|
68
71
|
end
|
69
|
-
|
70
72
|
end
|
71
73
|
end
|
72
|
-
|
73
|
-
|
@@ -1,58 +1,49 @@
|
|
1
1
|
|
2
2
|
namespace :i18n do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
finder = LocalchI18n::MissingKeysFinder.new(I18n.backend)
|
3
|
+
desc 'Find and list translation keys that do not exist in all locales'
|
4
|
+
task missing_keys: :environment do
|
5
|
+
finder = I18nDocs::MissingKeysFinder.new(I18n.backend)
|
7
6
|
finder.find_missing_keys
|
8
7
|
end
|
9
8
|
|
10
|
-
desc
|
11
|
-
task :
|
12
|
-
|
13
|
-
|
14
|
-
config_file = Rails.root.join('config', 'translations.yml')
|
15
|
-
raise "No config file 'config/translations.yml' found." if !File.exists?(config_file)
|
9
|
+
desc 'Download translations from Google Spreadsheet and save them to YAML files.'
|
10
|
+
task import_translations: :environment do
|
11
|
+
config_file = I18nDocs::CsvToYaml.root_path.join('config', 'translations.yml')
|
12
|
+
raise "No config file 'config/translations.yml' found." unless File.exist?(config_file)
|
16
13
|
|
17
|
-
tmp_dir =
|
14
|
+
tmp_dir = I18nDocs::CsvToYaml.root_path.join('tmp')
|
18
15
|
Dir.mkdir(tmp_dir) unless Dir.exist?(tmp_dir)
|
19
16
|
|
20
|
-
translations =
|
17
|
+
translations = I18nDocs::Translations.new(config_file, tmp_dir)
|
21
18
|
translations.download_files
|
22
19
|
translations.store_translations
|
23
20
|
translations.clean_up
|
24
|
-
|
25
21
|
end
|
26
22
|
|
27
|
-
desc
|
28
|
-
task :
|
29
|
-
|
30
|
-
|
31
|
-
source_dir = Rails.root.join('config', 'locales')
|
32
|
-
output_dir = Rails.root.join('tmp')
|
23
|
+
desc 'Export all language files to CSV files (only files contained in en folder are considered)'
|
24
|
+
task export_translations: :environment do
|
25
|
+
source_dir = I18nDocs::CsvToYaml.root_path.join('config', 'locales')
|
26
|
+
output_dir = I18nDocs::CsvToYaml.root_path.join('tmp')
|
33
27
|
locales = I18n.available_locales
|
34
28
|
|
35
29
|
input_files = Dir[File.join(source_dir, ENV['locale'] || 'en', '*.yml')]
|
36
30
|
|
37
|
-
puts
|
31
|
+
puts ''
|
38
32
|
puts " Detected locales: #{locales}"
|
39
|
-
puts
|
40
|
-
input_files.each {|f| puts " * #{File.basename(f)}" }
|
33
|
+
puts ' Detected files:'
|
34
|
+
input_files.each { |f| puts " * #{File.basename(f)}" }
|
41
35
|
|
42
|
-
puts
|
43
|
-
puts
|
36
|
+
puts ''
|
37
|
+
puts ' Start exporting files:'
|
44
38
|
|
45
39
|
input_files.each do |file|
|
46
40
|
file = File.basename(file)
|
47
|
-
exporter =
|
41
|
+
exporter = I18nDocs::TranslationFileExport.new(source_dir, file, output_dir, locales)
|
48
42
|
exporter.export
|
49
43
|
end
|
50
44
|
|
51
|
-
puts
|
52
|
-
puts
|
53
|
-
puts
|
45
|
+
puts ''
|
46
|
+
puts ' CSV files can be removed safely after uploading them manually to Google Spreadsheet.'
|
47
|
+
puts ''
|
54
48
|
end
|
55
|
-
|
56
49
|
end
|
57
|
-
|
58
|
-
|
data/test/fixtures/config.yml
CHANGED
@@ -6,4 +6,4 @@
|
|
6
6
|
# second.yml: http://www.google.com/spreadsheet/second.csv
|
7
7
|
#
|
8
8
|
files:
|
9
|
-
download.yml: "https://docs.google.com/
|
9
|
+
download.yml: "https://docs.google.com/spreadsheets/d/1PbmkqamXuNyP7gnVARpeCfV8rA7WvX98dTqsQB3Wdts/pub?output=csv"
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
1
4
|
require 'test/unit'
|
2
5
|
require 'fileutils'
|
3
6
|
require 'mocha/setup'
|
@@ -7,7 +10,6 @@ require 'i18n-docs'
|
|
7
10
|
Rails = Struct.new(:dummy)
|
8
11
|
|
9
12
|
module TestHelper
|
10
|
-
|
11
13
|
def fixture_path
|
12
14
|
File.join(File.expand_path(File.dirname(__FILE__)), 'fixtures')
|
13
15
|
end
|
@@ -17,14 +19,10 @@ module TestHelper
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def create_tmp_dir
|
20
|
-
FileUtils
|
22
|
+
FileUtils.mkdir(tmp_dir) unless File.exist?(tmp_dir)
|
21
23
|
end
|
22
24
|
|
23
25
|
def remove_tmp_dir
|
24
|
-
FileUtils
|
26
|
+
FileUtils.rmtree(tmp_dir)
|
25
27
|
end
|
26
|
-
|
27
28
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
@@ -3,7 +3,6 @@ require 'test_helper'
|
|
3
3
|
# run test: ruby -I test/ -I lib/ test/unit/csv_to_yaml_test.rb
|
4
4
|
|
5
5
|
module UnitTests
|
6
|
-
|
7
6
|
class CsvToYamlTest < Test::Unit::TestCase
|
8
7
|
include TestHelper
|
9
8
|
|
@@ -12,11 +11,11 @@ module UnitTests
|
|
12
11
|
|
13
12
|
@input_file = File.join(fixture_path, 'minimal.csv')
|
14
13
|
@output_file = File.join(tmp_dir, 'test.yml')
|
15
|
-
@locales = [
|
14
|
+
@locales = %w[de en]
|
16
15
|
|
17
|
-
Rails.stubs(:root).returns(stub(:
|
16
|
+
Rails.stubs(:root).returns(stub(join: @output_file))
|
18
17
|
|
19
|
-
@csv_to_yaml =
|
18
|
+
@csv_to_yaml = I18nDocs::CsvToYaml.new(@input_file, @output_file, @locales)
|
20
19
|
end
|
21
20
|
|
22
21
|
def teardown
|
@@ -24,8 +23,8 @@ module UnitTests
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def test_process_row
|
27
|
-
row1 = {'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => 'Telefonbuch der Schweiz'}
|
28
|
-
row2 = {'key' => 'homepage.welcome', 'en' => 'Welcome', 'de' => 'Willkommen'}
|
26
|
+
row1 = { 'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => 'Telefonbuch der Schweiz' }
|
27
|
+
row2 = { 'key' => 'homepage.welcome', 'en' => 'Welcome', 'de' => 'Willkommen' }
|
29
28
|
@csv_to_yaml.process_row(row1)
|
30
29
|
@csv_to_yaml.process_row(row2)
|
31
30
|
|
@@ -37,8 +36,8 @@ module UnitTests
|
|
37
36
|
end
|
38
37
|
|
39
38
|
def test_empty_row
|
40
|
-
row1 = {'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => 'Telefonbuch der Schweiz'}
|
41
|
-
row2 = {'key' => nil, 'en' => 'Welcome', 'de' => 'Willkommen'}
|
39
|
+
row1 = { 'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => 'Telefonbuch der Schweiz' }
|
40
|
+
row2 = { 'key' => nil, 'en' => 'Welcome', 'de' => 'Willkommen' }
|
42
41
|
@csv_to_yaml.process_row(row1)
|
43
42
|
@csv_to_yaml.process_row(row2)
|
44
43
|
|
@@ -48,18 +47,18 @@ module UnitTests
|
|
48
47
|
end
|
49
48
|
|
50
49
|
def test_row_containing_non_locale_columns
|
51
|
-
row = {'key' => 'homepage.title', 'en' =>
|
50
|
+
row = { 'key' => 'homepage.title', 'en' => 'We are the Phonebook', 'de' => 'Test DE',
|
51
|
+
'comment' => 'Test comment' }
|
52
52
|
@csv_to_yaml.process_row(row)
|
53
53
|
|
54
54
|
translations = @csv_to_yaml.translations
|
55
55
|
assert_equal 'We are the Phonebook', translations['en']['homepage']['title']
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
58
|
def test_empty_string_replacement_value
|
60
59
|
# As Google Spreadsheet does not export empty cells we use '_' as a fake whitespace which
|
61
60
|
# we replace with an empty string during CVS2YAML conversion.
|
62
|
-
row = {'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => '_'}
|
61
|
+
row = { 'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => '_' }
|
63
62
|
@csv_to_yaml.process_row(row)
|
64
63
|
|
65
64
|
translations = @csv_to_yaml.translations
|
@@ -67,9 +66,8 @@ module UnitTests
|
|
67
66
|
assert_equal 'Phonebook of Switzerland', translations['en']['homepage']['meta']['title']
|
68
67
|
end
|
69
68
|
|
70
|
-
|
71
69
|
def test_empty_string_value
|
72
|
-
row = {'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => ''}
|
70
|
+
row = { 'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => '' }
|
73
71
|
@csv_to_yaml.process_row(row)
|
74
72
|
|
75
73
|
translations = @csv_to_yaml.translations
|
@@ -77,9 +75,8 @@ module UnitTests
|
|
77
75
|
assert_equal 'Phonebook of Switzerland', translations['en']['homepage']['meta']['title']
|
78
76
|
end
|
79
77
|
|
80
|
-
|
81
78
|
def test_space_value
|
82
|
-
row = {'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => ' '}
|
79
|
+
row = { 'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => ' ' }
|
83
80
|
@csv_to_yaml.process_row(row)
|
84
81
|
|
85
82
|
translations = @csv_to_yaml.translations
|
@@ -88,7 +85,7 @@ module UnitTests
|
|
88
85
|
end
|
89
86
|
|
90
87
|
def test_nil_value
|
91
|
-
row = {'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => nil}
|
88
|
+
row = { 'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => nil }
|
92
89
|
@csv_to_yaml.process_row(row)
|
93
90
|
|
94
91
|
translations = @csv_to_yaml.translations
|
@@ -96,10 +93,9 @@ module UnitTests
|
|
96
93
|
assert_equal 'Phonebook of Switzerland', translations['en']['homepage']['meta']['title']
|
97
94
|
end
|
98
95
|
|
99
|
-
|
100
96
|
def test_nil_value_deep_structure
|
101
|
-
row1 = {'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => nil}
|
102
|
-
row2 = {'key' => 'homepage.welcome', 'en' => 'Welcome', 'de' => 'Willkommen'}
|
97
|
+
row1 = { 'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland', 'de' => nil }
|
98
|
+
row2 = { 'key' => 'homepage.welcome', 'en' => 'Welcome', 'de' => 'Willkommen' }
|
103
99
|
@csv_to_yaml.process_row(row1)
|
104
100
|
@csv_to_yaml.process_row(row2)
|
105
101
|
|
@@ -109,15 +105,28 @@ module UnitTests
|
|
109
105
|
assert_equal 'Phonebook of Switzerland', translations['en']['homepage']['meta']['title']
|
110
106
|
end
|
111
107
|
|
108
|
+
def test_row_for_missing_locale_key
|
109
|
+
row = { 'key' => 'homepage.meta.title', 'en' => 'Phonebook of Switzerland' }
|
110
|
+
assert_raise RuntimeError.new('Locale missing for key homepage.meta.title! (locales in app: ["de", "en"] / locales in file: ["en"])') do
|
111
|
+
@csv_to_yaml.process_row(row)
|
112
|
+
end
|
113
|
+
end
|
112
114
|
|
113
115
|
def test_store_translations
|
114
|
-
keys = [
|
116
|
+
keys = %w[homepage meta title]
|
115
117
|
@csv_to_yaml.store_translation(keys, 'de', 'Telefonbuch der Schweiz')
|
116
118
|
|
117
119
|
translations = @csv_to_yaml.translations
|
118
120
|
assert_equal 'Telefonbuch der Schweiz', translations['de']['homepage']['meta']['title']
|
119
121
|
end
|
120
122
|
|
123
|
+
def test_store_translations_with_faulty_locale
|
124
|
+
keys = %w[homepage meta title]
|
125
|
+
assert_raise RuntimeError.new("Error around key 'homepage.meta.title': Expected nil to be a Hash") do
|
126
|
+
@csv_to_yaml.store_translation(keys, 'zz', 'Telefonbuch der Schweiz')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
121
130
|
def test_process
|
122
131
|
@locales.each do |locale|
|
123
132
|
assert_empty @csv_to_yaml.translations[locale], "expected translation hash for locale '#{locale}' to be empty"
|
@@ -134,14 +143,14 @@ module UnitTests
|
|
134
143
|
end
|
135
144
|
|
136
145
|
def test_write_files
|
137
|
-
assert !File.
|
146
|
+
assert !File.exist?(@output_file)
|
138
147
|
@csv_to_yaml.process
|
139
148
|
@csv_to_yaml.write_files
|
140
|
-
assert File.
|
149
|
+
assert File.exist?(@output_file)
|
141
150
|
end
|
142
|
-
|
151
|
+
|
143
152
|
def test_key_has_spaces
|
144
|
-
row = {'key' => 'has. space', 'en' => 'yes', 'de' => 'ja'}
|
153
|
+
row = { 'key' => 'has. space', 'en' => 'yes', 'de' => 'ja' }
|
145
154
|
@csv_to_yaml.process_row(row)
|
146
155
|
|
147
156
|
translations = @csv_to_yaml.translations
|
@@ -149,5 +158,13 @@ module UnitTests
|
|
149
158
|
assert_equal 'yes', translations['en']['has']['space']
|
150
159
|
end
|
151
160
|
|
161
|
+
def test_wrong_csv_format_error_message
|
162
|
+
@input_file = File.join(fixture_path, 'error.csv')
|
163
|
+
@csv_to_yaml = I18nDocs::CsvToYaml.new(@input_file, @output_file, @locales)
|
164
|
+
|
165
|
+
assert_raise RuntimeError.new("Error around key 'top_level.key.another_key': Expected \"Value2\" to be a Hash") do
|
166
|
+
@csv_to_yaml.process
|
167
|
+
end
|
168
|
+
end
|
152
169
|
end
|
153
170
|
end
|
@@ -12,9 +12,9 @@ module UnitTests
|
|
12
12
|
source_dir = fixture_path
|
13
13
|
source_file = 'header.yml'
|
14
14
|
output_dir = tmp_dir
|
15
|
-
locales = [
|
15
|
+
locales = %w[en de]
|
16
16
|
|
17
|
-
@exporter =
|
17
|
+
@exporter = I18nDocs::TranslationFileExport.new(source_dir, source_file, output_dir, locales)
|
18
18
|
@output_file = File.join(output_dir, 'header.csv')
|
19
19
|
end
|
20
20
|
|
@@ -22,30 +22,28 @@ module UnitTests
|
|
22
22
|
remove_tmp_dir
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
25
|
def test_export
|
27
|
-
assert !File.
|
26
|
+
assert !File.exist?(@output_file)
|
28
27
|
@exporter.export
|
29
|
-
assert File.
|
28
|
+
assert File.exist?(@output_file), 'Expected to have a CSV file written'
|
30
29
|
end
|
31
30
|
|
32
31
|
def dtest_load_language
|
33
32
|
translations = @exporter.load_language('de')
|
34
33
|
|
35
|
-
assert translations,
|
36
|
-
assert_equal translations['header']['search'],
|
34
|
+
assert translations, 'Expected to return a hash with translations'
|
35
|
+
assert_equal translations['header']['search'], 'Finden'
|
37
36
|
end
|
38
37
|
|
39
38
|
def dtest_flatten_translations_hash
|
40
|
-
translation_hash = {'a' => {
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}
|
39
|
+
translation_hash = { 'a' => {
|
40
|
+
'I' => '1',
|
41
|
+
'II' => '2',
|
42
|
+
'III' => {
|
43
|
+
'Z' => '3'
|
44
|
+
}
|
45
|
+
},
|
46
|
+
'b' => '4' }
|
49
47
|
|
50
48
|
flat = @exporter.flatten_translations_hash(translation_hash, [])
|
51
49
|
assert_equal '1', flat['a.I']
|
@@ -66,8 +64,8 @@ module UnitTests
|
|
66
64
|
end
|
67
65
|
|
68
66
|
def dtest_write_to_csv
|
69
|
-
@exporter.translations = {'de' => {'numbers.one' => 'eins'},
|
70
|
-
|
67
|
+
@exporter.translations = { 'de' => { 'numbers.one' => 'eins' },
|
68
|
+
'en' => { 'numbers.one' => 'one' } }
|
71
69
|
|
72
70
|
@exporter.write_to_csv
|
73
71
|
|
@@ -75,7 +73,5 @@ module UnitTests
|
|
75
73
|
assert_match(/^key,(en|de|,){3}$/, output)
|
76
74
|
assert_match(/^numbers.one,(one|eins|,){3}$/, output)
|
77
75
|
end
|
78
|
-
|
79
|
-
|
80
76
|
end
|
81
77
|
end
|
@@ -10,15 +10,15 @@ module UnitTests
|
|
10
10
|
create_tmp_dir
|
11
11
|
|
12
12
|
config_file = File.join(fixture_path, 'config.yml')
|
13
|
-
@translations =
|
13
|
+
@translations = I18nDocs::Translations.new(config_file, tmp_dir)
|
14
14
|
@translations.tmp_folder = tmp_dir
|
15
|
-
@translations.locales = [
|
15
|
+
@translations.locales = %w[de en]
|
16
16
|
|
17
17
|
@fixture_file = File.join(fixture_path, 'minimal.csv')
|
18
18
|
@tmp_file = File.join(tmp_dir, 'downloaded.csv')
|
19
19
|
@output_file = File.join(tmp_dir, 'test.yml')
|
20
20
|
|
21
|
-
Rails.stubs(:root).returns(stub(:
|
21
|
+
Rails.stubs(:root).returns(stub(join: @output_file))
|
22
22
|
end
|
23
23
|
|
24
24
|
def teardown
|
@@ -26,35 +26,35 @@ module UnitTests
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_download
|
29
|
-
assert !File.
|
30
|
-
|
31
|
-
|
29
|
+
assert !File.exist?(@tmp_file)
|
30
|
+
sheet_url = 'https://docs.google.com/spreadsheets/d/1PbmkqamXuNyP7gnVARpeCfV8rA7WvX98dTqsQB3Wdts/pub?output=csv'
|
31
|
+
@translations.download(sheet_url, @tmp_file)
|
32
|
+
assert File.exist?(@tmp_file), "Expected to have downloaded Google Spreadsheet to '#{@tmp_file}'"
|
32
33
|
end
|
33
34
|
|
34
35
|
def test_cleanup
|
35
|
-
@translations.csv_files = {'dummy.yml' => @tmp_file}
|
36
|
-
File.open(@tmp_file,
|
37
|
-
assert File.
|
36
|
+
@translations.csv_files = { 'dummy.yml' => @tmp_file }
|
37
|
+
File.open(@tmp_file, 'w') {}
|
38
|
+
assert File.exist?(@tmp_file)
|
38
39
|
@translations.clean_up
|
39
|
-
assert !File.
|
40
|
+
assert !File.exist?(@tmp_file), 'Expected to delete file'
|
40
41
|
end
|
41
42
|
|
42
43
|
def test_store_translations
|
43
|
-
assert !File.
|
44
|
+
assert !File.exist?(@output_file)
|
44
45
|
|
45
|
-
@translations.csv_files = {@output_file => @fixture_file}
|
46
|
+
@translations.csv_files = { @output_file => @fixture_file }
|
46
47
|
@translations.store_translations
|
47
48
|
|
48
|
-
assert File.
|
49
|
+
assert File.exist?(@output_file)
|
49
50
|
end
|
50
51
|
|
51
52
|
def test_download_files
|
52
53
|
expected_file = File.join(tmp_dir, 'download.csv')
|
53
|
-
assert !File.
|
54
|
+
assert !File.exist?(expected_file)
|
54
55
|
@translations.download_files
|
55
|
-
assert File.
|
56
|
+
assert File.exist?(expected_file)
|
56
57
|
assert File.open(expected_file).read.encoding.name == 'UTF-8'
|
57
58
|
end
|
58
|
-
|
59
59
|
end
|
60
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-docs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georg Kunz
|
@@ -10,6 +10,7 @@ authors:
|
|
10
10
|
- Eduard Schäli
|
11
11
|
- Robin Wunderlin
|
12
12
|
- Esteban Pastorino
|
13
|
+
- Krzysztof Sakwerda
|
13
14
|
autorequire:
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
@@ -44,44 +45,76 @@ dependencies:
|
|
44
45
|
- !ruby/object:Gem::Version
|
45
46
|
version: 0.13.3
|
46
47
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
48
|
+
name: test-unit
|
48
49
|
requirement: !ruby/object:Gem::Requirement
|
49
50
|
requirements:
|
50
|
-
- - "
|
51
|
+
- - "~>"
|
51
52
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
53
|
+
version: 3.1.7
|
53
54
|
type: :development
|
54
55
|
prerelease: false
|
55
56
|
version_requirements: !ruby/object:Gem::Requirement
|
56
57
|
requirements:
|
57
|
-
- - "
|
58
|
+
- - "~>"
|
58
59
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
60
|
+
version: 3.1.7
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: simplecov
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.16.1
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.16.1
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rubocop
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.48.0
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.48.0
|
60
89
|
description: 'GEM providing helper scripts to manage i18n translations in Google Docs.
|
61
90
|
Features: check YAML files for missing translations; export YAML files to CSV; download
|
62
91
|
translations from multiple Google spreadsheets and store to YAML files'
|
63
|
-
email:
|
92
|
+
email: eduard.schaeli@localsearch.ch
|
64
93
|
executables: []
|
65
94
|
extensions: []
|
66
95
|
extra_rdoc_files: []
|
67
96
|
files:
|
97
|
+
- ".codeclimate.yml"
|
98
|
+
- ".github/workflows/ci.yml"
|
68
99
|
- ".gitignore"
|
100
|
+
- ".rubocop.yml"
|
101
|
+
- ".rubocop_todo.yml"
|
69
102
|
- Gemfile
|
70
103
|
- LICENSE.md
|
71
104
|
- README.md
|
72
105
|
- Rakefile
|
73
106
|
- i18n-docs.gemspec
|
74
107
|
- lib/i18n-docs.rb
|
75
|
-
- lib/
|
76
|
-
- lib/
|
77
|
-
- lib/
|
78
|
-
- lib/
|
79
|
-
- lib/
|
108
|
+
- lib/i18n_docs/csv_to_yaml.rb
|
109
|
+
- lib/i18n_docs/missing_keys_finder.rb
|
110
|
+
- lib/i18n_docs/translation_file_export.rb
|
111
|
+
- lib/i18n_docs/translations.rb
|
112
|
+
- lib/i18n_docs/version.rb
|
80
113
|
- lib/tasks/store_translations.rake
|
81
|
-
- tasks/test.rake
|
82
114
|
- test/fixtures/config.yml
|
83
115
|
- test/fixtures/de/header.yml
|
84
116
|
- test/fixtures/en/header.yml
|
117
|
+
- test/fixtures/error.csv
|
85
118
|
- test/fixtures/minimal.csv
|
86
119
|
- test/fixtures/test.csv
|
87
120
|
- test/test_helper.rb
|
@@ -106,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
139
|
- !ruby/object:Gem::Version
|
107
140
|
version: '0'
|
108
141
|
requirements: []
|
109
|
-
|
110
|
-
rubygems_version: 2.4.8
|
142
|
+
rubygems_version: 3.1.6
|
111
143
|
signing_key:
|
112
144
|
specification_version: 4
|
113
145
|
summary: Maintain translations in Google Docs and export them to your Rails project.
|
data/lib/localch_i18n/version.rb
DELETED