Sha256: 9808df641e426e36e97b76a5ac6ceba34e044f8e432fd071a6c394f606ec039d
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
module Babelyoda class LocalizationKey attr_reader :id attr_reader :context attr_reader :values def initialize(id, context) @id = id @context = context @values = {} end def <<(localization_value) @values[localization_value.language.to_sym] = localization_value.dup self end def merge!(localization_key, options = {}) updated = false context_changed = false if @context != localization_key.context @context = localization_key.context updated = context_changed = true end localization_key.values.each_value do |value| if @values.has_key?(value.language.to_sym) updated = true if @values[value.language.to_sym].merge!(value, options) else @values[value.language.to_sym] = value.dup updated = true end end # Mark all values as requiring translation if the context has changed. if context_changed @values.each_value do |value| value.status = :requires_translation end end return updated end def drop_empty! @values.delete_if do |id, value| value.text.empty? end end def empty? @values.empty? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
babelyoda-2.0.1 | lib/babelyoda/localization_key.rb |
babelyoda-2.0.0 | lib/babelyoda/localization_key.rb |