terrestrial-cli 0.1.1 → 0.6.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/terrestrial/cli/dot_strings_formatter.rb +20 -3
- data/lib/terrestrial/cli/flight/ios_workflow.rb +8 -2
- data/lib/terrestrial/cli/init.rb +2 -0
- data/lib/terrestrial/cli/pull/processes_translations.rb +63 -0
- data/lib/terrestrial/cli/pull.rb +7 -4
- data/lib/terrestrial/cli/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f9c9727a09008ddfadbf7834495b7a217537f0a
|
4
|
+
data.tar.gz: 7eed9f1dc4c523a1272637511a2066fd41c525a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ae1e63c73556277ed65a685312f66f252e3168ace1442ad3d2e8b256f52737951b4e38204cd16281d1e6e44dd1d13b5c3e68805c336d83f0aeb2444c2c98e1d
|
7
|
+
data.tar.gz: 5dfdfb649948aeb742fd78f1acbb08dda7e8367920a58e87eb038d7b400cc5f22c8388bb34992d1c744da58f3e98b06cdb1bec4fafd0ac1124fd3a2575074051
|
@@ -8,9 +8,18 @@ module Terrestrial
|
|
8
8
|
|
9
9
|
def format_foreign_translation
|
10
10
|
result = []
|
11
|
-
entries.each do |entry|
|
12
|
-
#
|
13
|
-
# files.
|
11
|
+
entries.reject(&:placeholder?).each do |entry|
|
12
|
+
# just id and string needed for translation
|
13
|
+
# files. extra metadata is found in base.lproj.
|
14
|
+
result << "\"#{entry.identifier}\"=\"#{entry.string}\";"
|
15
|
+
result << ""
|
16
|
+
end
|
17
|
+
|
18
|
+
result.concat(placeholder_disclaimer)
|
19
|
+
|
20
|
+
entries.select(&:placeholder?).each do |entry|
|
21
|
+
# just id and string needed for translation
|
22
|
+
# files. extra metadata is found in base.lproj.
|
14
23
|
result << "\"#{entry.identifier}\"=\"#{entry.string}\";"
|
15
24
|
result << ""
|
16
25
|
end
|
@@ -29,6 +38,14 @@ module Terrestrial
|
|
29
38
|
|
30
39
|
private
|
31
40
|
|
41
|
+
def placeholder_disclaimer
|
42
|
+
[
|
43
|
+
"// The following translations have been copied from the project base language because no translation was provided for them.",
|
44
|
+
"// iOS requires each Localizable.strings file to contain all keys used in the project. In order to provide proper fallbacks, Terrestrial includes missing translations in each translation resource file.",
|
45
|
+
""
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
32
49
|
def file_comments(entry)
|
33
50
|
["// Files:"] +
|
34
51
|
entry
|
@@ -38,7 +38,8 @@ module Terrestrial
|
|
38
38
|
|
39
39
|
def create_path_to_localization_files
|
40
40
|
folder_name = Pathname.new(Dir[Config[:directory] + "/*.xcodeproj"].first).basename(".*").to_s
|
41
|
-
|
41
|
+
project_language = detect_project_language(folder_name)
|
42
|
+
base_lproj_path = FileUtils.mkdir_p(Config[:directory] + "/#{folder_name}" + "/#{project_language}.lproj").first
|
42
43
|
|
43
44
|
base_lproj_path + "/Localizable.strings"
|
44
45
|
end
|
@@ -53,10 +54,15 @@ module Terrestrial
|
|
53
54
|
Config.update_project_config
|
54
55
|
end
|
55
56
|
|
57
|
+
def detect_project_language(folder)
|
58
|
+
info_plist = Dir[Config[:directory] + "/#{folder}/Info.plist"].first
|
59
|
+
`defaults read '#{info_plist}' CFBundleDevelopmentRegion`.gsub("\n", "").squeeze(" ")
|
60
|
+
end
|
61
|
+
|
56
62
|
def print_done_message(lproj_folder)
|
57
63
|
puts "------------------------------------"
|
58
64
|
puts "-- Done!"
|
59
|
-
puts "-
|
65
|
+
puts "- Localizable.strings created in #{lproj_folder}"
|
60
66
|
puts "- All strings in source substituted with IDs."
|
61
67
|
puts "- Remember to include the new localization files in your project!"
|
62
68
|
end
|
data/lib/terrestrial/cli/init.rb
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
module Terrestrial
|
2
|
+
module Cli
|
3
|
+
class Pull < Command
|
4
|
+
class ProcessesTranslations
|
5
|
+
def self.run(translations, local_strings, platform)
|
6
|
+
new(translations, local_strings, platform).run
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(translations, local_strings, platform)
|
10
|
+
@translations = translations
|
11
|
+
@local_strings = local_strings
|
12
|
+
@platform = platform
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
case platform
|
17
|
+
when "ios"
|
18
|
+
process_ios
|
19
|
+
when "android"
|
20
|
+
process_android
|
21
|
+
else
|
22
|
+
raise "Unknown platform"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def process_android
|
27
|
+
translations
|
28
|
+
.reject {|entry| entry["translation"].nil? || entry["translation"].empty? }
|
29
|
+
.map {|entry| TranslatedString.new(entry["translation"], entry["id"], false) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def process_ios
|
33
|
+
local_strings.map do |local_string|
|
34
|
+
match = find_translation_for_id(local_string["identifier"])
|
35
|
+
if match
|
36
|
+
TranslatedString.new(match["translation"], match["id"], false)
|
37
|
+
else
|
38
|
+
TranslatedString.new(local_string["string"], local_string["identifier"], true)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def find_translation_for_id(id)
|
44
|
+
translations.detect {|t| t["id"] == id }
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def translations
|
50
|
+
@translations
|
51
|
+
end
|
52
|
+
|
53
|
+
def local_strings
|
54
|
+
@local_strings
|
55
|
+
end
|
56
|
+
|
57
|
+
def platform
|
58
|
+
@platform
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/terrestrial/cli/pull.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'terrestrial/cli/pull/processes_translations'
|
1
2
|
require 'pathname'
|
2
3
|
require 'fileutils'
|
3
4
|
|
@@ -31,9 +32,7 @@ module Terrestrial
|
|
31
32
|
def update_translation_file(language, translations)
|
32
33
|
write_translation_file(
|
33
34
|
translation_file_path_for(language),
|
34
|
-
translations
|
35
|
-
.reject {|entry| entry["translation"].nil? || entry["translation"].empty? }
|
36
|
-
.map {|entry| TranslatedString.new(entry["translation"], entry["id"]) }
|
35
|
+
ProcessesTranslations.run(translations, string_registry.entries, Config[:platform])
|
37
36
|
)
|
38
37
|
end
|
39
38
|
|
@@ -99,11 +98,15 @@ module Terrestrial
|
|
99
98
|
@response
|
100
99
|
end
|
101
100
|
|
101
|
+
def string_registry
|
102
|
+
@string_registry ||= StringRegistry.load
|
103
|
+
end
|
104
|
+
|
102
105
|
def web_client
|
103
106
|
@web_client ||= Web.new
|
104
107
|
end
|
105
108
|
|
106
|
-
class TranslatedString < Struct.new(:string, :identifier)
|
109
|
+
class TranslatedString < Struct.new(:string, :identifier, :placeholder?)
|
107
110
|
end
|
108
111
|
end
|
109
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terrestrial-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niklas Begley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: terminal-table
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- lib/terrestrial/cli/parser/swift.rb
|
150
150
|
- lib/terrestrial/cli/photoshoot.rb
|
151
151
|
- lib/terrestrial/cli/pull.rb
|
152
|
+
- lib/terrestrial/cli/pull/processes_translations.rb
|
152
153
|
- lib/terrestrial/cli/push.rb
|
153
154
|
- lib/terrestrial/cli/scan.rb
|
154
155
|
- lib/terrestrial/cli/string_registry.rb
|