Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: hermesdt/tolk
base: 211ac72670
...
head fork: hermesdt/tolk
compare: 808109e935
Checking mergeability… Don't worry, you can still create the pull request.
  • 5 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
3  Gemfile
@@ -1,3 +0,0 @@
-gem 'rails', '>= 3.2.0'
-gem 'will_paginate'
-gem 'ya2yaml'
View
18 app/models/tolk/locale.rb
@@ -134,9 +134,7 @@ def phrases_without_translation(page = nil, options = {})
existing_ids = self.translations.all(:select => 'tolk_translations.phrase_id').map(&:phrase_id).uniq
phrases = phrases.scoped(:conditions => ['tolk_phrases.id NOT IN (?)', existing_ids]) if existing_ids.present?
- result = phrases.paginate({:page => page}.merge(options))
- Tolk::Phrase.send :preload_associations, result, :translations
- result
+ phrases.paginate({:page => page}.merge(options))
end
def search_phrases(query, scope, page = nil, options = {})
@@ -163,9 +161,7 @@ def search_phrases_without_translation(query, page = nil, options = {})
existing_ids = self.translations.all(:select => 'tolk_translations.phrase_id').map(&:phrase_id).uniq
phrases = phrases.scoped(:conditions => ['tolk_phrases.id NOT IN (?) AND tolk_phrases.id IN(?)', existing_ids, found_translations_ids]) if existing_ids.present?
- result = phrases.paginate({:page => page}.merge(options))
- Tolk::Phrase.send :preload_associations, result, :translations
- result
+ phrases.paginate({:page => page}.merge(options))
end
def to_hash
@@ -200,18 +196,16 @@ def [](key)
end
def translations_with_html
- translations = self.translations.all(:conditions => "tolk_translations.text LIKE '%>%' AND
+ 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
end
private
def remove_invalid_translations_from_target
- self.translations.proxy_target.each do |t|
+ self.translations.each do |t|
unless t.valid?
- self.translations.proxy_target.delete(t)
+ self.translations.delete(t)
else
t.updated_at = Time.current # Silly hax to fool autosave into saving the record
end
@@ -225,8 +219,6 @@ def find_phrases_with_translations(page, conditions = {})
:conditions => { :'tolk_translations.locale_id' => self.id }.merge(conditions),
:joins => :translations, :order => 'tolk_phrases.key ASC')
- Tolk::Phrase.send :preload_associations, result, :translations
-
result.each do |phrase|
phrase.translation = phrase.translations.for(self)
end
View
2  app/models/tolk/translation.rb
@@ -110,7 +110,7 @@ def check_matching_variables
if primary_translation.variables.empty?
self.errors.add(:text, "The original does not contain variables, so they should not be included.")
else
- self.errors.add(:text, "The translation should contain the variables #{primary_translation.to_a.to_sentence}.")
+ self.errors.add(:text, "The translation should contain the variables #{primary_translation.variables.to_a.to_sentence}.")
end
end
end
View
8 lib/tasks/tolk_tasks.rake
@@ -7,6 +7,14 @@ namespace :tolk do
Rake::Task['tolk:sync'].invoke
Rake::Task['tolk:import'].invoke
end
+
+
+ desc "Delete all locales, translations and phrases (for developing purpose)"
+ task :clean_all => :environment do
+ Tolk::Locale.delete_all
+ Tolk::Translation.delete_all
+ Tolk::Phrase.delete_all
+ end
desc "Sync Tolk with the default locale's yml file"
task :sync => :environment do
View
3  lib/tolk.rb
@@ -2,5 +2,8 @@
require 'tolk/sync'
require 'tolk/import'
+require 'will_paginate'
+require 'ya2yaml'
+
module Tolk
end
View
3  tolk.gemspec
@@ -13,5 +13,8 @@ Gem::Specification.new do |s|
s.files = Dir['README', 'MIT-LICENSE', "config/*", 'lib/**/*', 'app/**/*', 'public/tolk/**/*']
s.has_rdoc = false
+ s.add_dependency("will_paginate", ">= 3.0.0")
+ s.add_dependency("ya2yaml", ">= 0.30.0")
+
s.require_path = 'lib'
end

No commit comments for this range

Something went wrong with that request. Please try again.