translation 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/translation_io/client/base_operation/save_special_yaml_files_step.rb +2 -2
- data/lib/translation_io/client/init_operation/create_yaml_po_files_step.rb +11 -4
- data/lib/translation_io/client/sync_operation/create_yaml_pot_file_step.rb +10 -5
- data/lib/translation_io/config.rb +8 -6
- data/lib/translation_io/flat_hash.rb +1 -1
- data/lib/translation_io/yaml_entry.rb +43 -41
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61d74cef08246ebc2fb57c359957e82ea18c0024
|
4
|
+
data.tar.gz: 935f1c9c13da8244b0ece61700a3a07e76a79161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b3cdfcee4610adce8f938c805ce18316e96871b57e4663297991d1fef4801d3d5e0b640030523d6b35d2c6fdf42299d38bc314cb6be95f6e0d398579b8c6cd
|
7
|
+
data.tar.gz: 67178106997e7b09f293beeaebd487f9e86b5e2babf73518bb8fb4383094d10d8bfa79a5e014ab1c8635893acbb80c2531cbd1fff43672c4d8fcc0bd7c5792c7
|
@@ -21,11 +21,11 @@ module TranslationIO
|
|
21
21
|
end
|
22
22
|
|
23
23
|
all_flat_special_translations = all_flat_translations.select do |key, value|
|
24
|
-
YamlEntry.localization?(key, value)
|
24
|
+
TranslationIO::YamlEntry.localization?(key, value)
|
25
25
|
end
|
26
26
|
|
27
27
|
source_flat_special_translations = all_flat_special_translations.select do |key|
|
28
|
-
YamlEntry.from_locale?(key, @source_locale) && !YamlEntry.ignored?(key)
|
28
|
+
TranslationIO::YamlEntry.from_locale?(key, @source_locale) && !TranslationIO::YamlEntry.ignored?(key)
|
29
29
|
end
|
30
30
|
|
31
31
|
@target_locales.each do |target_locale|
|
@@ -10,19 +10,26 @@ module TranslationIO
|
|
10
10
|
|
11
11
|
def run(params)
|
12
12
|
TranslationIO.info "Importing translations from YAML files."
|
13
|
-
|
13
|
+
|
14
|
+
all_translations = {}
|
14
15
|
|
15
16
|
@yaml_file_paths.each do |file_path|
|
16
17
|
TranslationIO.info file_path, 2, 2
|
17
|
-
|
18
|
+
file_translations = YAML::load(File.read(file_path))
|
19
|
+
|
20
|
+
unless file_translations.blank?
|
21
|
+
all_translations = all_translations.deep_merge(file_translations)
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
25
|
+
all_flat_translations = FlatHash.to_flat_hash(all_translations)
|
26
|
+
|
20
27
|
all_flat_string_translations = all_flat_translations.select do |key, value|
|
21
|
-
YamlEntry.string?(key, value) && !YamlEntry.localization?(key, value)
|
28
|
+
TranslationIO::YamlEntry.string?(key, value) && !TranslationIO::YamlEntry.localization?(key, value)
|
22
29
|
end
|
23
30
|
|
24
31
|
source_flat_string_tanslations = all_flat_string_translations.select do |key|
|
25
|
-
YamlEntry.from_locale?(key, @source_locale) && !YamlEntry.ignored?(key)
|
32
|
+
TranslationIO::YamlEntry.from_locale?(key, @source_locale) && !TranslationIO::YamlEntry.ignored?(key)
|
26
33
|
end
|
27
34
|
|
28
35
|
@target_locales.each do |target_locale|
|
@@ -9,17 +9,22 @@ module TranslationIO
|
|
9
9
|
|
10
10
|
def run(params)
|
11
11
|
TranslationIO.info "Generating POT file from YAML files."
|
12
|
-
|
12
|
+
|
13
|
+
all_translations = {}
|
13
14
|
|
14
15
|
@yaml_file_paths.each do |file_path|
|
15
16
|
TranslationIO.info file_path, 2, 2
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
file_translations = YAML::load(File.read(file_path))
|
18
|
+
|
19
|
+
unless file_translations.blank?
|
20
|
+
all_translations = all_translations.deep_merge(file_translations)
|
21
|
+
end
|
19
22
|
end
|
20
23
|
|
24
|
+
all_flat_translations = FlatHash.to_flat_hash(all_translations)
|
25
|
+
|
21
26
|
source_flat_string_tanslations = all_flat_translations.select do |key, value|
|
22
|
-
YamlEntry.string?(key, value) && YamlEntry.from_locale?(key, @source_locale) && !YamlEntry.ignored?(key) && !YamlEntry.localization?(key, value)
|
27
|
+
TranslationIO::YamlEntry.string?(key, value) && TranslationIO::YamlEntry.from_locale?(key, @source_locale) && !TranslationIO::YamlEntry.ignored?(key) && !TranslationIO::YamlEntry.localization?(key, value)
|
23
28
|
end
|
24
29
|
|
25
30
|
pot_representation = GetText::PO.new
|
@@ -5,14 +5,16 @@ module TranslationIO
|
|
5
5
|
attr_accessor :endpoint
|
6
6
|
attr_accessor :verbose
|
7
7
|
attr_accessor :test
|
8
|
+
attr_accessor :ignored_key_prefixes
|
8
9
|
|
9
10
|
def initialize
|
10
|
-
self.locales_path
|
11
|
-
self.source_locale
|
12
|
-
self.target_locales
|
13
|
-
self.endpoint
|
14
|
-
self.verbose
|
15
|
-
self.test
|
11
|
+
self.locales_path = File.join('config', 'locales', 'gettext')
|
12
|
+
self.source_locale = :en
|
13
|
+
self.target_locales = []
|
14
|
+
self.endpoint = 'https://translation.io/api'
|
15
|
+
self.verbose = 1
|
16
|
+
self.test = false
|
17
|
+
self.ignored_key_prefixes = []
|
16
18
|
end
|
17
19
|
|
18
20
|
def pot_path
|
@@ -1,51 +1,53 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def string?(key, value)
|
24
|
-
key.present? && value.is_a?(String)
|
25
|
-
end
|
1
|
+
module TranslationIO
|
2
|
+
module TranslationIO::YamlEntry
|
3
|
+
|
4
|
+
LOCALIZATION_KEY_PREFIXES = [
|
5
|
+
'date.formats',
|
6
|
+
'date.order',
|
7
|
+
'time.formats',
|
8
|
+
'support.array',
|
9
|
+
'number.format',
|
10
|
+
'number.currency',
|
11
|
+
'number.percentage',
|
12
|
+
'number.precision',
|
13
|
+
'number.human.format',
|
14
|
+
'number.human.storage_units.format',
|
15
|
+
'number.human.decimal_units.format',
|
16
|
+
'number.human.decimal_units.units.unit'
|
17
|
+
]
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def string?(key, value)
|
21
|
+
key.present? && value.is_a?(String)
|
22
|
+
end
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
def from_locale?(key, locale)
|
25
|
+
key.present? && key.start_with?("#{locale}.")
|
26
|
+
end
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
def ignored?(key)
|
29
|
+
key.present? && ignored_key_prefixes.any? { |p| key_without_locale(key).start_with?(p) }
|
30
|
+
end
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
def localization?(key, value)
|
33
|
+
key.present? && (localization_prefix?(key) || (!TranslationIO::YamlEntry.string?(key, value) && !value.nil?))
|
34
|
+
end
|
38
35
|
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
def localization_prefix?(key)
|
37
|
+
LOCALIZATION_KEY_PREFIXES.any? do |prefix|
|
38
|
+
key_without_locale(key).start_with?(prefix)
|
39
|
+
end
|
42
40
|
end
|
43
|
-
end
|
44
41
|
|
45
|
-
|
42
|
+
private
|
46
43
|
|
47
|
-
|
48
|
-
|
44
|
+
def ignored_key_prefixes
|
45
|
+
['faker.'] + TranslationIO.config.ignored_key_prefixes
|
46
|
+
end
|
47
|
+
|
48
|
+
def key_without_locale(key)
|
49
|
+
key.split('.', 2).last
|
50
|
+
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: translation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurelien Malisart
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gettext
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.2.
|
122
|
+
rubygems_version: 2.2.2
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Rails translation made _("simple") with YAML and GetText.
|