Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed deprecated class method ApplicationController#globalize?
- Loading branch information
Luca Guidi
committed
Jul 16, 2008
1 parent
ba22d8b
commit aa9a58f
Showing
5 changed files
with
24 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,46 @@ | ||
class LocalesController < ApplicationController | ||
before_filter :check_globalize, :clear_cache | ||
before_filter :globalize?, :clear_cache | ||
|
||
def set | ||
Locale.set(params[:id]) if params[:id] | ||
session[:locale] = Locale.active | ||
session[:__globalize_translations] = nil | ||
logger.debug("[#{Time.now.to_s(:db)}] - Set current Locale on #{Locale.language}") | ||
redirect_to request.env['HTTP_REFERER'] if request.env['HTTP_REFERER'] | ||
end | ||
|
||
def translate | ||
if request.xhr? | ||
Locale.set_pluralized_translation(params[:key], 1, params[:value]) | ||
@formatted_value = params[:value] | ||
render :layout => false, :inline => "<%= #{inline} %>" | ||
end | ||
end | ||
|
||
def translate_unformatted | ||
if request.xhr? | ||
@unformatted_value = Locale.translate(params[:key]) | ||
render :layout => false, :inline => "<%= @unformatted_value %>" | ||
end | ||
end | ||
|
||
def translations | ||
if request.xhr? | ||
logger.debug("Translations got from the server: #{session[:__globalize_translations].inspect}") | ||
render :json => session[:__globalize_translations].to_json, :status => 200 | ||
end | ||
end | ||
|
||
private | ||
def check_globalize | ||
# Note: self.class.globalize? is deprecated. | ||
globalize? && self.class.globalize? | ||
end | ||
|
||
def clear_cache | ||
Locale.clear_cache | ||
end | ||
def clear_cache | ||
Locale.clear_cache | ||
end | ||
|
||
def inline | ||
case Locale.formatting | ||
when :textile then 'textilize_without_paragraph( @formatted_value )' | ||
when :markdown then 'markdown( @formatted_value )' | ||
else '@formatted_value' | ||
def inline | ||
case Locale.formatting | ||
when :textile then 'textilize_without_paragraph( @formatted_value )' | ||
when :markdown then 'markdown( @formatted_value )' | ||
else '@formatted_value' | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters