<commit_before>require 'r18n-core'
# make sure we're running inside Merb
if defined?(Merb::Plugins)

  # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
  Merb::Plugins.config[:merb_i18n] = {
    :default_locale   => 'en',
    :untranslated => '<span style="color: red">%s</span>'
  }
  
  Merb.push_path(:i18n, Merb.root / :app / :i18n) unless Merb.load_paths.include?(:i18n)

  module MerbI18n
    
    module Controller
      # Return tool for i18n support. It will be R18n::I18n object, see it
      # documentation for more information.
      def i18n
        @i18n
      end

      def _set_i18n
        R18n::I18n.default = Merb::Plugins.config[:merb_i18n][:default_locale]

        locales = R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE'])
        locales.insert(0, params[:locale]) if params[:locale]

        @i18n = R18n::I18n.new(locales, self.i18n_dirs)
        R18n.set(@i18n)
      end

      # Namespaced i18n with controller and action name
      def ni18n
        @n18n ||= i18n.send(params[:controller]).send(params[:action])
      end

      # Dirs to load translations
      def i18n_dirs
        Merb.dir_for(:i18n)
      end<commit_msg>Use [] to access to translation by controller and action names<commit_after>require 'r18n-core'
# make sure we're running inside Merb
if defined?(Merb::Plugins)

  # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
  Merb::Plugins.config[:merb_i18n] = {
    :default_locale   => 'en',
    :untranslated => '<span style="color: red">%s</span>'
  }
  
  Merb.push_path(:i18n, Merb.root / :app / :i18n) unless Merb.load_paths.include?(:i18n)

  module MerbI18n
    
    module Controller
      # Return tool for i18n support. It will be R18n::I18n object, see it
      # documentation for more information.
      def i18n
        @i18n
      end

      def _set_i18n
        R18n::I18n.default = Merb::Plugins.config[:merb_i18n][:default_locale]

        locales = R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE'])
        locales.insert(0, params[:locale]) if params[:locale]

        @i18n = R18n::I18n.new(locales, self.i18n_dirs)
        R18n.set(@i18n)
      end

      # Namespaced i18n with controller and action name
      def ni18n
        @n18n ||= i18n[params[:controller]][params[:action]]
      end

      # Dirs to load translations
      def i18n_dirs
        Merb.dir_for(:i18n)
      end
{'fraction_non_alphanumeric': 0.11583637100040502, 'fraction_numerical': 0.0477926285945727, 'mean_word_length': 2.865414710485133, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2921759', 'n_tokens_mistral': 956, 'n_tokens_neox': 875, 'n_words': 204}