Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Modified setup page so that it shows all locale files that have been …

…loaded rather than only the rb file.
  • Loading branch information...
commit 14903735a8fbc9a1c769f66e6682c2466c2bfd68 1 parent 3ede1b2
@clemens authored
View
6 app/controllers/application.rb
@@ -23,9 +23,13 @@ def set_locale
I18n.locale = session[:locale] || I18n.default_locale
# load locale from settings
+ @locale_files = []
['yml', 'rb'].each do |type|
locale_file = "#{LOCALES_DIRECTORY}#{I18n.locale}.#{type}"
- I18n.load_translations locale_file if File.exists?(locale_file)
+ if File.exists?(locale_file)
+ @locale_files << locale_file
+ I18n.load_translations locale_file
+ end
end
end
end
View
9 app/controllers/pages_controller.rb
@@ -1,11 +1,2 @@
class PagesController < ApplicationController
-
- def update_value
- render :text => params[:value]
- end
-
- def setup
- @locale_file = File.new("#{RAILS_ROOT}/config/locales/#{I18n.locale}.rb", "r")
- end
-
end
View
13 app/helpers/application_helper.rb
@@ -1,11 +1,14 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
- def show_source(file)
+ def show_locale_files
output = ''
- counter, lineWidth = 1, 80
- while(line = @locale_file.gets)
- output << "#{sprintf('%3d', counter)}: #{line}"
- counter += 1
+ @locale_files.sort.each do |locale_file|
+ output << "\n#{locale_file.sub(RAILS_ROOT + "/", "")}:\n\n"
+ counter, lineWidth = 1, 80
+ lines = *open(locale_file).map(&:rstrip).each do |line|
+ output << "#{sprintf('%3d', counter)}: #{line}\n"
+ counter += 1
+ end
end
output
end
View
2  app/views/pages/setup.html.erb
@@ -23,7 +23,7 @@ rake rails:freeze:edge
<p> <%= I18n.t 'txt.setup.locale' %></p>
<blockquote>
<pre>
-<%= show_source(@locale_file)%>
+<%= show_locale_files %>
</pre>
</blockquote>
<p><%= I18n.t 'txt.setup.defaults' %></p>
Please sign in to comment.
Something went wrong with that request. Please try again.