Redefine the +translate+ method in ActionView (contributed by TranslationHelper) that is
 context-aware of what view (or partial) is being rendered.
 Initial scoping will be scoped to [:controller_name :view_name]
551033
def translate_with_context(key, options={})
      # default to an empty scope
      scope = []

      # Use the template for scoping if there is a templ
      unless self.template.nil?
        # The outer scope will typically be the controller name ("blog_posts")
        # but can also be a dir of shared partials ("shared").
        outer_scope = self.template.base_path
        
        # The template will be the view being rendered ("show.erb" or "_ad.erb")
        inner_scope = self.template.name
        
        # Partials template names start with underscore, which should be removed
        inner_scope.sub!(/^_/, '')

        scope = [outer_scope, inner_scope]
      end
      
      # In the case of a missing translation, fall back to letting TranslationHelper
      # put in span tag for a translation_missing.
      begin
        Translator.translate_with_scope(scope, key, options.merge({:raise => true}))
      rescue Translator::TranslatorError, I18n::MissingTranslationData => exc
        # Call the original translate method
        str = translate_without_context(key, options)
        
        # View helper adds the translation missing span like:
        # In strict mode, do not allow TranslationHelper to add "translation missing" span like:
        # <span class="translation_missing">en, missing_string</span>
        if str =~ /span class\=\"translation_missing\"/
          # In strict mode, do not allow TranslationHelper to add "translation missing"
          raise if Translator.strict_mode?
          
          # Invoke callback if it is defined
          Translator.missing_translation_callback(exc, key, options)
        end

        str
      end
    end
482381
def page_redirect_url(options = {})
      options = {
        locale: prefix_locale? ? @page.language_code : nil,
        urlname: @page.urlname
      }.merge(options)

      alchemy.show_page_path additional_params.merge(options)
    end
530663
def localized(locales = I18n.available_locales, opts = {})
      # Add if not added Rails.root/config/locales/*.yml in the I18n.load_path
      if !@i18n_routing_path_set and defined?(Rails) and Rails.respond_to?(:root) and Rails.root
        I18n.load_path = (I18n.load_path << Dir[Rails.root.join('config', 'locales', '*.yml')]).flatten.uniq
        @i18n_routing_path_set = true
      end

      old_value = @locales
      @locales = locales
      @i18n_verbose ||= opts.delete(:verbose)
      yield
    ensure
      @locales = old_value
    end
241390
@Override
    public View resolveViewName(String viewName, Locale locale) {
        if (viewName == null) {
            throw new IllegalArgumentException("Method argument viewName must not be null.");
        }

        if (viewName.startsWith(REDIRECT_URL_PREFIX)) {
            String redirectUrl = viewName.substring(REDIRECT_URL_PREFIX.length());
            return new SlingRedirectView(redirectUrl, true, true);
        }

        if (viewName.startsWith(FORWARD_URL_PREFIX)) {
            String forwardUrl = viewName.substring(FORWARD_URL_PREFIX.length());
            return new InternalResourceView(forwardUrl);
        }

        return resolveScriptingView(viewName);
    }
489619
def _get_handled_methods(self, actions_map):
        
        methods = ('OPTIONS',)

        defined_actions = []
        for action_name in actions_map.keys():
            view_method = getattr(self, action_name, None)
            method_exists = view_method is not None
            method_defined = view_method != self.not_allowed_action
            if method_exists and method_defined:
                defined_actions.append(action_name)

        for action in defined_actions:
            methods += actions_map[action]

        return methods
512729
public void apply(ActionContext context) {
        Boolean hasTemplate = context.hasTemplate();
        if (null != hasTemplate && hasTemplate) {
            RenderTemplate.get(context.successStatus()).apply(context);
            return;
        }
        H.Format fmt = context.accept();
        if (fmt == UNKNOWN) {
            H.Request req = context.req();
            if (req.userAgent().isIE9Down()) {
                fmt = HTML;
            } else {
                H.Method method = req.method();
                String methodInfo = S.concat(method.name(), " method to ");
                String acceptHeader = req.header(H.Header.Names.ACCEPT);
                throw E.unsupport(S.concat(
                        "Unknown accept content type(",
                        acceptHeader,
                        "): ",
                        methodInfo,
                        req.url()));
            }
        }
        Result result = null;
        if (JSON == fmt) {
            List<String> varNames = context.__appRenderArgNames();
            Map<String, Object> map = new HashMap<>(context.renderArgs());
            if (null != varNames && !varNames.isEmpty()) {
                for (String name : varNames) {
                    map.put(name, context.renderArg(name));
                }
            }
            result = new RenderJSON(map);
        } else if (XML == fmt) {
            List<String> varNames = context.__appRenderArgNames();
            Map<String, Object> map = new HashMap<>();
            if (null != varNames && !varNames.isEmpty()) {
                for (String name : varNames) {
                    map.put(name, context.renderArg(name));
                }
            }
            result = new FilteredRenderXML(map, null, context);
        } else if (HTML == fmt || TXT == fmt || CSV == fmt) {
            if (!ignoreMissingTemplate) {
                throw E.unsupport("Template[%s] not found", context.templatePath());
            }
            context.nullValueResultIgnoreRenderArgs().apply(context.req(), context.prepareRespForResultEvaluation());
            return;
        } else if (PDF == fmt || XLS == fmt || XLSX == fmt || DOC == fmt || DOCX == fmt) {
            List<String> varNames = context.__appRenderArgNames();
            if (null != varNames && !varNames.isEmpty()) {
                Object firstVar = context.renderArg(varNames.get(0));
                String action = S.str(context.actionPath()).afterLast(".").toString();
                if (firstVar instanceof File) {
                    File file = (File) firstVar;
                    result = new RenderBinary(file, action);
                } else if (firstVar instanceof InputStream) {
                    InputStream is = (InputStream) firstVar;
                    result = new RenderBinary(is, action);
                } else if (firstVar instanceof ISObject) {
                    ISObject sobj = (ISObject) firstVar;
                    result = new RenderBinary(sobj.asInputStream(), action);
                }
                if (null == result) {
                    throw E.unsupport("Unknown render arg type [%s] for binary response", firstVar.getClass());
                }
            } else {
                throw E.unexpected("No render arg found for binary response");
            }
        }
        if (null != result) {
            ActResponse<?> resp = context.prepareRespForResultEvaluation();
            result.status(context.successStatus()).apply(context.req(), resp);
        } else {
            throw E.unexpected("Unknown accept content type: %s", fmt.contentType());
        }
    }
1218318
def scope=(input)
      @scope = (input.instance_of?(Redistat::Scope)) ? input : Scope.new(input)
    end
28655
function updateLocalization() {
      $scope.model.areaOrder.forEach( areaName => {
         $scope.model.areas[ areaName ].forEach( button => {
            button.htmlLabel = i18n.localize( button.i18nHtmlLabel );
         } );
      } );
   }
1122707
def translate(context, hash)
      # makes sure that the context is a hash
      raise ArgumentError.new('did not pass a hash for the context') unless context.is_a?(Hash)
      raise ArgumentError.new('cannot provide include hash in context') if context[:hash]
      # create the context instance for instance variables
      struct = StructContext.new(context, hash)

      # instantiate MapMethods to perform translations and define lambda
      # for how to tranlate a field
      #

      translate = lambda { |t|
        MapMethods.send(t[:name], struct, t[:field], t[:block])
      }

      # determine the version of the incoming hash
      #
      struct_version = struct.instance_exec(&@migrations.version)

      raise StandardError.new('calculated version is not valid') unless Gem::Version.correct?(struct_version)

      # gets a list of the potential versions 
      #
      migration_versions = @migrations.translations.keys
      migration_versions.delete(:first)
      migration_versions.delete(:last)

      # get the first and last translations
      #
      firsts = @migrations.translations[:first]
      lasts = @migrations.translations[:last]

      # sorts the versions
      #
      migration_versions.sort! do |x,y|
        Gem::Version.new(x) <=> Gem::Version.new(y)
      end

      # reverse order if descending was specified
      #
      migration_versions = @migrations.order == :descending ? migration_versions.reverse : migration_versions
      # run the first translations if they exist
      #
      firsts.each(&translate) if firsts

      # determine the first version to run translations
      #
      first_index = @migrations.order == :ascending ? migration_versions.find_index(struct_version) : nil
      last_index = @migrations.order == :descending ? migration_versions.find_index(struct_version) : nil

      # run all subsequent version translations
      #
      migration_versions.each_with_index do |version, index|
        next unless !first_index || index >= first_index
        next unless !last_index || index <= last_index
        @migrations.translations[version].each(&translate)
      end

      # run the first translations if they exist
      #
      lasts.each(&translate) if lasts

      # return hash
      #
      struct.hash
    end
1220529
function(actionName, event){
        var action = this.action[actionName];

        if (action)
          action.call(this, event);

        /** @cut */ if (!action)
        /** @cut */   basis.dev.warn('template call `' + actionName + '` action, but it isn\'t defined in action list');
      }
49188
def render(view_name = nil, context: Attributor::DEFAULT_ROOT_CONTEXT, renderer: Renderer.new, **opts)
      if !view_name.nil?
        warn 'DEPRECATED: please do not pass the view name as the first parameter in Blueprint.render, pass through the view: named param instead.'
      elsif opts.key?(:view)
        view_name = opts[:view]
      end

      fields = opts[:fields]
      view_name = :default if view_name.nil? && fields.nil?

      if view_name
        unless (view = self.class.views[view_name])
          raise "view with name '#{view_name.inspect}' is not defined in #{self.class}"
        end
        return view.render(self, context: context, renderer: renderer)
      end

      # Accept a simple array of fields, and transform it to a 1-level hash with true values
      if fields.is_a? Array
        fields = fields.each_with_object({}) { |field, hash| hash[field] = true }
      end

      # expand fields
      expanded_fields = FieldExpander.expand(self.class, fields)

      renderer.render(self, expanded_fields, context: context)
    end
754263
def create_rails_view
      name = @view.underscore
      Rails.application.eager_load! if ApplicationController.descendants.length == 0
      controllers = ApplicationController.descendants.map { |cont| cont.name.gsub('Controller', '').underscore }
      dirname = controllers.include?(name) ? name : name.pluralize
      empty_directory "app/views/#{dirname}"
      if Gem.loaded_specs.has_key? 'haml-rails'
        file = "app/views/#{dirname}/index.html.haml"
        copy_file "boilerplate/views/rails_view.html.haml", file
        gsub_file file, /placeholder/, name
      else
        file = "app/views/#{dirname}/index.html.erb"
        copy_file "boilerplate/views/rails_view.html.erb", file
        gsub_file file, /placeholder/, name
      end
    end
968266
def target_view_path
        target_type = @target.to_resources_name
        view_path = [controller_path, target_type].join('/')
        lookup_context.exists?(action_name, view_path) ?
          view_path :
          [controller_path, DEFAULT_VIEW_DIRECTORY].join('/')
      end
1317989
def _resolve_view_params(self, request, defaults, *args, **kwargs):
        
        params = copy.copy(defaults)
        params.update(self.params)
        params.update(kwargs)
        resolved_params = {}
        
        extra_context = {}
        for key in params:
            # grab from provided params. 
            value = params[key]
            
            # otherwise grab from existing params
            if value == None:
                value = self.params[key] if self.params.has_key(key) else None
            
            # otherwise grab from class method
            if value == None:
                value = getattr(self, 'get_%s' % key)(request, *args, **kwargs) if getattr(self, 'get_%s' % key, None) else None

            if key in defaults:
                resolved_params[key] = value
            else:
                extra_context[key] = value
        
        if extra_context:
            try:
                resolved_params['extra_context'].update(extra_context)
            except AttributeError:
                resolved_params['extra_context'] = extra_context

        return resolved_params
682122
def translation_for(locale)
      @translation_caches ||= {}
      # Need to temporary switch of merging, because #translations uses
      # #attributes method too, to avoid stack level too deep error.
      @stop_merging_translated_attributes = true
      unless @translation_caches[locale]
        _translation = translations.find_by_locale(locale)
        _translation ||= translations.build(:locale => locale)
        @translation_caches[locale] = _translation
      end
      @stop_merging_translated_attributes = false
      @translation_caches[locale]
    end
605569
def _normalize_options(options)
        options = super(options)
        if options[:partial] == true
          options[:partial] = action_name
        end

        if (options.keys & [:partial, :file, :template]).empty?
          options[:prefixes] ||= _prefixes
        end

        options[:template] ||= (options[:action] || action_name).to_s
        options
      end
617576
def render(template, context = {})
      return nil unless exist?(template)

      path = File.join(@template_path, template + ".erb")
      layout_context = context.merge(partial: ERB.new(File.read(path)).result(Yokunai::RenderContext.new(context).get_binding))

      ERB.new(@raw_layout).result(Yokunai::RenderContext.new(layout_context).get_binding)
    end