Class: GoNative::Plugins::IOS::AddLanguage

Inherits:
Object
  • Object
show all
Extended by:
DSL::Serviceable
Defined in:
lib/gonative/plugins/ios/add_language.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(language) ⇒ AddLanguage

Returns a new instance of AddLanguage.



13
14
15
# File 'lib/gonative/plugins/ios/add_language.rb', line 13

def initialize(language)
  @language = language
end

Instance Attribute Details

#languageObject (readonly)

Returns the value of attribute language.



11
12
13
# File 'lib/gonative/plugins/ios/add_language.rb', line 11

def language
  @language
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/gonative/plugins/ios/add_language.rb', line 17

def call
  return unless exists?

  proj = Xcodeproj::Project.open('MedianIOS.xcodeproj')
  file = proj.new_file("#{language}.lproj/Localizable.strings")
  file.move(localizable_group(proj))
  file.name = language

  proj.save
end

#localizable_group(proj) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/gonative/plugins/ios/add_language.rb', line 28

def localizable_group(proj)
  proj.objects.each do |o|
    if o.is_a?(Xcodeproj::Project::Object::PBXGroup) && (o.hierarchy_path == '/LeanIOS/Localizable.strings')
      return o
    end
  end

  nil
end