translation 0.9.7 → 1.0.0
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/lib/translation_io/client/base_operation/save_special_yaml_files_step.rb +2 -6
- data/lib/translation_io/client/init_operation/update_pot_file_step.rb +9 -2
- data/lib/translation_io/client/init_operation.rb +1 -1
- data/lib/translation_io/client/sync_operation/update_and_collect_pot_file_step.rb +7 -1
- data/lib/translation_io/config.rb +12 -0
- data/lib/translation_io/controller.rb +15 -5
- data/lib/translation_io/flat_hash.rb +3 -0
- data/lib/translation_io/yaml_entry.rb +1 -1
- metadata +17 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a79514a84e9a61c0b950fb4225a613e906cdeb80
|
4
|
+
data.tar.gz: bab34ec6a4ffb1b3f759640eccea15090a5261d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97ae9198f3b4dd04d6b4d22c7642f8c8fb6a283586637a9c6088fa2b0c0223f7324fd5e3098689bd633e3c0447764f5b36b8976ad8d137a74e33b6ad4c81819f
|
7
|
+
data.tar.gz: abdbb1ac3a7bd00f85a59ea693c89efc42d00a32ce047fb8355834e95ec9c0ed647a497962c3c551b1bbadf998e7d8d37a8a0dddd8e1989f61ac1050f2c586b7
|
@@ -24,20 +24,16 @@ module TranslationIO
|
|
24
24
|
TranslationIO::YamlEntry.localization?(key, value)
|
25
25
|
end
|
26
26
|
|
27
|
-
source_flat_special_translations = all_flat_special_translations.select do |key|
|
28
|
-
TranslationIO::YamlEntry.from_locale?(key, @source_locale) && !TranslationIO::YamlEntry.ignored?(key)
|
29
|
-
end
|
30
|
-
|
31
27
|
@target_locales.each do |target_locale|
|
32
28
|
yaml_path = File.join(@yaml_locales_path, "localization.#{target_locale}.yml")
|
33
29
|
|
34
30
|
TranslationIO.info yaml_path, 2, 2
|
35
31
|
|
36
|
-
|
32
|
+
target_flat_special_translations = all_flat_special_translations.select do |key|
|
37
33
|
TranslationIO::YamlEntry.from_locale?(key, target_locale) && !TranslationIO::YamlEntry.ignored?(key)
|
38
34
|
end
|
39
35
|
|
40
|
-
yaml_data = YAMLConversion.get_yaml_data_from_flat_translations(
|
36
|
+
yaml_data = YAMLConversion.get_yaml_data_from_flat_translations(target_flat_special_translations)
|
41
37
|
|
42
38
|
File.open(yaml_path, 'wb') do |file|
|
43
39
|
file.write(yaml_data)
|
@@ -7,10 +7,17 @@ module TranslationIO
|
|
7
7
|
@source_files = source_files
|
8
8
|
end
|
9
9
|
|
10
|
-
def run
|
10
|
+
def run(params)
|
11
11
|
TranslationIO.info "Updating POT file."
|
12
12
|
FileUtils.mkdir_p(File.dirname(@pot_path))
|
13
|
-
GetText::Tools::XGetText.run(*@source_files, '-o', @pot_path,
|
13
|
+
GetText::Tools::XGetText.run(*@source_files, '-o', @pot_path,
|
14
|
+
'--msgid-bugs-address', TranslationIO.config.pot_msgid_bugs_address,
|
15
|
+
'--package-name', TranslationIO.config.pot_package_name,
|
16
|
+
'--package-version', TranslationIO.config.pot_package_version,
|
17
|
+
'--copyright-holder', TranslationIO.config.pot_copyright_holder,
|
18
|
+
'--copyright-year', TranslationIO.config.pot_copyright_year.to_s)
|
19
|
+
|
20
|
+
params["pot_data"] = File.read(@pot_path)
|
14
21
|
end
|
15
22
|
end
|
16
23
|
end
|
@@ -23,7 +23,7 @@ module TranslationIO
|
|
23
23
|
yaml_locales_path = config.yaml_locales_path
|
24
24
|
yaml_file_paths = config.yaml_file_paths
|
25
25
|
|
26
|
-
UpdatePotFileStep.new(pot_path, source_files).run
|
26
|
+
UpdatePotFileStep.new(pot_path, source_files).run(params)
|
27
27
|
UpdateAndCollectPoFilesStep.new(target_locales, pot_path, locales_path).run(params)
|
28
28
|
CreateYamlPoFilesStep.new(source_locale, target_locales, yaml_file_paths).run(params)
|
29
29
|
|
@@ -9,7 +9,13 @@ module TranslationIO
|
|
9
9
|
|
10
10
|
def run(params)
|
11
11
|
TranslationIO.info "Updating POT file."
|
12
|
-
GetText::Tools::XGetText.run(*@source_files, '-o', @pot_path
|
12
|
+
GetText::Tools::XGetText.run(*@source_files, '-o', @pot_path,
|
13
|
+
'--msgid-bugs-address', TranslationIO.config.pot_msgid_bugs_address,
|
14
|
+
'--package-name', TranslationIO.config.pot_package_name,
|
15
|
+
'--package-version', TranslationIO.config.pot_package_version,
|
16
|
+
'--copyright-holder', TranslationIO.config.pot_copyright_holder,
|
17
|
+
'--copyright-year', TranslationIO.config.pot_copyright_year.to_s)
|
18
|
+
|
13
19
|
params['pot_data'] = File.read(@pot_path)
|
14
20
|
end
|
15
21
|
end
|
@@ -9,6 +9,12 @@ module TranslationIO
|
|
9
9
|
attr_accessor :localization_key_prefixes
|
10
10
|
attr_accessor :charset
|
11
11
|
|
12
|
+
attr_accessor :pot_msgid_bugs_address
|
13
|
+
attr_accessor :pot_package_name
|
14
|
+
attr_accessor :pot_package_version
|
15
|
+
attr_accessor :pot_copyright_holder
|
16
|
+
attr_accessor :pot_copyright_year
|
17
|
+
|
12
18
|
def initialize
|
13
19
|
self.locales_path = File.join('config', 'locales', 'gettext')
|
14
20
|
self.source_locale = :en
|
@@ -19,6 +25,12 @@ module TranslationIO
|
|
19
25
|
self.ignored_key_prefixes = []
|
20
26
|
self.localization_key_prefixes = []
|
21
27
|
self.charset = 'UTF-8'
|
28
|
+
|
29
|
+
self.pot_msgid_bugs_address = 'contact@translation.io'
|
30
|
+
self.pot_package_name = File.basename(Dir.pwd)
|
31
|
+
self.pot_package_version = '1.0'
|
32
|
+
self.pot_copyright_holder = File.basename(Dir.pwd)
|
33
|
+
self.pot_copyright_year = Date.today.year
|
22
34
|
end
|
23
35
|
|
24
36
|
def pot_path
|
@@ -1,17 +1,27 @@
|
|
1
1
|
module TranslationIO
|
2
2
|
module Controller
|
3
3
|
def set_locale
|
4
|
-
requested_locale = params[:locale]
|
5
|
-
session[:locale]
|
6
|
-
cookies[:locale]
|
7
|
-
request.env['HTTP_ACCEPT_LANGUAGE'] ||
|
4
|
+
requested_locale = params[:locale] ||
|
5
|
+
session[:locale] ||
|
6
|
+
cookies[:locale] ||
|
7
|
+
extract_browser_locale(request.env['HTTP_ACCEPT_LANGUAGE']) ||
|
8
8
|
I18n.default_locale
|
9
9
|
|
10
10
|
if I18n.available_locales.include?(requested_locale.to_sym)
|
11
11
|
session[:locale] = requested_locale
|
12
12
|
I18n.locale = requested_locale
|
13
13
|
else
|
14
|
-
|
14
|
+
if respond_to?(:root_path)
|
15
|
+
redirect_to root_path(:locale => I18n.default_locale)
|
16
|
+
else
|
17
|
+
redirect_to "/?locale=#{I18n.default_locale}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def extract_browser_locale(http_accept_language)
|
23
|
+
http_accept_language.to_s.scan(/[a-z]{2}(?:-[A-Z]{2})?/).detect do |candidate|
|
24
|
+
I18n.available_locales.include?(candidate.to_sym)
|
15
25
|
end
|
16
26
|
end
|
17
27
|
end
|
@@ -137,6 +137,9 @@ module TranslationIO
|
|
137
137
|
if h.is_a?(Hash)
|
138
138
|
h.keys.each do |key|
|
139
139
|
if [TrueClass, FalseClass].include?(key.class)
|
140
|
+
# # This warning is commented because Rails admin uses bad keys: https://github.com/sferik/rails_admin/blob/master/config/locales/rails_admin.en.yml
|
141
|
+
# TranslationIO.info("Warning - We found some YAML protected keys in your project, they will not be synchronized: 'yes', 'no', 'y', 'n', 'on', 'off', 'true', 'false'")
|
142
|
+
# TranslationIO.info(h.inspect)
|
140
143
|
h.delete(key)
|
141
144
|
else
|
142
145
|
remove_reserved_keys!(h[key])
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurelien Malisart
|
@@ -9,12 +9,15 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gettext
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '3.1'
|
18
21
|
- - ">="
|
19
22
|
- !ruby/object:Gem::Version
|
20
23
|
version: 3.1.2
|
@@ -22,6 +25,9 @@ dependencies:
|
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
28
|
+
- - "~>"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '3.1'
|
25
31
|
- - ">="
|
26
32
|
- !ruby/object:Gem::Version
|
27
33
|
version: 3.1.2
|
@@ -29,45 +35,47 @@ dependencies:
|
|
29
35
|
name: rake
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
31
37
|
requirements:
|
32
|
-
- - "
|
38
|
+
- - "~>"
|
33
39
|
- !ruby/object:Gem::Version
|
34
40
|
version: '0'
|
35
41
|
type: :development
|
36
42
|
prerelease: false
|
37
43
|
version_requirements: !ruby/object:Gem::Requirement
|
38
44
|
requirements:
|
39
|
-
- - "
|
45
|
+
- - "~>"
|
40
46
|
- !ruby/object:Gem::Version
|
41
47
|
version: '0'
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
49
|
name: rspec
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
45
51
|
requirements:
|
46
|
-
- - "
|
52
|
+
- - "~>"
|
47
53
|
- !ruby/object:Gem::Version
|
48
54
|
version: '0'
|
49
55
|
type: :development
|
50
56
|
prerelease: false
|
51
57
|
version_requirements: !ruby/object:Gem::Requirement
|
52
58
|
requirements:
|
53
|
-
- - "
|
59
|
+
- - "~>"
|
54
60
|
- !ruby/object:Gem::Version
|
55
61
|
version: '0'
|
56
62
|
- !ruby/object:Gem::Dependency
|
57
63
|
name: rails
|
58
64
|
requirement: !ruby/object:Gem::Requirement
|
59
65
|
requirements:
|
60
|
-
- - "
|
66
|
+
- - "~>"
|
61
67
|
- !ruby/object:Gem::Version
|
62
68
|
version: '0'
|
63
69
|
type: :development
|
64
70
|
prerelease: false
|
65
71
|
version_requirements: !ruby/object:Gem::Requirement
|
66
72
|
requirements:
|
67
|
-
- - "
|
73
|
+
- - "~>"
|
68
74
|
- !ruby/object:Gem::Version
|
69
75
|
version: '0'
|
70
|
-
description:
|
76
|
+
description: Translation.io allows you to localize Rails applications using either
|
77
|
+
t(".keys") or _("free text"). Just type "rake translation:sync" to synchronize with
|
78
|
+
your translators, and let them translate online with our interface.
|
71
79
|
email: contact@translation.io
|
72
80
|
executables: []
|
73
81
|
extensions: []
|