Created
April 17, 2014 11:46
-
-
Save simon-engledew/10976852 to your computer and use it in GitHub Desktop.
Rails 3 i18n Progress Visualizer
This file contains hidden or 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
# see how well you are doing localizing your site by flipping all localized text upside-down! | |
# anything being loaded from your en.yml will now be quite obvious! | |
if ENV['REVERSE'] | |
module I18n::Backend::Base | |
def flip(c) | |
case c | |
when "a" then return "\u0250" | |
when "b" then return "q" | |
when "c" then return "\u0254" | |
when "d" then return "p" | |
when "e" then return "\u01DD" | |
when "f" then return "\u025F" | |
when "g" then return "b" | |
when "h" then return "\u0265" | |
when "i" then return "\u0131" | |
when "j" then return "\u0638" | |
when "k" then return "\u029E" | |
when "l" then return "1" | |
when "m" then return "\u026F" | |
when "n" then return "u" | |
when "o" then return "o" | |
when "p" then return "d" | |
when "q" then return "b" | |
when "r" then return "\u0279" | |
when "s" then return "s" | |
when "t" then return "\u0287" | |
when "u" then return "n" | |
when "v" then return "\u028C" | |
when "w" then return "\u028D" | |
when "x" then return "x" | |
when "y" then return "\u028E" | |
when "z" then return "z" | |
when "[" then return "]" | |
when "]" then return "[" | |
when "(" then return ")" | |
when ")" then return "(" | |
when "{" then return "}" | |
when "}" then return "{" | |
when "?" then return "\u00BF" | |
when "\u00BF" then return "?" | |
when "!" then return "\u00A1" | |
when '"' then return ',' | |
when "," then return '"' | |
else return c | |
end | |
end | |
def translate_with_reverse(*args) | |
d = Nokogiri::HTML::fragment(translate_without_reverse(*args)) | |
d.traverse do |x| | |
x.content = x.content.each_char.map {|c| flip c.downcase }.reverse.join if x.text? | |
end | |
d.to_html(encoding: 'utf-8') | |
end | |
alias_method_chain :translate, :reverse | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment