translation 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/translation.rb +9 -9
- data/lib/translation_io/client.rb +26 -0
- data/lib/{translation → translation_io}/client/base_operation.rb +11 -11
- data/lib/{translation → translation_io}/client/base_operation/create_new_mo_files_step.rb +3 -3
- data/lib/{translation → translation_io}/client/base_operation/dump_haml_gettext_keys_step.rb +4 -4
- data/lib/{translation → translation_io}/client/base_operation/dump_slim_gettext_keys_step.rb +4 -4
- data/lib/{translation → translation_io}/client/base_operation/save_new_po_files_step.rb +3 -3
- data/lib/{translation → translation_io}/client/base_operation/save_new_yaml_files_step.rb +7 -3
- data/lib/{translation → translation_io}/client/base_operation/save_special_yaml_files_step.rb +3 -3
- data/lib/{translation → translation_io}/client/init_operation.rb +10 -10
- data/lib/{translation → translation_io}/client/init_operation/cleanup_yaml_files_step.rb +5 -5
- data/lib/{translation → translation_io}/client/init_operation/create_yaml_po_files_step.rb +4 -4
- data/lib/{translation → translation_io}/client/init_operation/update_and_collect_po_files_step.rb +3 -3
- data/lib/{translation → translation_io}/client/init_operation/update_pot_file_step.rb +2 -2
- data/lib/{translation → translation_io}/client/sync_operation.rb +7 -7
- data/lib/{translation → translation_io}/client/sync_operation/create_yaml_pot_file_step.rb +3 -3
- data/lib/{translation → translation_io}/client/sync_operation/update_and_collect_pot_file_step.rb +2 -2
- data/lib/{translation → translation_io}/config.rb +1 -1
- data/lib/{translation → translation_io}/controller.rb +1 -1
- data/lib/{translation → translation_io}/flat_hash.rb +1 -1
- data/lib/{translation → translation_io}/railtie.rb +3 -3
- data/lib/translation_io/tasks.rb +31 -0
- data/lib/{translation → translation_io}/yaml_conversion.rb +2 -2
- metadata +24 -25
- data/lib/translation/client.rb +0 -27
- data/lib/translation/client/purge_operation.rb +0 -13
- data/lib/translation/tasks.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb09a74f74ac00b8329153da4a49738c9d5dfa6d
|
4
|
+
data.tar.gz: f7c44831d5941ba238b67912c04fda320193ecd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e583d94964346af1eb8ef7744d39ece151dea744ddaec97e58f7b37f7069300399832296c783db2c53ff03643a18e5afbb3f5a4dbdb3a4c1633274d96b403ce0
|
7
|
+
data.tar.gz: 49a1c002021da3bbbeb3aa9352a646289ba600db027d5dff1faf6d1b811b6bd7ccace1158feb6a60b96b25d2315b2b57e1224f886bb8c911d820026523677fe5
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# gem for [Rails
|
1
|
+
# gem for [Rails TranslationIO](http://rails.translation.io)
|
2
2
|
|
3
3
|
## Description
|
4
4
|
|
5
|
-
Add this gem to your [Rails](http://rubyonrails.org) app to translate it with [Rails
|
5
|
+
Add this gem to your [Rails](http://rubyonrails.org) app to translate it with [Rails TranslationIO](http://rails.translation.io).
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -21,7 +21,7 @@ And finish by inititalizing your translation project with :
|
|
21
21
|
|
22
22
|
## Synchronization
|
23
23
|
|
24
|
-
To get new translations from Rails
|
24
|
+
To get new translations from Rails TranslationIO and to send new translatable strings, simply run :
|
25
25
|
|
26
26
|
bundle exec rake translation:sync
|
27
27
|
|
@@ -33,7 +33,7 @@ If you need to remove unused keys taking the current branch as reference :
|
|
33
33
|
|
34
34
|
Note that this operation will also perform a sync at the same time.
|
35
35
|
|
36
|
-
Warning : all keys that are not present in the current branch will be **permanently deleted both on Rails
|
36
|
+
Warning : all keys that are not present in the current branch will be **permanently deleted both on Rails TranslationIO and in your app**.
|
37
37
|
|
38
38
|
## Tests
|
39
39
|
|
data/lib/translation.rb
CHANGED
@@ -6,7 +6,7 @@ require 'gettext/po_parser'
|
|
6
6
|
require 'gettext/tools'
|
7
7
|
require 'gettext/text_domain_manager'
|
8
8
|
|
9
|
-
module
|
9
|
+
module TranslationIO
|
10
10
|
GETTEXT_METHODS = [
|
11
11
|
:_, :n_, :p_, :s_, :np_, :ns_, :N_, :Nn,
|
12
12
|
:gettext, :sgettext, :ngettext, :nsgettext, :pgettext, :npgettext
|
@@ -16,15 +16,15 @@ module Translation
|
|
16
16
|
SOURCE_FILES_PATTERN = '**/*.{rb,erb,html.erb,xml.erb}'
|
17
17
|
end
|
18
18
|
|
19
|
-
require '
|
20
|
-
require '
|
21
|
-
require '
|
22
|
-
require '
|
23
|
-
require '
|
19
|
+
require 'translation_io/config'
|
20
|
+
require 'translation_io/railtie'
|
21
|
+
require 'translation_io/client'
|
22
|
+
require 'translation_io/flat_hash'
|
23
|
+
require 'translation_io/yaml_conversion'
|
24
24
|
|
25
|
-
require '
|
25
|
+
require 'translation_io/controller'
|
26
26
|
|
27
|
-
module
|
27
|
+
module TranslationIO
|
28
28
|
module Proxy
|
29
29
|
include GetText
|
30
30
|
end
|
@@ -55,7 +55,7 @@ module Translation
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def pot_path
|
58
|
-
File.join(
|
58
|
+
File.join(TranslationIO.config.locales_path, "#{TEXT_DOMAIN}.pot")
|
59
59
|
end
|
60
60
|
|
61
61
|
def info(message, level = 0, verbose_level = 0)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'translation_io/client/base_operation'
|
2
|
+
require 'translation_io/client/init_operation'
|
3
|
+
require 'translation_io/client/sync_operation'
|
4
|
+
|
5
|
+
module TranslationIO
|
6
|
+
class Client
|
7
|
+
attr_reader :api_key, :endpoint
|
8
|
+
|
9
|
+
def initialize(api_key, endpoint)
|
10
|
+
@api_key = api_key
|
11
|
+
@endpoint = endpoint
|
12
|
+
end
|
13
|
+
|
14
|
+
def init
|
15
|
+
TranslationIO::Client::InitOperation.new(self).run
|
16
|
+
end
|
17
|
+
|
18
|
+
def sync
|
19
|
+
TranslationIO::Client::SyncOperation.new(self).run
|
20
|
+
end
|
21
|
+
|
22
|
+
def purge
|
23
|
+
TranslationIO::Client::SyncOperation.new(self).run(true)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
|
8
|
-
module
|
1
|
+
require 'translation_io/client/base_operation/save_new_po_files_step'
|
2
|
+
require 'translation_io/client/base_operation/create_new_mo_files_step'
|
3
|
+
require 'translation_io/client/base_operation/save_new_yaml_files_step'
|
4
|
+
require 'translation_io/client/base_operation/save_special_yaml_files_step'
|
5
|
+
require 'translation_io/client/base_operation/dump_haml_gettext_keys_step'
|
6
|
+
require 'translation_io/client/base_operation/dump_slim_gettext_keys_step'
|
7
|
+
|
8
|
+
module TranslationIO
|
9
9
|
class Client
|
10
10
|
class BaseOperation
|
11
11
|
attr_accessor :client, :params
|
12
12
|
|
13
|
-
GETTEXT_ENTRY_RE = Regexp.new('(?:' +
|
13
|
+
GETTEXT_ENTRY_RE = Regexp.new('(?:' + TranslationIO::GETTEXT_METHODS.join('|') + ')\([^)]+\)?\)')
|
14
14
|
|
15
15
|
def initialize(client, perform_real_requests = true)
|
16
16
|
@client = client
|
17
17
|
@params = {
|
18
|
-
'gem_version' =>
|
19
|
-
'target_languages[]' =>
|
18
|
+
'gem_version' => TranslationIO.version,
|
19
|
+
'target_languages[]' => TranslationIO.config.target_locales.map(&:to_s)
|
20
20
|
}
|
21
21
|
end
|
22
22
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class BaseOperation
|
4
4
|
class CreateNewMoFilesStep
|
@@ -7,11 +7,11 @@ module Translation
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def run
|
10
|
-
|
10
|
+
TranslationIO.info "Creating new MO files."
|
11
11
|
|
12
12
|
Dir["#{@locales_path}/*/#{TEXT_DOMAIN}.po"].each do |po_path|
|
13
13
|
mo_path = "#{File.dirname(po_path)}/LC_MESSAGES/app.mo"
|
14
|
-
|
14
|
+
TranslationIO.info mo_path, 2, 2
|
15
15
|
FileUtils.mkdir_p(File.dirname(mo_path))
|
16
16
|
GetText::Tools::MsgFmt.run(po_path, '-o', mo_path)
|
17
17
|
end
|
data/lib/{translation → translation_io}/client/base_operation/dump_haml_gettext_keys_step.rb
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class BaseOperation
|
4
4
|
class DumpHamlGettextKeysStep
|
@@ -8,7 +8,7 @@ module Translation
|
|
8
8
|
|
9
9
|
def run
|
10
10
|
if @haml_source_files.any? && defined?(Haml)
|
11
|
-
|
11
|
+
TranslationIO.info "Extracting Gettext entries from HAML files."
|
12
12
|
|
13
13
|
File.open(File.join('tmp', 'translation-haml-gettext.rb'), 'w') do |file|
|
14
14
|
extracted_gettext_entries.each do |entry|
|
@@ -24,7 +24,7 @@ module Translation
|
|
24
24
|
entries = []
|
25
25
|
|
26
26
|
@haml_source_files.each do |haml_file_path|
|
27
|
-
|
27
|
+
TranslationIO.info haml_file_path, 2, 2
|
28
28
|
|
29
29
|
haml_data = File.read(haml_file_path)
|
30
30
|
ruby_data = Haml::Engine.new(haml_data).precompiled
|
@@ -34,7 +34,7 @@ module Translation
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
TranslationIO.info "#{entries.size} entries found", 2, 2
|
38
38
|
|
39
39
|
entries
|
40
40
|
end
|
data/lib/{translation → translation_io}/client/base_operation/dump_slim_gettext_keys_step.rb
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class BaseOperation
|
4
4
|
class DumpSlimGettextKeysStep
|
@@ -8,7 +8,7 @@ module Translation
|
|
8
8
|
|
9
9
|
def run
|
10
10
|
if @slim_source_files.any? && defined?(Slim)
|
11
|
-
|
11
|
+
TranslationIO.info "Extracting Gettext entries from SLIM files."
|
12
12
|
|
13
13
|
File.open(File.join('tmp', 'translation-slim-gettext.rb'), 'w') do |file|
|
14
14
|
extracted_gettext_entries.each do |entry|
|
@@ -24,7 +24,7 @@ module Translation
|
|
24
24
|
entries = []
|
25
25
|
|
26
26
|
@slim_source_files.each do |slim_file_path|
|
27
|
-
|
27
|
+
TranslationIO.info slim_file_path, 2, 2
|
28
28
|
|
29
29
|
ruby_data = Slim::Template.new(slim_file_path, {}).precompiled_template
|
30
30
|
|
@@ -33,7 +33,7 @@ module Translation
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
TranslationIO.info "#{entries.size} entries found", 2, 2
|
37
37
|
|
38
38
|
entries
|
39
39
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class BaseOperation
|
4
4
|
class SaveNewPoFilesStep
|
@@ -9,13 +9,13 @@ module Translation
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def run
|
12
|
-
|
12
|
+
TranslationIO.info "Saving new PO files."
|
13
13
|
|
14
14
|
@target_locales.each do |target_locale|
|
15
15
|
if @parsed_response.has_key?("po_data_#{target_locale}")
|
16
16
|
po_path = File.join(@locales_path, target_locale.to_s.gsub('-', '_'), "#{TEXT_DOMAIN}.po")
|
17
17
|
FileUtils.mkdir_p(File.dirname(po_path))
|
18
|
-
|
18
|
+
TranslationIO.info po_path, 2, 2
|
19
19
|
|
20
20
|
File.open(po_path, 'wb') do |file|
|
21
21
|
file.write(@parsed_response["po_data_#{target_locale}"])
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class BaseOperation
|
4
4
|
class SaveNewYamlFilesStep
|
@@ -9,18 +9,22 @@ module Translation
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def run
|
12
|
-
|
12
|
+
TranslationIO.info "Saving new translation YAML files."
|
13
13
|
|
14
14
|
@target_locales.each do |target_locale|
|
15
15
|
if @parsed_response.has_key?("yaml_po_data_#{target_locale}")
|
16
16
|
FileUtils.mkdir_p(@yaml_locales_path)
|
17
17
|
yaml_path = File.join(@yaml_locales_path, "translation.#{target_locale}.yml")
|
18
|
-
|
18
|
+
TranslationIO.info yaml_path, 2, 2
|
19
19
|
yaml_data = YAMLConversion.get_yaml_data_from_po_data(@parsed_response["yaml_po_data_#{target_locale}"], target_locale)
|
20
20
|
|
21
21
|
top_comment = <<EOS
|
22
22
|
# WARNING. THIS FILE WAS AUTO-GENERATED BY THE TRANSLATION GEM.
|
23
23
|
# IF YOU UPDATE IT, YOUR CHANGES WILL BE LOST AT THE NEXT SYNC.
|
24
|
+
#
|
25
|
+
# To update this file, use this translation interface :
|
26
|
+
# #{@parsed_response['project_url']}/#{target_locale}
|
27
|
+
#
|
24
28
|
EOS
|
25
29
|
|
26
30
|
File.open(yaml_path, 'wb') do |file|
|
data/lib/{translation → translation_io}/client/base_operation/save_special_yaml_files_step.rb
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class BaseOperation
|
4
4
|
class SaveSpecialYamlFilesStep
|
@@ -11,7 +11,7 @@ module Translation
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def run
|
14
|
-
|
14
|
+
TranslationIO.info "Saving new localization YAML files (with non-string values)."
|
15
15
|
all_flat_translations = {}
|
16
16
|
|
17
17
|
@yaml_file_paths.each do |file_path|
|
@@ -31,7 +31,7 @@ module Translation
|
|
31
31
|
@target_locales.each do |target_locale|
|
32
32
|
yaml_path = File.join(@yaml_locales_path, "localization.#{target_locale}.yml")
|
33
33
|
|
34
|
-
|
34
|
+
TranslationIO.info yaml_path, 2, 2
|
35
35
|
flat_translations = {}
|
36
36
|
|
37
37
|
source_flat_special_translations.each_pair do |key, value|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
1
|
+
require 'translation_io/client/init_operation/update_pot_file_step'
|
2
|
+
require 'translation_io/client/init_operation/update_and_collect_po_files_step'
|
3
|
+
require 'translation_io/client/init_operation/create_yaml_po_files_step'
|
4
|
+
require 'translation_io/client/init_operation/cleanup_yaml_files_step'
|
5
5
|
|
6
|
-
module
|
6
|
+
module TranslationIO
|
7
7
|
class Client
|
8
8
|
class InitOperation < BaseOperation
|
9
9
|
def run
|
@@ -14,10 +14,10 @@ module Translation
|
|
14
14
|
BaseOperation::DumpSlimGettextKeysStep.new(slim_source_files).run
|
15
15
|
|
16
16
|
source_files = Dir[SOURCE_FILES_PATTERN]
|
17
|
-
pot_path =
|
18
|
-
source_locale =
|
19
|
-
target_locales =
|
20
|
-
locales_path =
|
17
|
+
pot_path = TranslationIO.pot_path
|
18
|
+
source_locale = TranslationIO.config.source_locale
|
19
|
+
target_locales = TranslationIO.config.target_locales
|
20
|
+
locales_path = TranslationIO.config.locales_path
|
21
21
|
yaml_locales_path = 'config/locales'
|
22
22
|
yaml_file_paths = I18n.load_path
|
23
23
|
|
@@ -25,7 +25,7 @@ module Translation
|
|
25
25
|
UpdateAndCollectPoFilesStep.new(target_locales, pot_path, locales_path).run(params)
|
26
26
|
CreateYamlPoFilesStep.new(source_locale, target_locales, yaml_file_paths).run(params)
|
27
27
|
|
28
|
-
|
28
|
+
TranslationIO.info "Sending data to server"
|
29
29
|
uri = URI("http://#{client.endpoint}/projects/#{client.api_key}/init")
|
30
30
|
parsed_response = perform_request(uri, params)
|
31
31
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class InitOperation < BaseOperation
|
4
4
|
class CleanupYamlFilesStep
|
@@ -27,12 +27,12 @@ module Translation
|
|
27
27
|
new_content_hash = content_hash.keep_if { |k| k.to_s == @source_locale.to_s }
|
28
28
|
|
29
29
|
if new_content_hash.keys.any?
|
30
|
-
|
30
|
+
TranslationIO.info "Rewriting #{locale_file_path}", 2, 2
|
31
31
|
File.open(locale_file_path, 'wb') do |file|
|
32
32
|
file.write(new_content_hash.to_yaml)
|
33
33
|
end
|
34
34
|
else
|
35
|
-
|
35
|
+
TranslationIO.info "Removing #{locale_file_path}", 2, 2
|
36
36
|
FileUtils.rm(locale_file_path)
|
37
37
|
end
|
38
38
|
end
|
@@ -42,8 +42,8 @@ module Translation
|
|
42
42
|
private
|
43
43
|
|
44
44
|
def locale_file_path_in_project?(locale_file_path)
|
45
|
-
|
46
|
-
|
45
|
+
TranslationIO.normalize_path(locale_file_path).start_with?(
|
46
|
+
TranslationIO.normalize_path(@yaml_locales_path)
|
47
47
|
)
|
48
48
|
end
|
49
49
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class InitOperation < BaseOperation
|
4
4
|
class CreateYamlPoFilesStep
|
@@ -9,11 +9,11 @@ module Translation
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def run(params)
|
12
|
-
|
12
|
+
TranslationIO.info "Importing translations from YAML files."
|
13
13
|
all_flat_translations = {}
|
14
14
|
|
15
15
|
@yaml_file_paths.each do |file_path|
|
16
|
-
|
16
|
+
TranslationIO.info file_path, 2, 2
|
17
17
|
all_flat_translations.merge!(YAMLConversion.get_flat_translations_for_yaml_file(file_path))
|
18
18
|
end
|
19
19
|
|
@@ -29,7 +29,7 @@ module Translation
|
|
29
29
|
po_representation = GetText::PO.new
|
30
30
|
|
31
31
|
source_flat_string_tanslations.each_pair do |key, value|
|
32
|
-
target_key = key.gsub(/\A#{
|
32
|
+
target_key = key.gsub(/\A#{TranslationIO.config.source_locale}\./, "#{target_locale}.")
|
33
33
|
msgid = value
|
34
34
|
msgstr = all_flat_string_translations[target_key]
|
35
35
|
|
data/lib/{translation → translation_io}/client/init_operation/update_and_collect_po_files_step.rb
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class InitOperation < BaseOperation
|
4
4
|
class UpdateAndCollectPoFilesStep
|
@@ -9,11 +9,11 @@ module Translation
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def run(params)
|
12
|
-
|
12
|
+
TranslationIO.info "Updating PO files."
|
13
13
|
|
14
14
|
@target_locales.each do |target_locale|
|
15
15
|
po_path = "#{@locales_path}/#{target_locale.gsub('-', '_')}/#{TEXT_DOMAIN}.po"
|
16
|
-
|
16
|
+
TranslationIO.info po_path, 2, 2
|
17
17
|
|
18
18
|
if File.exist?(po_path)
|
19
19
|
GetText::Tools::MsgMerge.run(po_path, @pot_path, '-o', po_path, '--no-fuzzy-matching', '--no-obsolete-entries')
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class InitOperation < BaseOperation
|
4
4
|
class UpdatePotFileStep
|
@@ -8,7 +8,7 @@ module Translation
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run
|
11
|
-
|
11
|
+
TranslationIO.info "Updating POT file."
|
12
12
|
FileUtils.mkdir_p(File.dirname(@pot_path))
|
13
13
|
GetText::Tools::XGetText.run(*@source_files, '-o', @pot_path, '--msgid-bugs-address', 'contact@translation.io',)
|
14
14
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'translation_io/client/sync_operation/update_and_collect_pot_file_step'
|
2
|
+
require 'translation_io/client/sync_operation/create_yaml_pot_file_step'
|
3
3
|
|
4
|
-
module
|
4
|
+
module TranslationIO
|
5
5
|
class Client
|
6
6
|
class SyncOperation < BaseOperation
|
7
7
|
def run(purge = false)
|
@@ -12,10 +12,10 @@ module Translation
|
|
12
12
|
BaseOperation::DumpSlimGettextKeysStep.new(slim_source_files).run
|
13
13
|
|
14
14
|
source_files = Dir[SOURCE_FILES_PATTERN]
|
15
|
-
pot_path =
|
16
|
-
source_locale =
|
17
|
-
target_locales =
|
18
|
-
locales_path =
|
15
|
+
pot_path = TranslationIO.pot_path
|
16
|
+
source_locale = TranslationIO.config.source_locale
|
17
|
+
target_locales = TranslationIO.config.target_locales
|
18
|
+
locales_path = TranslationIO.config.locales_path
|
19
19
|
yaml_locales_path = 'config/locales'
|
20
20
|
yaml_file_paths = I18n.load_path
|
21
21
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class SyncOperation < BaseOperation
|
4
4
|
class CreateYamlPotFileStep
|
@@ -8,11 +8,11 @@ module Translation
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run(params)
|
11
|
-
|
11
|
+
TranslationIO.info "Generating POT file from YAML files."
|
12
12
|
all_flat_translations = {}
|
13
13
|
|
14
14
|
@yaml_file_paths.each do |file_path|
|
15
|
-
|
15
|
+
TranslationIO.info file_path, 2, 2
|
16
16
|
all_flat_translations.merge!(
|
17
17
|
YAMLConversion.get_flat_translations_for_yaml_file(file_path)
|
18
18
|
)
|
data/lib/{translation → translation_io}/client/sync_operation/update_and_collect_pot_file_step.rb
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
class Client
|
3
3
|
class SyncOperation < BaseOperation
|
4
4
|
class UpdateAndCollectPotFileStep
|
@@ -8,7 +8,7 @@ module Translation
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run(params)
|
11
|
-
|
11
|
+
TranslationIO.info "Updating POT file."
|
12
12
|
GetText::Tools::XGetText.run(*@source_files, '-o', @pot_path)
|
13
13
|
params['pot_data'] = File.read(@pot_path)
|
14
14
|
end
|
@@ -5,14 +5,14 @@ require 'gettext'
|
|
5
5
|
require 'gettext/po'
|
6
6
|
require 'gettext/po_parser'
|
7
7
|
|
8
|
-
module
|
8
|
+
module TranslationIO
|
9
9
|
class Railtie < Rails::Railtie
|
10
10
|
rake_tasks do
|
11
|
-
require '
|
11
|
+
require 'translation_io/tasks'
|
12
12
|
end
|
13
13
|
|
14
14
|
initializer 'translation.rails_extensions' do
|
15
|
-
ActionController::Base.send(:include,
|
15
|
+
ActionController::Base.send(:include, TranslationIO::Controller)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'gettext/tools'
|
2
|
+
|
3
|
+
namespace :translation do
|
4
|
+
task :config => :environment do
|
5
|
+
puts TranslationIO.config
|
6
|
+
end
|
7
|
+
|
8
|
+
task :init => :environment do
|
9
|
+
if TranslationIO.client
|
10
|
+
TranslationIO.client.init
|
11
|
+
else
|
12
|
+
TranslationIO.info "[Error] Client cannot be built. Did you set up the initializer?"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
task :sync => :environment do
|
17
|
+
if TranslationIO.client
|
18
|
+
TranslationIO.client.sync
|
19
|
+
else
|
20
|
+
TranslationIO.info "[Error] Client cannot be built. Did you set up the initializer?"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
task :purge => :environment do
|
25
|
+
if TranslationIO.client
|
26
|
+
TranslationIO.client.purge
|
27
|
+
else
|
28
|
+
TranslationIO.info "[Error] Client cannot be built. Did you set up the initializer?"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module TranslationIO
|
2
2
|
module YAMLConversion
|
3
3
|
class << self
|
4
4
|
|
5
5
|
def get_pot_data_from_yaml(source_locale = nil, yaml_file_paths = nil)
|
6
|
-
source_locale =
|
6
|
+
source_locale = TranslationIO.config.source_locale if source_locale.blank?
|
7
7
|
yaml_file_paths = I18n.load_path if yaml_file_paths.nil?
|
8
8
|
|
9
9
|
source_translations = YAMLConversion.get_flat_translations_for_locale(source_locale, yaml_file_paths)
|
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: '0.4'
|
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-07-
|
12
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gettext
|
@@ -101,30 +101,29 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- lib/translation/client/base_operation/create_new_mo_files_step.rb
|
105
|
-
- lib/translation/client/base_operation/dump_haml_gettext_keys_step.rb
|
106
|
-
- lib/translation/client/base_operation/dump_slim_gettext_keys_step.rb
|
107
|
-
- lib/translation/client/base_operation/save_new_po_files_step.rb
|
108
|
-
- lib/translation/client/base_operation/save_new_yaml_files_step.rb
|
109
|
-
- lib/translation/client/base_operation/save_special_yaml_files_step.rb
|
110
|
-
- lib/translation/client/base_operation.rb
|
111
|
-
- lib/translation/client/init_operation/cleanup_yaml_files_step.rb
|
112
|
-
- lib/translation/client/init_operation/create_yaml_po_files_step.rb
|
113
|
-
- lib/translation/client/init_operation/update_and_collect_po_files_step.rb
|
114
|
-
- lib/translation/client/init_operation/update_pot_file_step.rb
|
115
|
-
- lib/translation/client/init_operation.rb
|
116
|
-
- lib/translation/client/purge_operation.rb
|
117
|
-
- lib/translation/client/sync_operation/create_yaml_pot_file_step.rb
|
118
|
-
- lib/translation/client/sync_operation/update_and_collect_pot_file_step.rb
|
119
|
-
- lib/translation/client/sync_operation.rb
|
120
|
-
- lib/translation/client.rb
|
121
|
-
- lib/translation/config.rb
|
122
|
-
- lib/translation/controller.rb
|
123
|
-
- lib/translation/flat_hash.rb
|
124
|
-
- lib/translation/railtie.rb
|
125
|
-
- lib/translation/tasks.rb
|
126
|
-
- lib/translation/yaml_conversion.rb
|
127
104
|
- lib/translation.rb
|
105
|
+
- lib/translation_io/client/base_operation/create_new_mo_files_step.rb
|
106
|
+
- lib/translation_io/client/base_operation/dump_haml_gettext_keys_step.rb
|
107
|
+
- lib/translation_io/client/base_operation/dump_slim_gettext_keys_step.rb
|
108
|
+
- lib/translation_io/client/base_operation/save_new_po_files_step.rb
|
109
|
+
- lib/translation_io/client/base_operation/save_new_yaml_files_step.rb
|
110
|
+
- lib/translation_io/client/base_operation/save_special_yaml_files_step.rb
|
111
|
+
- lib/translation_io/client/base_operation.rb
|
112
|
+
- lib/translation_io/client/init_operation/cleanup_yaml_files_step.rb
|
113
|
+
- lib/translation_io/client/init_operation/create_yaml_po_files_step.rb
|
114
|
+
- lib/translation_io/client/init_operation/update_and_collect_po_files_step.rb
|
115
|
+
- lib/translation_io/client/init_operation/update_pot_file_step.rb
|
116
|
+
- lib/translation_io/client/init_operation.rb
|
117
|
+
- lib/translation_io/client/sync_operation/create_yaml_pot_file_step.rb
|
118
|
+
- lib/translation_io/client/sync_operation/update_and_collect_pot_file_step.rb
|
119
|
+
- lib/translation_io/client/sync_operation.rb
|
120
|
+
- lib/translation_io/client.rb
|
121
|
+
- lib/translation_io/config.rb
|
122
|
+
- lib/translation_io/controller.rb
|
123
|
+
- lib/translation_io/flat_hash.rb
|
124
|
+
- lib/translation_io/railtie.rb
|
125
|
+
- lib/translation_io/tasks.rb
|
126
|
+
- lib/translation_io/yaml_conversion.rb
|
128
127
|
- README.md
|
129
128
|
homepage: http://rails.translation.io
|
130
129
|
licenses:
|
data/lib/translation/client.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'translation/client/base_operation'
|
2
|
-
require 'translation/client/init_operation'
|
3
|
-
require 'translation/client/sync_operation'
|
4
|
-
require 'translation/client/purge_operation'
|
5
|
-
|
6
|
-
module Translation
|
7
|
-
class Client
|
8
|
-
attr_reader :api_key, :endpoint
|
9
|
-
|
10
|
-
def initialize(api_key, endpoint)
|
11
|
-
@api_key = api_key
|
12
|
-
@endpoint = endpoint
|
13
|
-
end
|
14
|
-
|
15
|
-
def init
|
16
|
-
Translation::Client::InitOperation.new(self).run
|
17
|
-
end
|
18
|
-
|
19
|
-
def sync
|
20
|
-
Translation::Client::SyncOperation.new(self).run
|
21
|
-
end
|
22
|
-
|
23
|
-
def purge
|
24
|
-
Translation::Client::SyncOperation.new(self).run(true)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/translation/tasks.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'gettext/tools'
|
2
|
-
|
3
|
-
namespace :translation do
|
4
|
-
task :config => :environment do
|
5
|
-
puts Translation.config
|
6
|
-
end
|
7
|
-
|
8
|
-
task :init => :environment do
|
9
|
-
if Translation.client
|
10
|
-
Translation.client.init
|
11
|
-
else
|
12
|
-
Translation.info "[Error] Client cannot be built. Did you set up the initializer?"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
task :sync => :environment do
|
17
|
-
if Translation.client
|
18
|
-
Translation.client.sync
|
19
|
-
else
|
20
|
-
Translation.info "[Error] Client cannot be built. Did you set up the initializer?"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
task :purge => :environment do
|
25
|
-
if Translation.client
|
26
|
-
Translation.client.purge
|
27
|
-
else
|
28
|
-
Translation.info "[Error] Client cannot be built. Did you set up the initializer?"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|