<commit_before>class LocaleJs::LocaleController < ApplicationController
  
  # remember to add the locales route
  # map.connect '/locale/:action.:format', :controller => :locale
  # then add this to your layout <%= javascript_include_tag  "/locale/#{I18n.locale}.js" %>
  # your locale will be available in a javascript global: I18n
  
  rescue_from AbstractController::ActionNotFound, :with => :action_mising
  
  # this method searches the locales dir and then defines methods on this class for each locale
  Dir.glob(File.join(Rails.root,'config/locales/*.yml')).map do |file|
    locale = File.basename(file).match(/(.+)\.yml/)[1]
    define_method(locale) do
      generate_locale(locale)
    end
  end
  
  private
  def generate_locale(locale)
    expires_in(30.days)
    I18n.locale = locale
    # initialize i18n
    I18n.translate :hello
    @locale = I18n.backend.send(:translations)[I18n.locale]
    render :template => 'locale/i18n', :formats => [:js]
  end
  
  def action_missing(action)
    logger.debug("No config/locales/#{action}.yml exists! Reverting to #{I18n.default_locale}")
    generate_locale(I18n.default_locale)
  end

end<commit_msg>specify full ext<commit_after>class LocaleJs::LocaleController < ApplicationController
  
  # remember to add the locales route
  # map.connect '/locale/:action.:format', :controller => :locale
  # then add this to your layout <%= javascript_include_tag  "/locale/#{I18n.locale}.js" %>
  # your locale will be available in a javascript global: I18n
  
  rescue_from AbstractController::ActionNotFound, :with => :action_mising
  
  # this method searches the locales dir and then defines methods on this class for each locale
  Dir.glob(File.join(Rails.root,'config/locales/*.yml')).map do |file|
    locale = File.basename(file).match(/(.+)\.yml/)[1]
    define_method(locale) do
      generate_locale(locale)
    end
  end
  
  private
  def generate_locale(locale)
    expires_in(30.days)
    I18n.locale = locale
    # initialize i18n
    I18n.translate :hello
    @locale = I18n.backend.send(:translations)[I18n.locale]
    render :template => 'locale/i18n.js.erb'
  end
  
  def action_missing(action)
    logger.debug("No config/locales/#{action}.yml exists! Reverting to #{I18n.default_locale}")
    generate_locale(I18n.default_locale)
  end

end
{'fraction_non_alphanumeric': 0.11696158826068191, 'fraction_numerical': 0.01985325852395339, 'mean_word_length': 3.952991452991453, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, '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': '2881660', 'n_tokens_mistral': 781, 'n_tokens_neox': 742, 'n_words': 179}