Sha256: 63efff0390e7f7edd319c4ee51725b800fcf95f879a01bd5a08c9ab07817a624

Contents?: true

Size: 962 Bytes

Versions: 7

Compression:

Stored size: 962 Bytes

Contents

# frozen_string_literal: true

require 'xcodeproj'

module GoNative
  module Plugins
    module IOS
      class AddLanguage
        extend DSL::Serviceable

        attr_reader :language

        def initialize(language)
          @language = language
        end

        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

        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

        private

        def exists?
          File.directory?("LeanIOS/#{language}.lproj")
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gonative-cli-1.4.4 lib/gonative/plugins/ios/add_language.rb
gonative-cli-1.4.3 lib/gonative/plugins/ios/add_language.rb
gonative-cli-1.4.2 lib/gonative/plugins/ios/add_language.rb
gonative-cli-1.4.1 lib/gonative/plugins/ios/add_language.rb
gonative-cli-1.4.0 lib/gonative/plugins/ios/add_language.rb
gonative-cli-1.3.9 lib/gonative/plugins/ios/add_language.rb
gonative-cli-1.3.8 lib/gonative/plugins/ios/add_language.rb