Sha256: 2adb49c47c6a8276a648b61ac1e61c2b52813ddf8291404653ccf4cc09e1256c
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
class SlimKeyfy::Transformer::Word attr_reader :line, :tokens, :indentation attr_accessor :translations def initialize(line, key_base, extension) @line = line @key_base = key_base @extension = extension @indentation = " " * (@line.size - unindented_line.size) @translations = {} end def as_list(delim=" ") @line.split(delim) end def unindented_line @line.sub(/^\s*/, "") end def head as_list.first end def tail as_list.drop(1) end def i18nString(translation_key) if @extension == "rb" "t('#{@key_base}.#{translation_key}')" else "t('.#{translation_key}')" end end def update_translation_key_hash(yaml_processor, translation) translation_key = SlimKeyfy::Slimutils::TranslationKeyGenerator.new(translation).generate_key_name translation_key_with_base = "#{@key_base}.#{translation_key}" translation_key_with_base, translation = yaml_processor.merge!(translation_key_with_base, translation) unless yaml_processor.nil? @translations.merge!({translation_key_with_base => translation}) i18nString(extract_updated_key(translation_key_with_base)) end def extract_updated_key(translation_key_with_base) return "" if (translation_key_with_base.nil? or translation_key_with_base.empty?) translation_key_with_base.split(".").last end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slimkeyfy-0.0.3 | lib/slimkeyfy/transformer/word.rb |