xcmultilingual 0.1.7 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab93f05077b93908e01de7a5a365419661b94252
4
- data.tar.gz: 49cb5cfbbabf3a31609591e72f8a5e314a1339f5
3
+ metadata.gz: da9fbf5ba45832c00e8cee478c30c1e7f56059c9
4
+ data.tar.gz: d4fa56b66ea906b632dbdaa94573daa1d576e85e
5
5
  SHA512:
6
- metadata.gz: ad45c0bf484fc603b585f64e989fbed8f817ab46cf59885e9bd9bfb979a73282721a60c20aeb7b0456d4d7fa33610abcc9d650e8f2fe914d9ce38676f0bd68ed
7
- data.tar.gz: 4055751839a4c531b8eacfecc9fc1c80077bee25bc0ebafeaac683db5da941209037b8327409b90a36e42b9cb9960f3f252689c48e7f7b275e800a204bce09df
6
+ metadata.gz: d2a5c99476070187fadce16261b3e96901ef50dd65da776444035293b4c5a1ac90a8763ba40b04081b7bf96c24dc5d8b03bad1c9f8bf92cb3b7a695f87ffaf10
7
+ data.tar.gz: 6611c99675c2c1e0cce6f7722f432ab51555bfbc33642bd20bd2d60d74d74468f0796c371b1667be07a0f60b68090d84afd8b1ff4947cb917dece78a4ca15020
@@ -28,12 +28,13 @@ struct Multilingual {
28
28
  return NSLocalizedString(rawValue, tableName: "Animal", bundle: NSBundle.mainBundle(), value: "\(rawValue)", comment: "")
29
29
  }
30
30
 
31
- static func keys() -> [String] {
31
+ static let name = "Animal"
32
+
33
+ static var keys: [String] {
32
34
  return ["CAT", "DOG", "BEAR", "DEER", "SQUIRREL", "ELEPHANT", "GIRAFFE", "TIGER", "LION", "RABBIT", "RHINOCEROS", "GORILLA", "MONKEY"]
33
35
  }
34
-
35
- static func localizations() -> [String] {
36
- return Animal.keys().map { Animal(rawValue: $0)!.string() }
36
+ static var localizations: [String] {
37
+ return Animal.keys.map { Animal(rawValue: $0)!.string() }
37
38
  }
38
39
  }
39
40
 
@@ -46,12 +47,13 @@ struct Multilingual {
46
47
  return NSLocalizedString(rawValue, tableName: "Localizable", bundle: NSBundle.mainBundle(), value: "\(rawValue)", comment: "")
47
48
  }
48
49
 
49
- static func keys() -> [String] {
50
+ static let name = "Localizable"
51
+
52
+ static var keys: [String] {
50
53
  return ["HELLO", "GOODMORNING", "GOODEVENING"]
51
54
  }
52
-
53
- static func localizations() -> [String] {
54
- return Localizable.keys().map { Localizable(rawValue: $0)!.string() }
55
+ static var localizations: [String] {
56
+ return Localizable.keys.map { Localizable(rawValue: $0)!.string() }
55
57
  }
56
58
  }
57
59
 
@@ -62,12 +64,13 @@ struct Multilingual {
62
64
  return NSLocalizedString(rawValue, tableName: "Sample Localization", bundle: Multilingual.bundle("Loalizations/sample2.bundle"), value: "\(rawValue)", comment: "")
63
65
  }
64
66
 
65
- static func keys() -> [String] {
67
+ static let name = "Sample Localization"
68
+
69
+ static var keys: [String] {
66
70
  return ["SAMPLE 2"]
67
71
  }
68
-
69
- static func localizations() -> [String] {
70
- return Sample2Sample_Localization.keys().map { Sample2Sample_Localization(rawValue: $0)!.string() }
72
+ static var localizations: [String] {
73
+ return Sample2Sample_Localization.keys.map { Sample2Sample_Localization(rawValue: $0)!.string() }
71
74
  }
72
75
  }
73
76
 
@@ -78,12 +81,13 @@ struct Multilingual {
78
81
  return NSLocalizedString(rawValue, tableName: "Sample", bundle: Multilingual.bundle("sample.bundle"), value: "\(rawValue)", comment: "")
79
82
  }
80
83
 
81
- static func keys() -> [String] {
84
+ static let name = "Sample"
85
+
86
+ static var keys: [String] {
82
87
  return ["SAMPLE"]
83
88
  }
84
-
85
- static func localizations() -> [String] {
86
- return SampleSample.keys().map { SampleSample(rawValue: $0)!.string() }
89
+ static var localizations: [String] {
90
+ return SampleSample.keys.map { SampleSample(rawValue: $0)!.string() }
87
91
  }
88
92
  }
89
93
 
@@ -23,24 +23,24 @@ class ViewController: UITableViewController {
23
23
 
24
24
  let tables = [
25
25
  Table(
26
- name: "Localizable",
27
- keys: Multilingual.Localizable.keys(),
28
- localizations: Multilingual.Localizable.localizations()
26
+ name: Multilingual.Localizable.name,
27
+ keys: Multilingual.Localizable.keys,
28
+ localizations: Multilingual.Localizable.localizations
29
29
  ),
30
30
  Table(
31
- name: "Animal",
32
- keys: Multilingual.Animal.keys(),
33
- localizations: Multilingual.Animal.localizations()
31
+ name: Multilingual.Animal.name,
32
+ keys: Multilingual.Animal.keys,
33
+ localizations: Multilingual.Animal.localizations
34
34
  ),
35
35
  Table(
36
- name: "SampleSample",
37
- keys: Multilingual.SampleSample.keys(),
38
- localizations: Multilingual.SampleSample.localizations()
36
+ name: Multilingual.SampleSample.name,
37
+ keys: Multilingual.SampleSample.keys,
38
+ localizations: Multilingual.SampleSample.localizations
39
39
  ),
40
40
  Table(
41
- name: "Sample2Sample_Localization",
42
- keys: Multilingual.Sample2Sample_Localization.keys(),
43
- localizations: Multilingual.Sample2Sample_Localization.localizations()
41
+ name: Multilingual.Sample2Sample_Localization.name,
42
+ keys: Multilingual.Sample2Sample_Localization.keys,
43
+ localizations: Multilingual.Sample2Sample_Localization.localizations
44
44
  )
45
45
  ]
46
46
  }
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xcmultilingual (0.1.7)
4
+ xcmultilingual (0.2.0)
5
5
  thor
6
6
 
7
7
  GEM
@@ -3,15 +3,21 @@ module Xcmultilingual
3
3
  def description
4
4
  name_description = name.nil? ? "MAIN BUNDLE" : name
5
5
  relative_path_description = relative_path.nil? ? "NO RELATIVE PATH" : relative_path
6
- tables_description = tables.map { |table| table.description }.join("")
7
- " [Bundle] name: #{name_description}, relative_path: #{relative_path_description}, tables: #{tables_description}"
6
+ tables_description = tables.map { |table| table.description }.join(" / ")
7
+ "[#{name_description}]\nname: #{name_description}, relative_path: #{relative_path_description}, tables: #{tables_description}"
8
8
  end
9
9
  end
10
10
 
11
11
  Table = Struct.new("Table", :name, :keys) do
12
12
  def description
13
13
  keys_description = keys.join(", ")
14
- "\n - [Table] name: #{name}, keys: #{keys_description}"
14
+ "[Table] name: #{name}, keys: #{keys_description}"
15
15
  end
16
16
  end
17
17
  end
18
+
19
+ class String
20
+ def safe
21
+ return self.gsub(" ", "_")
22
+ end
23
+ end
@@ -20,10 +20,13 @@ module Xcmultilingual
20
20
  writer.verbose = options[:verbose] || false
21
21
  writer.write
22
22
 
23
- puts "+ DONE" if options[:verbose]
23
+ puts "" if options[:verbose]
24
+ puts "+++ DONE ++++++++++++++++++++++++" if options[:verbose]
24
25
  puts "" if options[:verbose]
25
26
  puts " See #{destination}" if options[:verbose]
26
27
  puts "" if options[:verbose]
28
+ puts "+++++++++++++++++++++++++++++++++" if options[:verbose]
29
+ puts "" if options[:verbose]
27
30
  end
28
31
 
29
32
  map %w[--version -v] => :__print_version
@@ -9,8 +9,7 @@ module Xcmultilingual
9
9
  end
10
10
 
11
11
  def parse
12
- puts "+ START PARSING" if @verbose
13
- puts "" if @verbose
12
+ puts "[START PARSING]" if @verbose
14
13
 
15
14
  destination_path = File.expand_path(@destination)
16
15
  destination_dir = File.dirname(destination_path)
@@ -41,7 +40,7 @@ module Xcmultilingual
41
40
  safe_line = line.scrub('?')
42
41
  if key = find_key(safe_line)
43
42
  bundles[bundle_name][:tables][name] << key
44
- puts " PARSE: #{File.basename(file_path)} > #{line}" if @verbose
43
+ puts "<#{File.basename(file_path)}> #{line}" if @verbose
45
44
  end
46
45
  end
47
46
  end
@@ -54,13 +53,11 @@ module Xcmultilingual
54
53
  bundle.tables << table
55
54
  end
56
55
 
57
- puts "" if @verbose
58
56
  puts "#{bundle.description}" if @verbose
59
57
  bundle_data << bundle
60
58
  end
61
59
 
62
- puts "" if @verbose
63
- puts "+ PARSE SUCCEEDED" if @verbose
60
+ puts "[PARSE SUCCEEDED]" if @verbose
64
61
  puts "" if @verbose
65
62
 
66
63
  bundle_data
@@ -11,24 +11,25 @@ import Foundation
11
11
  struct <%= @name %> {
12
12
  <% @bundle_data.each do |bundle| -%>
13
13
  <% nsbundle = bundle.name ? "Multilingual.bundle(\"#{bundle.relative_path}\")" : "NSBundle.mainBundle()" -%>
14
- <% bundle_name = bundle.name.nil? ? "" : bundle.name.gsub(" ", "_").capitalize -%>
14
+ <% bundle_name = bundle.name.nil? ? "" : bundle.name.safe.capitalize -%>
15
15
  <% bundle.tables.each do |table| -%>
16
- <% class_name = bundle_name + table.name.gsub(" ", "_") -%>
16
+ <% class_name = bundle_name + table.name.safe -%>
17
17
  enum <%= class_name %>: String {
18
18
  <% table.keys.each do |key| -%>
19
- case <%= key.gsub(" ", "_") %> = "<%= key %>"
19
+ case <%= key.safe %> = "<%= key %>"
20
20
  <% end # keys -%>
21
21
 
22
22
  func string() -> String {
23
23
  return NSLocalizedString(rawValue, tableName: "<%= table.name %>", bundle: <%= nsbundle %>, value: "\(rawValue)", comment: "")
24
24
  }
25
25
 
26
- static func keys() -> [String] {
26
+ static let name = "<%= table.name %>"
27
+
28
+ static var keys: [String] {
27
29
  return ["<%= table.keys.join("\", \"") %>"]
28
30
  }
29
-
30
- static func localizations() -> [String] {
31
- return <%= class_name %>.keys().map { <%= class_name %>(rawValue: $0)!.string() }
31
+ static var localizations: [String] {
32
+ return <%= class_name %>.keys.map { <%= class_name %>(rawValue: $0)!.string() }
32
33
  }
33
34
  }
34
35
 
@@ -1,3 +1,3 @@
1
1
  module Xcmultilingual
2
- VERSION = "0.1.7"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -12,12 +12,12 @@ module Xcmultilingual
12
12
  end
13
13
 
14
14
  def write
15
- puts "+ START UPDATING\n\n" if @verbose
15
+ puts "[START UPDATING]" if @verbose
16
16
 
17
17
  if !File.exist?("#{@destination}")
18
- puts " There is no destination file." if @verbose
18
+ puts "There is no destination file." if @verbose
19
19
  puts "\n+ FAILED UPDATING\n" if @verbose
20
- return
20
+ exit 2
21
21
  end
22
22
 
23
23
  File.open("#{@destination}", "w") do |file|
@@ -25,7 +25,7 @@ module Xcmultilingual
25
25
  body = ERB.new(File.open(path).read, nil, '-').result(binding)
26
26
  file.write(body)
27
27
  end
28
- puts "+ END UPDATING\n\n" if @verbose
28
+ puts "[END UPDATING]" if @verbose
29
29
  end
30
30
 
31
31
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcmultilingual
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naoki Morita