Parse translated value from the each_translated enumerator
 @param [Object] untranslated
 @param [Enumerator] each_translated
 @return [Object] final translated value
428164
def parse_value(untranslated, each_translated)
      case untranslated
      when Array
        # implode array
        untranslated.map { |from| parse_value(from, each_translated) }
      when String
        restore_interpolations untranslated, each_translated.next
      else
        untranslated
      end
    end
730319
def delete_translation_values
      field_key = FieldKey.find_by_global_key(params[:i18n_key])
      field_key.visible = false

      # not convinced it makes sense to delete the associated translations
      # phrases = I18n::Backend::ActiveRecord::Translation.where(:key => params[:i18n_key])
      # phrases.destroy_all

      field_key.save!
      render json: { success: true }
    end
1085604
def _set_translated_fields(self, language_code=None, **fields):
        
        objects = []  # no generator, make sure objects are all filled first
        for parler_meta, model_fields in self._parler_meta._split_fields(**fields):
            translation = self._get_translated_model(language_code=language_code, auto_create=True, meta=parler_meta)
            for field, value in six.iteritems(model_fields):
                setattr(translation, field, value)

            objects.append(translation)
        return objects
832173
def to_ruby_value
      bare_value = to_value
      case value_type
      when :utf8
        bare_value.to_utf8
      when Array
        value_type[1].wrap bare_value
      when Class
        value_type.wrap bare_value
      else
        bare_value
      end
    end
609042
def get_cached_translation(instance, language_code=None, related_name=None, use_fallback=False):
    
    if language_code is None:
        language_code = instance.get_current_language()

    translated_model = instance._parler_meta.get_model_by_related_name(related_name)
    values = _get_cached_values(instance, translated_model, language_code, use_fallback)
    if not values:
        return None

    try:
        translation = translated_model(**values)
    except TypeError:
        # Some model field was removed, cache entry is no longer working.
        return None

    translation._state.adding = False
    return translation
237442
def localized_scope
      langs = ::I18n.available_locales.join('|')
      scope '(:locale)', locale: Regexp.new(langs) do
        yield
      end
    end
844975
def get_translations(self, language=None):
        
        from .models import Translation

        if not self.pk:
            return Translation.objects.none()

        return Translation.objects.get_translations(obj=self, language=language)
911011
def translation_instances(self):
        
        return [
            instance
            for k, v in six.iteritems(self.instance._linguist_translations)
            for instance in v.values()
        ]
644096
def each
      raise Erlang::ImproperListError if improper?
      return to_enum unless block_given?
      list = self
      until list.empty?
        yield(list.head)
        list = list.tail
      end
      return self
    end
1122098
def get_translatable_children(self, obj):
        
        collector = NestedObjects(using='default')
        collector.collect([obj])
        object_list = collector.nested()
        items = self.get_elements(object_list)
        # avoid first object because it's the main object
        return items[1:]
120186
function ungettext(msgid1, msgid2, n) {
        if (_i18n_locale.locale_name == 'en_DEBUG') return __debug_trans_str(msgid1);
        var id = ''+_i18n_plural(n)+'-'+msgid1;
        var entry = _i18n_catalog[id];
        return entry == undefined ? (n==1 ? msgid1 : msgid2)  : entry;
    }
690589
def each
      return enum_for(:each) unless block_given?

      execute.each do |result|
        yield(model.new(result.merge(api: api)))
      end
    end
107580
def translate(root_list, use_bag_semantics=False):
    
    translator = (Translator() if use_bag_semantics else SetTranslator())
    return [translator.translate(root).to_sql() for root in root_list]
235870
def compile_translations(markup)
      syntax_tree = @parser.parse(markup, root: :translations)
      if(syntax_tree.nil?)
        raise Exception, "Parse error: #{@parser.failure_reason}"
      end
      syntax_tree.value
    end
1278756
def translate(value):
    
    if isinstance(value, BaseValidator):
        return value

    if value is None:
        return Anything()

    if isinstance(value, type):
        return IsA(value)

    if type(value) in compat.func_types:
        real_value = value()
        return IsA(type(real_value), default=real_value)

    if isinstance(value, list):
        if value == []:
            # no inner spec, just an empty list as the default value
            return IsA(list)
        elif len(value) == 1:
            # the only item as spec for each item of the collection
            return ListOf(translate(value[0]))
        else:
            raise StructureSpecificationError(
                'Expected a list containing exactly 1 item; '
                'got {cnt}: {spec}'.format(cnt=len(value), spec=value))

    if isinstance(value, dict):
        if not value:
            return IsA(dict)
        items = []
        for k, v in value.items():
            if isinstance(k, BaseValidator):
                k_validator = k
            else:
                k_validator = translate(k)
                default = k_validator.get_default_for(None)
                if default is not None:
                    k_validator = Equals(default)
            v_validator = translate(v)
            items.append((k_validator, v_validator))
        return DictOf(items)

    return IsA(type(value), default=value)
536248
def encodingStrings( reverse = false )
      @encodingStrings  = [ {"&" => "&amp;" },  {"<" => "&lt;"} , {">" => "&gt;"}, {"'" => "&apos;"}, {"\"" => "&quot;" }  ] if @encodingStrings.nil?
      if block_given?
         if reverse
            @encodingStrings.reverse_each{ |s| s.each{|k,v| yield v,k } }
         else
            @encodingStrings.each{ |s| s.each{|k,v| yield k,v }  }
         end
      else
         @encodingStrings
      end
   end
1167940
protected function visitTranslatedList(Generator $generator, array $translatedElements, $listName)
    {
        $generator->startHashElement($listName);
        $generator->startList('value');
        foreach ($translatedElements as $languageCode => $element) {
            $generator->startValueElement('value', $element, array('languageCode' => $languageCode));
            $generator->endValueElement('value');
        }
        $generator->endList('value');
        $generator->endHashElement($listName);
    }