ftotr 0.1.0 → 0.1.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 +4 -4
- data/lib/ftotr.rb +10 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd6c6cf667a6ec8ec9bec4f8560810832c5143c6
|
4
|
+
data.tar.gz: f29d4dd31bf61e66f1b88a9000c1a49034563a03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 731210aefc1fc673bd369154298a68d90b5815d8b0eedc77c622fc0c0ac35e3a49c013bf4a54328a72f00f0f40507ad9cb93296ec7e6ee45aaf2cd4f88bc4223
|
7
|
+
data.tar.gz: 9118cff9698d350b07b6d282c0182f940837d302044e4d6286e8319081362f5dba7f9709490a58cb41ad7e91bf475cdcdaa2d5b7af9669e8cc1b59b46169a778
|
data/lib/ftotr.rb
CHANGED
@@ -11,16 +11,19 @@ class Ftotr
|
|
11
11
|
|
12
12
|
# Search for .strings files
|
13
13
|
strings_file_paths = []
|
14
|
+
xcodeproj_file_paths = []
|
14
15
|
Find.find(Pathname.pwd) do |path|
|
15
16
|
strings_file_paths << path if path =~ /.*\.strings$/
|
16
17
|
strings_file_paths = strings_file_paths.select{ |i| i[/^((?!Pods).)*$/] }
|
18
|
+
xcodeproj_file_paths << path if path =~ /.*\.xcodeproj$/
|
19
|
+
xcodeproj_file_paths = xcodeproj_file_paths.select{ |i| i[/^((?!Pods).)*$/] }
|
17
20
|
end
|
18
21
|
|
19
22
|
# Write found '\\TOTR' to corresponding files
|
20
23
|
for strings_file_path in strings_file_paths do
|
21
24
|
file_created = false
|
22
25
|
file_path = ''
|
23
|
-
File.open(strings_file_path).each_line do |line|
|
26
|
+
File.open(strings_file_path).each_line.with_index do |line, i|
|
24
27
|
if !line.valid_encoding?
|
25
28
|
line = line.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8')
|
26
29
|
end
|
@@ -28,9 +31,12 @@ class Ftotr
|
|
28
31
|
if !file_created
|
29
32
|
output = strings_file_path + " :("
|
30
33
|
puts output.red
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
language_name = URI(strings_file_path).path.split('/').last(2)[0].sub('.lproj', '')
|
35
|
+
project_file_name = URI(xcodeproj_file_paths.last).path.split('/').last.sub('.xcodeproj', '')
|
36
|
+
file_name = URI(strings_file_path).path.split('/').last.sub('.strings', '')
|
37
|
+
output_file_name = language_name + "_" + project_file_name + "_" + file_name
|
38
|
+
output_file_name = output_file_name.downcase
|
39
|
+
file_path = base_output_file_path + output_file_name + ".txt"
|
34
40
|
File.delete(file_path) if File.exist?(file_path)
|
35
41
|
file_created = true
|
36
42
|
end
|