Permalink
Browse files

adding another method on the request

  • Loading branch information...
1 parent 869c686 commit 97b0a978e90e85a5c91e7898b76c59ff093aca91 @peburrows committed Feb 8, 2008
Showing with 8 additions and 1 deletion.
  1. +8 −1 app/models/translate_response_cache.rb
View
9 app/models/translate_response_cache.rb
@@ -1,6 +1,6 @@
class TranslateResponseCache
- [SiteController, Admin::AbstractModelController].each do |klass|
+ [SiteController, Admin::AbstractModelController, Admin::PageController].each do |klass|
klass.class_eval {
# yes, i know this is really bad, but we need it. otherwise, we'll have to reinvent the wheel
around_filter :do_something_bad
@@ -47,6 +47,13 @@ def language
lang.match(Regexp.new("^#{TranslatorExtension.defaults[:lang]}")) ? "" : lang
end
+ def language_full
+ lang = self.env['HTTP_ACCEPT_LANGUAGE']
+ m = lang.match(/^[a-zA-Z]{2}(\-[a-zA-Z]{2})?/)
+ # return the four letter (or two if no four was found) language string or nil if nothing was found
+ m ? m[0] : nil
+ end
+
def suffixize(lang)
lang.blank? ? "" : "_#{lang}"
end

0 comments on commit 97b0a97

Please sign in to comment.