Sha256: d45478a51d417a70c68ab301b9d01feb8d5391529a937f1aa7eba77dade3b3a1
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
// // <%= @filename %> // xcmultilingual // // Created by xcmultilingual. // // import Foundation struct <%= @name %> { <% @bundle_data.each do |bundle| -%> <% nsbundle = bundle.name ? "Multilingual.bundle(\"#{bundle.relative_path}\")" : "NSBundle.mainBundle()" -%> <% bundle_name = bundle.name.nil? ? "" : bundle.name.gsub(" ", "_").capitalize -%> <% bundle.tables.each do |table| -%> <% class_name = bundle_name + table.name.gsub(" ", "_") -%> enum <%= class_name %>: String { <% table.keys.each do |key| -%> case <%= key.gsub(" ", "_") %> = "<%= key %>" <% end # keys -%> func string() -> String { return NSLocalizedString(rawValue, tableName: "<%= table.name %>", bundle: <%= nsbundle %>, value: "\(rawValue)", comment: "") } static func keys() -> [String] { return ["<%= table.keys.join("\", \"") %>"] } static func localizations() -> [String] { return <%= class_name %>.keys().map { <%= class_name %>(rawValue: $0)!.string() } } } <%- end # table -%> <%- end # bundle -%> private static func bundle(relativePath: String) -> NSBundle { var components = (__FILE__ as String).pathComponents components.removeLast() let bundlePath = join("/", components) + "/" + relativePath return NSBundle(path: bundlePath) ?? NSBundle.mainBundle() } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xcmultilingual-0.1.7 | lib/xcmultilingual/templates/swift.erb |