Sha256: cb2cc5c5e4e43de0f8f9e0aa10d6a960642a871593cff101bb4bbcef7ca2e93a

Contents?: true

Size: 754 Bytes

Versions: 5

Compression:

Stored size: 754 Bytes

Contents

# frozen_string_literal: true

module ExtractI18n::Adapters
  class VueAdapter < SlimAdapter
    def process_line(old_line)
      @mode ||= :template
      if old_line[/^<template/]
        @mode = :template
      elsif old_line[/^<script/]
        @mode = :script
      elsif old_line[/^<style/]
        @mode = :style
      end
      if @mode != :template
        return old_line
      end
      word = ExtractI18n::Slimkeyfy::Word.for('.vue').new(old_line)
      ExtractI18n::Slimkeyfy::VueTransformer.new(word, @file_key).transform do |change|
        if change.nil? # nothing to do
          return old_line
        end

        if @on_ask.call(change)
          change.i18n_t
        else
          old_line
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
extract_i18n-0.5.0 lib/extract_i18n/adapters/vue_adapter.rb
extract_i18n-0.4.0 lib/extract_i18n/adapters/vue_adapter.rb
extract_i18n-0.3.0 lib/extract_i18n/adapters/vue_adapter.rb
extract_i18n-0.2.0 lib/extract_i18n/adapters/vue_adapter.rb
extract_i18n-0.1.0 lib/extract_i18n/adapters/vue_adapter.rb