neeto-translate-cli 0.3.0 → 0.3.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8c28612a13470b065b969ab1a0a9c8b6032b97277831e26d29dcb162c5910a51
|
|
4
|
+
data.tar.gz: f6b66f779db20ce9295aa689f57de60ff25c70216ac4d5fd2ddf28168159d860
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5356ea228db659c589d028cf4ec3bce893917452c25606a9764c08bc8e05bf019dc385e8b29083ab05ffd8e25e23dc684b32bd03f5f349696084b96e776cee8c
|
|
7
|
+
data.tar.gz: b10758d936606e7b58277368056f427a56163e3a127bd2e5f0ecba78683dd24e1a58fa33b217a3ba240f0fcaf468eb54b600733ebc9bf70f343b5d491af2f8ca
|
|
@@ -9,6 +9,7 @@ module NeetoTranslateCli
|
|
|
9
9
|
# Same plural rule as Github::CreatePullRequestService on the server.
|
|
10
10
|
PLURAL_FORM_REGEX = /\A(?<base>.+)(?<separator>[._])(?:zero|one|two|few|many|other)\z/
|
|
11
11
|
PLURAL_BASE_FORMS = %w[one other].freeze
|
|
12
|
+
PLURAL_SEPARATORS = %w[_ .].freeze
|
|
12
13
|
|
|
13
14
|
attr_reader :options, :updated_keys
|
|
14
15
|
|
|
@@ -117,7 +118,9 @@ module NeetoTranslateCli
|
|
|
117
118
|
translations = load_translations(type, lang)
|
|
118
119
|
next unless translations
|
|
119
120
|
|
|
120
|
-
removed[lang] = (flatten_hash(translations).keys - base_keys).reject
|
|
121
|
+
removed[lang] = (flatten_hash(translations).keys - base_keys).reject do |key|
|
|
122
|
+
plural_form_of?(key, base_keys) || plural_base_of?(key, base_keys)
|
|
123
|
+
end
|
|
121
124
|
end
|
|
122
125
|
end
|
|
123
126
|
|
|
@@ -140,6 +143,14 @@ module NeetoTranslateCli
|
|
|
140
143
|
PLURAL_BASE_FORMS.any? { |form| base_keys.include?("#{match[:base]}#{match[:separator]}#{form}") }
|
|
141
144
|
end
|
|
142
145
|
|
|
146
|
+
# Languages like ar and ru fall back to the base key (e.g. `item`) for the plural forms they don't have,
|
|
147
|
+
# so it is not treated as removed when en has its plural forms (`item_one`, `items.other`).
|
|
148
|
+
def plural_base_of?(key, base_keys)
|
|
149
|
+
PLURAL_BASE_FORMS.product(PLURAL_SEPARATORS).any? do |form, separator|
|
|
150
|
+
base_keys.include?("#{key}#{separator}#{form}")
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
143
154
|
def load_json(file_path)
|
|
144
155
|
return {} unless File.file?(file_path)
|
|
145
156
|
|
|
@@ -191,6 +191,27 @@ class NeetoTranslateCli::PayloadBuilderTest < Minitest::Test
|
|
|
191
191
|
end
|
|
192
192
|
end
|
|
193
193
|
|
|
194
|
+
def test_removed_keys_keep_base_keys_whose_plural_forms_are_in_en
|
|
195
|
+
with_locale_files do |payload_builder|
|
|
196
|
+
payload = payload_builder.process!
|
|
197
|
+
|
|
198
|
+
refute_includes payload.dig(:frontend, :removed_keys, "es"), "common.item"
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def test_removed_keys_keep_base_keys_whose_nested_plural_forms_are_in_en
|
|
203
|
+
with_locale_files do |payload_builder|
|
|
204
|
+
frontend, backend = payload_builder.options.values_at(:frontend, :backend)
|
|
205
|
+
FileUtils.cp(File.join(frontend, "en.json"), File.join(frontend, "pl.json"))
|
|
206
|
+
pl_yml = { "pl" => { "common" => { "ok" => "OK", "items" => "Elementy" } } }
|
|
207
|
+
File.write(File.join(backend, "pl.yml"), pl_yml.to_yaml)
|
|
208
|
+
|
|
209
|
+
payload = payload_builder.process!
|
|
210
|
+
|
|
211
|
+
refute_includes payload.dig(:backend, :removed_keys, "pl"), "common.items"
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
194
215
|
def test_no_new_changes_is_false_when_keys_were_only_removed
|
|
195
216
|
with_locale_files do |payload_builder|
|
|
196
217
|
payload = payload_builder.process!
|
|
@@ -212,7 +233,7 @@ class NeetoTranslateCli::PayloadBuilderTest < Minitest::Test
|
|
|
212
233
|
en_json = { "common" => { "ok" => "OK", "item_one" => "Item", "item_other" => "Items" } }
|
|
213
234
|
es_json = {
|
|
214
235
|
"common" => { "ok" => "Aceptar", "item_one" => "Elemento", "item_other" => "Elementos",
|
|
215
|
-
"item_many" => "Elementos", "deleted" => "Borrado" },
|
|
236
|
+
"item_many" => "Elementos", "item" => "Elemento", "deleted" => "Borrado" },
|
|
216
237
|
"dashboard" => { "stats" => { "removed" => "Eliminado" } }
|
|
217
238
|
}
|
|
218
239
|
File.write(File.join(frontend, "en.json"), JSON.generate(en_json))
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: neeto-translate-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Neeraj Singh
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: faraday
|
|
@@ -63,7 +62,6 @@ licenses: []
|
|
|
63
62
|
metadata:
|
|
64
63
|
homepage_uri: https://github.com/neetozone/neeto-translate
|
|
65
64
|
source_code_uri: https://github.com/neetozone/neeto-translate
|
|
66
|
-
post_install_message:
|
|
67
65
|
rdoc_options: []
|
|
68
66
|
require_paths:
|
|
69
67
|
- lib
|
|
@@ -78,8 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
78
76
|
- !ruby/object:Gem::Version
|
|
79
77
|
version: '0'
|
|
80
78
|
requirements: []
|
|
81
|
-
rubygems_version:
|
|
82
|
-
signing_key:
|
|
79
|
+
rubygems_version: 4.0.20
|
|
83
80
|
specification_version: 4
|
|
84
81
|
summary: neeto-translate CLI tool to extract translation files and make requests to
|
|
85
82
|
the neeto-translate API
|