Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Specify encoding

  • Loading branch information...
commit 1aebee577ef6c63f40f97f9e359ab7931a7fe06d 1 parent cd3d81e
@ZenCocoon authored
View
2  app/controllers/tolk/application_controller.rb
@@ -1,3 +1,5 @@
+# encoding: utf-8
+#
module Tolk
class ApplicationController < ActionController::Base
helper :all
View
4 app/controllers/tolk/locales_controller.rb
@@ -1,3 +1,5 @@
+# encoding: utf-8
+#
module Tolk
class LocalesController < Tolk::ApplicationController
before_filter :find_locale, :only => [:show, :all, :update, :updated]
@@ -6,7 +8,7 @@ class LocalesController < Tolk::ApplicationController
def index
@locales = Tolk::Locale.secondary_locales
end
-
+
def show
respond_to do |format|
format.html do
View
4 app/controllers/tolk/searches_controller.rb
@@ -1,7 +1,9 @@
+# encoding: utf-8
+#
module Tolk
class SearchesController < Tolk::ApplicationController
before_filter :find_locale
-
+
def show
@phrases = @locale.search_phrases(params[:q], params[:scope].to_sym, params[:page])
end
View
2  app/helpers/tolk/application_helper.rb
@@ -1,3 +1,5 @@
+# encoding: utf-8
+#
module Tolk
module ApplicationHelper
def format_i18n_value(value)
View
10 app/models/tolk/locale.rb
@@ -1,3 +1,5 @@
+# encoding: utf-8
+#
module Tolk
class Locale < ActiveRecord::Base
set_table_name "tolk_locales"
@@ -149,14 +151,14 @@ def search_phrases(query, scope, page = nil, options = {})
self.translations.containing_text(query)
end
- phrases = Tolk::Phrase.scoped(:order => 'tolk_phrases.key ASC')
+ phrases = Tolk::Phrase.scoped(:order => 'tolk_phrases.key ASC')
phrases = phrases.scoped(:conditions => ['tolk_phrases.id IN(?)', translations.map(&:phrase_id).uniq])
phrases.paginate({:page => page}.merge(options))
end
-
+
def search_phrases_without_translation(query, page = nil, options = {})
return phrases_without_translation(page, options) unless query.present?
-
+
phrases = Tolk::Phrase.scoped(:order => 'tolk_phrases.key ASC')
found_translations_ids = Tolk::Locale.primary_locale.translations.all(:conditions => ["tolk_translations.text LIKE ?", "%#{query}%"], :select => 'tolk_translations.phrase_id').map(&:phrase_id).uniq
@@ -198,7 +200,7 @@ def [](key)
end
def translations_with_html
- translations = self.translations.all(:conditions => "tolk_translations.text LIKE '%>%' AND
+ translations = self.translations.all(:conditions => "tolk_translations.text LIKE '%>%' AND
tolk_translations.text LIKE '%<%' AND tolk_phrases.key NOT LIKE '%_html'", :joins => :phrase)
Translation.send :preload_associations, translations, :phrase
translations
View
2  app/models/tolk/phrase.rb
@@ -1,3 +1,5 @@
+# encoding: utf-8
+#
module Tolk
class Phrase < ActiveRecord::Base
set_table_name "tolk_phrases"
View
4 app/models/tolk/translation.rb
@@ -1,3 +1,5 @@
+# encoding: utf-8
+#
module Tolk
class Translation < ActiveRecord::Base
set_table_name "tolk_translations"
@@ -54,7 +56,7 @@ def value
def self.detect_variables(search_in)
case search_in
- when String then Set.new(search_in.scan(/\{\{(\w+)\}\}/).flatten + search_in.scan(/\%\{(\w+)\}/).flatten)
+ when String then Set.new(search_in.scan(/\{\{(\w+)\}\}/).flatten + search_in.scan(/\%\{(\w+)\}/).flatten)
when Array then search_in.inject(Set[]) { |carry, item| carry + detect_variables(item) }
when Hash then search_in.values.inject(Set[]) { |carry, item| carry + detect_variables(item) }
else Set[]
Please sign in to comment.
Something went wrong with that request. Please try again.