convert-strings-ios-and 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/convert-strings-ios-and.rb +95 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 399dd07c9f1fd6437e1c58a29acc8070f5312d13
|
4
|
+
data.tar.gz: 5a9facaafc13ed3f824aa1a2013a452d2954a6d6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fb7afd61241ff0d38c240cc62e29453524d9246b44482df143a6eebde427ec1d21936258023a7bad80a30b810b1eb97ad812650c23a853274908c2c5f8ffca96
|
7
|
+
data.tar.gz: 4857a375e348da6fc63d4b2e89be800415184c3a21d1e17df9c11490294e3153fb25dd04fb3889aa60bb4d398b0ae072dd16347abae3c76d77c611aaa3e50a89
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#
|
2
|
+
# Convert Strings iOS <-> Android
|
3
|
+
#
|
4
|
+
# last update 2016.12.07
|
5
|
+
#
|
6
|
+
# hwj4477@gmail.com
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'net/http'
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
class ConvertStrings
|
13
|
+
|
14
|
+
def self.ios_to_android(stringsPath)
|
15
|
+
|
16
|
+
resultFile = File.open('strings.xml', 'wb')
|
17
|
+
|
18
|
+
File.open(stringsPath) do |file|
|
19
|
+
|
20
|
+
resultFile.puts "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
|
21
|
+
resultFile.puts "\n"
|
22
|
+
|
23
|
+
while line = file.gets
|
24
|
+
|
25
|
+
# puts strings
|
26
|
+
if line =~ /"/ && line.split("=").count == 2
|
27
|
+
|
28
|
+
key = line.split("=").first.strip
|
29
|
+
value = line.split("=").last.strip.gsub(/"/, "").gsub(/;/, "")
|
30
|
+
|
31
|
+
resultFile.puts "<string name=#{key}>#{value}</string>"
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
# puts comment
|
36
|
+
if line =~ /\/\//
|
37
|
+
|
38
|
+
comment = line.gsub(/\/\//, "").strip
|
39
|
+
|
40
|
+
resultFile.puts "<!-- #{comment} -->"
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
# result
|
49
|
+
yield File.absolute_path(resultFile.path)
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.android_to_ios(stringsPath)
|
54
|
+
|
55
|
+
resultFile = File.open('Localizable.strings', 'wb')
|
56
|
+
|
57
|
+
File.open(stringsPath) do |file|
|
58
|
+
|
59
|
+
while line = file.gets
|
60
|
+
|
61
|
+
# puts strings
|
62
|
+
if line =~ /<string name="/
|
63
|
+
|
64
|
+
key_value = line.strip.gsub(/<string name="/, "").gsub(/<\/string>/, "").split("\">")
|
65
|
+
|
66
|
+
if key_value.count == 2
|
67
|
+
|
68
|
+
key = key_value.first
|
69
|
+
value = key_value.last
|
70
|
+
|
71
|
+
resultFile.puts "\"#{key}\" = \"#{value}\";"
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
# puts comment
|
78
|
+
if line =~ /<!--/
|
79
|
+
|
80
|
+
comment = line.gsub(/<!--/, "//").gsub(/-->/, "").strip
|
81
|
+
|
82
|
+
resultFile.puts comment
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
# result
|
91
|
+
yield File.absolute_path(resultFile.path)
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: convert-strings-ios-and
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hwj4477
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Strings Converter
|
14
|
+
email: hwj4477@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib//convert-strings-ios-and.rb
|
20
|
+
homepage: http://github.com/hwj4477/convert-strings-ios-and
|
21
|
+
licenses:
|
22
|
+
- hwj4477
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.8
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Convert Strings iOS <-> Android
|
44
|
+
test_files: []
|