Sha256: db3f3011f0cad1a1415180fe66dc770b764c19882bd0a56802e3d5d698eefc7c

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

module PolyglotIos
  module Serializer
    module Source
      class TranslationCase
        include Helper::General

        attr_accessor :name
        attr_accessor :value
        attr_accessor :translation

        def initialize(name, value, translation = nil)
          @name = name
          @value = value
          @translation = translation
        end

        def serialized()
          clean_name = clean_case_name(name)
          "public static let #{clean_name}: Strings = \"#{value}\""
        end
        
        def serializedDefaultTranslation()
          if !translation.nil?
            return format_translation_as_comment(translation)
          end
          return ""
        end

        def format_translation_as_comment(translation)
          lines = translation.lines
          lines.each_with_index.map do |line, index|
            if index == 0
              "/// Value: #{line.chomp}"
            else
              "\t/// #{line.chomp}"
            end
          end.join("\n")
        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ios_polyglot_cli-2.8.0 lib/ios_polyglot_cli/serializers/sources/swift_helpers/translation_case.rb
ios_polyglot_cli-2.7.3 lib/ios_polyglot_cli/serializers/sources/swift_helpers/translation_case.rb
ios_polyglot_cli-2.7.2 lib/ios_polyglot_cli/serializers/sources/swift_helpers/translation_case.rb
ios_polyglot_cli-2.7.1 lib/ios_polyglot_cli/serializers/sources/swift_helpers/translation_case.rb