-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
35 lines (26 loc) · 838 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true
namespace :strings do
desc 'Generate Swift interface'
task :generate do
output = <<~SWIFT
// Automatically generated. Do not modify.
import Foundation
enum LocalizedString: String {
SWIFT
raw = File.read('Modules/Redacted-iOS/Resources/en.lproj/Localizable.strings')
keys = raw.scan(/^"([A-Z_]+)" = "/).collect(&:first).sort
keys.each do |key|
camel = key.split('_').collect(&:capitalize).join.tap { |e| e[0] = e[0].downcase }
output += %( case #{camel} = "#{key}"\n)
end
output += <<~SWIFT
var string: String {
return NSLocalizedString(rawValue, comment: "")
}
}
SWIFT
File.open('Modules/Redacted-iOS/Sources/LocalizedString.swift', 'w') do |f|
f.write(output)
end
end
end