Skip to content

Commit

Permalink
Merge pull request #957 from elzj/old_translation_plugins
Browse files Browse the repository at this point in the history
Issue 2232: Remove old translation plugins
  • Loading branch information
neuroalien committed Dec 9, 2012
2 parents fbc0031 + f38c36e commit dcd7e47
Show file tree
Hide file tree
Showing 48 changed files with 46 additions and 1,906 deletions.
5 changes: 0 additions & 5 deletions Gemfile
Expand Up @@ -44,11 +44,6 @@ gem 'paperclip', '>=2.3.16'
# for looking up image dimensions quickly
gem 'fastimage'

gem 'tolk',
:git => 'git://github.com/ambtus/tolk.git',
:branch => 'rails3',
:require => 'tolk'

gem 'authlogic',
:git => 'git://github.com/odorcicd/authlogic.git',
:branch => 'rails3',
Expand Down
11 changes: 0 additions & 11 deletions Gemfile.lock
@@ -1,12 +1,3 @@
GIT
remote: git://github.com/ambtus/tolk.git
revision: 0cf6384dd811ed38e658db3c77d170a95d08e276
branch: rails3
specs:
tolk (1.0)
will_paginate (~> 3.0.pre2)
ya2yaml (~> 0.26)

GIT
remote: git://github.com/odorcicd/authlogic.git
revision: a087ad0cba3c165ba22fcf176c28b6f7517931e8
Expand Down Expand Up @@ -259,7 +250,6 @@ GEM
activesupport (>= 2.3.4)
will_paginate (3.0.2)
xml-simple (1.0.12)
ya2yaml (0.30)
yard (0.6.1)

PLATFORMS
Expand Down Expand Up @@ -310,7 +300,6 @@ DEPENDENCIES
shoulda
timeliness
tire
tolk!
unicorn
valium
vcr
Expand Down
2 changes: 1 addition & 1 deletion app/models/chapter.rb
Expand Up @@ -160,7 +160,7 @@ def author_attributes=(attributes)
def validate_authors
return if self.new_record? && self.position == 1
if self.authors.blank? && self.pseuds.empty?
errors.add(:base, t('needs_author', :default => "Chapter must have at least one author."))
errors.add(:base, ts("Chapter must have at least one author."))
return false
end
end
Expand Down
14 changes: 7 additions & 7 deletions app/models/collection_participant.rb
Expand Up @@ -10,18 +10,18 @@ class CollectionParticipant < ActiveRecord::Base
MEMBER = PARTICIPANT_ROLES[3]
INVITED = PARTICIPANT_ROLES[4]
MAINTAINER_ROLES = [PARTICIPANT_ROLES[1], PARTICIPANT_ROLES[2]]
PARTICIPANT_ROLE_OPTIONS = [ [t('collection_participant.none', :default => "None"), NONE],
[t('collection_participant.none', :default => "Invited"), INVITED],
[t('collection_participant.member', :default => "Member"), MEMBER],
[t('collection_participant.moderator', :default => "Moderator"), MODERATOR],
[t('collection_participant.owner', :default => "Owner"), OWNER] ]
PARTICIPANT_ROLE_OPTIONS = [ [ts("None"), NONE],
[ts("Invited"), INVITED],
[ts("Member"), MEMBER],
[ts("Moderator"), MODERATOR],
[ts("Owner"), OWNER] ]

validates_uniqueness_of :pseud_id, :scope => [:collection_id],
:message => t('collection_participant.not_unique', :default => "That person appears to already be a participant in that collection.")
:message => ts("That person appears to already be a participant in that collection.")

validates_presence_of :participant_role
validates_inclusion_of :participant_role, :in => PARTICIPANT_ROLES,
:message => t('collection.item.invalid_type', :default => "That is not a valid participant role.")
:message => ts("That is not a valid participant role.")

scope :for_user, lambda {|user|
select("DISTINCT collection_participants.*").
Expand Down
8 changes: 4 additions & 4 deletions app/models/external_work.rb
Expand Up @@ -30,16 +30,16 @@ class ExternalWork < ActiveRecord::Base

validates_presence_of :title
validates_length_of :title, :minimum => ArchiveConfig.TITLE_MIN,
:too_short=> t('title_too_short', :default => "must be at least %{min} characters long.", :min => ArchiveConfig.TITLE_MIN)
:too_short=> ts("must be at least %{min} characters long.", :min => ArchiveConfig.TITLE_MIN)
validates_length_of :title, :maximum => ArchiveConfig.TITLE_MAX,
:too_long=> t('title_too_long', :default => "must be less than %{max} characters long.", :max => ArchiveConfig.TITLE_MAX)
:too_long=> ts("must be less than %{max} characters long.", :max => ArchiveConfig.TITLE_MAX)

validates_length_of :summary, :allow_blank => true, :maximum => ArchiveConfig.SUMMARY_MAX,
:too_long => t('summary_too_long', :default => "must be less than %{max} characters long.", :max => ArchiveConfig.SUMMARY_MAX)
:too_long => ts("must be less than %{max} characters long.", :max => ArchiveConfig.SUMMARY_MAX)

validates_presence_of :author
validates_length_of :author, :maximum => AUTHOR_LENGTH_MAX,
:too_long=> t('author_too_long', :default => "must be less than %{max} characters long.", :max => AUTHOR_LENGTH_MAX)
:too_long=> ts("must be less than %{max} characters long.", :max => AUTHOR_LENGTH_MAX)

# TODO: External works should have fandoms, but they currently don't get added through the
# post new work form so we can't validate them
Expand Down
8 changes: 4 additions & 4 deletions app/models/known_issue.rb
Expand Up @@ -7,17 +7,17 @@ class KnownIssue < ActiveRecord::Base
validates_presence_of :title
validates_length_of :title,
:minimum => ArchiveConfig.TITLE_MIN,
:too_short=> t('title_too_short', :default => "must be at least %{min} letters long.", :min => ArchiveConfig.TITLE_MIN)
:too_short=> ts("must be at least %{min} letters long.", :min => ArchiveConfig.TITLE_MIN)

validates_length_of :title,
:maximum => ArchiveConfig.TITLE_MAX,
:too_long=> t('title_too_long', :default => "must be less than %{max} letters long.", :max => ArchiveConfig.TITLE_MAX)
:too_long=> ts("must be less than %{max} letters long.", :max => ArchiveConfig.TITLE_MAX)

validates_presence_of :content
validates_length_of :content, :minimum => ArchiveConfig.CONTENT_MIN,
:too_short => t('content_too_short', :default => "must be at least %{min} letters long.", :min => ArchiveConfig.CONTENT_MIN)
:too_short => ts("must be at least %{min} letters long.", :min => ArchiveConfig.CONTENT_MIN)

validates_length_of :content, :maximum => ArchiveConfig.CONTENT_MAX,
:too_long => t('content_too_long', :default => "cannot be more than %{max} characters long.", :max => ArchiveConfig.CONTENT_MAX)
:too_long => ts("cannot be more than %{max} characters long.", :max => ArchiveConfig.CONTENT_MAX)

end
35 changes: 1 addition & 34 deletions app/models/locale.rb
Expand Up @@ -6,10 +6,6 @@ class Locale < ActiveRecord::Base
validates_uniqueness_of :iso
validates_presence_of :name

# FIXME: throws a method missing error in
# config/initializers/archive_config/locale.rb
# acts_as_authorizable # so that each locale can have authorized translators

def to_param
iso
end
Expand All @@ -19,38 +15,9 @@ def self.default
Locale.set_base_locale(:iso => ArchiveConfig.DEFAULT_LOCALE_ISO, :name => ArchiveConfig.DEFAULT_LOCALE_NAME, :language_id => language.id)
end

# Returns a floating point number between 0.0 and 1.0, reflecting the fraction of the translations that
# are up to date in this locale (i.e. that exist and are not older than the corresponding string for
# the main locale
def completeness
return 1.0 if main?

main_translations_count = Locale.find_main_cached.translations.count
main_translations = Locale.find_main_translations
local_translations = translations.inject({}) { |memo, tr| memo["#{tr.namespace}/#{tr.tr_key}"] = tr; memo }

outdated = 0
main_translations.each do |key, main_tr|
if !local_translations[key] || (local_translations[key].updated_at && main_tr.updated_at && local_translations[key].updated_at < main_tr.updated_at)
outdated += 1
end
end
(main_translations_count - outdated).to_f / main_translations_count
end

def self.find_main_cached
@@find_main_cached ||= find_by_main(1)
end

# Ensure that there's at least one locale in the database
def self.set_base_locale(locale={:iso => "en", :name => "English"})
language = Language.find_by_short(ArchiveConfig.DEFAULT_LANGUAGE_SHORT)
find_main_cached || Locale.find_by_iso(locale[:iso].to_s) || language.locales.create(:iso => locale[:iso].to_s, :name => locale[:name].to_s, :main => 1)
Locale.find_by_iso(locale[:iso].to_s) || language.locales.create(:iso => locale[:iso].to_s, :name => locale[:name].to_s, :main => 1)
end

# Sets up a hash with keys like "app.pages.membership/n_months_free" and values being
# translation activerecord objects
def self.find_main_translations
#find_main_cached.translations.inject({}) { |memo, tr| memo["#{tr.namespace}/#{tr.tr_key}"] = tr; memo }
end
end
2 changes: 1 addition & 1 deletion app/models/preference.rb
Expand Up @@ -4,7 +4,7 @@ class Preference < ActiveRecord::Base


validates_format_of :work_title_format, :with => /^[a-zA-Z0-9_\-,\. ]+$/,
:message => t('invalid_work_title_format', :default => "can only contain letters, numbers, spaces, and some limited punctuation (comma, period, dash, underscore).")
:message => ts("can only contain letters, numbers, spaces, and some limited punctuation (comma, period, dash, underscore).")

before_create :set_default_skin
def set_default_skin
Expand Down
32 changes: 16 additions & 16 deletions app/models/series.rb
Expand Up @@ -18,21 +18,21 @@ class Series < ActiveRecord::Base
validates_presence_of :title
validates_length_of :title,
:minimum => ArchiveConfig.TITLE_MIN,
:too_short=> t('title_too_short', :default => "must be at least %{min} letters long.", :min => ArchiveConfig.TITLE_MIN)
:too_short=> ts("must be at least %{min} letters long.", :min => ArchiveConfig.TITLE_MIN)

validates_length_of :title,
:maximum => ArchiveConfig.TITLE_MAX,
:too_long=> t('title_too_long', :default => "must be less than %{max} letters long.", :max => ArchiveConfig.TITLE_MAX)
:too_long=> ts("must be less than %{max} letters long.", :max => ArchiveConfig.TITLE_MAX)

validates_length_of :summary,
:allow_blank => true,
:maximum => ArchiveConfig.SUMMARY_MAX,
:too_long => t('summary_too_long', :default => "must be less than %{max} letters long.", :max => ArchiveConfig.SUMMARY_MAX)
:too_long => ts("must be less than %{max} letters long.", :max => ArchiveConfig.SUMMARY_MAX)

validates_length_of :notes,
:allow_blank => true,
:maximum => ArchiveConfig.NOTES_MAX,
:too_long => t('notes_too_long', :default => "must be less than %{max} letters long.", :max => ArchiveConfig.NOTES_MAX)
:too_long => ts("must be less than %{max} letters long.", :max => ArchiveConfig.NOTES_MAX)

after_save :adjust_restricted

Expand Down Expand Up @@ -112,19 +112,19 @@ def unrevealed?
!self.works.select { |work| work.unrevealed? }.empty?
end

# if the series includes an unrestricted work, restricted should be false
# if the series includes no unrestricted works, restricted should be true
def adjust_restricted
unless self.restricted? == !(self.works.where(:restricted => false).count > 0)
self.restricted = !(self.works.where(:restricted => false).count > 0)
self.save(:validate => false)
end
end
# if the series includes an unrestricted work, restricted should be false
# if the series includes no unrestricted works, restricted should be true
def adjust_restricted
unless self.restricted? == !(self.works.where(:restricted => false).count > 0)
self.restricted = !(self.works.where(:restricted => false).count > 0)
self.save(:validate => false)
end
end

# Change the positions of the serial works in the series
def reorder(positions)
SortableList.new(self.serial_works.in_order).reorder_list(positions)
end
# Change the positions of the serial works in the series
def reorder(positions)
SortableList.new(self.serial_works.in_order).reorder_list(positions)
end

# return list of pseuds on this series
def allpseuds
Expand Down
7 changes: 0 additions & 7 deletions config/initializers/gem-plugin_config/tolk_config.rb

This file was deleted.

12 changes: 12 additions & 0 deletions db/migrate/20121023221449_remove_old_translation_systems.rb
@@ -0,0 +1,12 @@
class RemoveOldTranslationSystems < ActiveRecord::Migration
def self.up
drop_table :tolk_locales
drop_table :tolk_phrases
drop_table :tolk_translations
drop_table :translation_notes
drop_table :translations
end

def self.down
end
end
19 changes: 0 additions & 19 deletions vendor/plugins/i18n_db/README.rdoc

This file was deleted.

6 changes: 0 additions & 6 deletions vendor/plugins/i18n_db/init.rb

This file was deleted.

65 changes: 0 additions & 65 deletions vendor/plugins/i18n_db/lib/i18n_db/action_controller.rb

This file was deleted.

0 comments on commit dcd7e47

Please sign in to comment.