Permalink
Browse files

Merge branch 'rails3' of git://github.com/dhh/tolk

Conflicts:
	app/models/tolk/translation.rb
	test/locales/formats/en.yml
  • Loading branch information...
2 parents bd2f37d + 863399b commit 5b6f6c1f3c46926976248a21456077879ce11a60 @cover committed Nov 24, 2010
Showing with 92 additions and 3,619 deletions.
  1. +3 −0 CHANGELOG
  2. +1 −0 Gemfile
  3. +5 −15 README
  4. +1 −1 app/controllers/tolk/locales_controller.rb
  5. +1 −3 app/models/tolk/translation.rb
  6. +2 −2 app/views/tolk/locales/all.html.erb
  7. +1 −1 app/views/tolk/locales/index.html.erb
  8. +2 −2 app/views/tolk/locales/show.html.erb
  9. +1 −1 app/views/tolk/searches/_form.html.erb
  10. +2 −2 app/views/tolk/searches/show.html.erb
  11. +1 −1 config/routes.rb
  12. +0 −7 generators/tolk_migration/tolk_migration_generator.rb
  13. +0 −5 init.rb
  14. +3 −0 { → lib}/generators/tolk_migration/templates/migrate/create_tolk_tables.rb
  15. +19 −0 lib/generators/tolk_migration/tolk_migration_generator.rb
  16. +18 −0 { → lib}/tasks/tolk_tasks.rake
  17. +6 −0 lib/tolk.rb
  18. +7 −0 lib/tolk/engine.rb
  19. +0 −28 lib/tolk/link_renderer.rb
  20. +19 −0 tolk.gemspec
  21. +0 −43 vendor/plugins/will_paginate/.manifest
  22. +0 −139 vendor/plugins/will_paginate/CHANGELOG.rdoc
  23. +0 −18 vendor/plugins/will_paginate/LICENSE
  24. +0 −107 vendor/plugins/will_paginate/README.rdoc
  25. +0 −53 vendor/plugins/will_paginate/Rakefile
  26. BIN vendor/plugins/will_paginate/examples/apple-circle.gif
  27. +0 −69 vendor/plugins/will_paginate/examples/index.haml
  28. +0 −92 vendor/plugins/will_paginate/examples/index.html
  29. +0 −90 vendor/plugins/will_paginate/examples/pagination.css
  30. +0 −91 vendor/plugins/will_paginate/examples/pagination.sass
  31. +0 −1 vendor/plugins/will_paginate/init.rb
  32. +0 −90 vendor/plugins/will_paginate/lib/will_paginate.rb
  33. +0 −16 vendor/plugins/will_paginate/lib/will_paginate/array.rb
  34. +0 −144 vendor/plugins/will_paginate/lib/will_paginate/collection.rb
  35. +0 −43 vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb
  36. +0 −264 vendor/plugins/will_paginate/lib/will_paginate/finder.rb
  37. +0 −170 vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb
  38. +0 −37 vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb
  39. +0 −9 vendor/plugins/will_paginate/lib/will_paginate/version.rb
  40. +0 −408 vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb
  41. +0 −21 vendor/plugins/will_paginate/test/boot.rb
  42. +0 −143 vendor/plugins/will_paginate/test/collection_test.rb
  43. +0 −8 vendor/plugins/will_paginate/test/console
  44. +0 −22 vendor/plugins/will_paginate/test/database.yml
  45. +0 −473 vendor/plugins/will_paginate/test/finder_test.rb
  46. +0 −3 vendor/plugins/will_paginate/test/fixtures/admin.rb
  47. +0 −14 vendor/plugins/will_paginate/test/fixtures/developer.rb
  48. +0 −13 vendor/plugins/will_paginate/test/fixtures/developers_projects.yml
  49. +0 −15 vendor/plugins/will_paginate/test/fixtures/project.rb
  50. +0 −6 vendor/plugins/will_paginate/test/fixtures/projects.yml
  51. +0 −29 vendor/plugins/will_paginate/test/fixtures/replies.yml
  52. +0 −7 vendor/plugins/will_paginate/test/fixtures/reply.rb
  53. +0 −38 vendor/plugins/will_paginate/test/fixtures/schema.rb
  54. +0 −10 vendor/plugins/will_paginate/test/fixtures/topic.rb
  55. +0 −30 vendor/plugins/will_paginate/test/fixtures/topics.yml
  56. +0 −2 vendor/plugins/will_paginate/test/fixtures/user.rb
  57. +0 −35 vendor/plugins/will_paginate/test/fixtures/users.yml
  58. +0 −37 vendor/plugins/will_paginate/test/helper.rb
  59. +0 −43 vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb
  60. +0 −75 vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb
  61. +0 −11 vendor/plugins/will_paginate/test/lib/load_fixtures.rb
  62. +0 −179 vendor/plugins/will_paginate/test/lib/view_test_process.rb
  63. +0 −59 vendor/plugins/will_paginate/test/tasks.rake
  64. +0 −373 vendor/plugins/will_paginate/test/view_test.rb
  65. +0 −21 vendor/plugins/will_paginate/will_paginate.gemspec
View
@@ -0,0 +1,3 @@
+*Tolk 1.0.0 [June 6th, 2010]*
+
+* First public release as a Rails 3 engine gem
View
@@ -0,0 +1 @@
+gem 'will_paginate', :git => 'http://github.com/mislav/will_paginate.git', :branch => 'rails3'
View
@@ -1,28 +1,18 @@
-Tolk is a Rails engine designed to facilitate the translators doing the dirty work of translating your application to other languages.
+Tolk is a Rails 3 engine designed to facilitate the translators doing the dirty work of translating your application to other languages.
* This Fork
Adds auto translations on click via google translate. video is available here: http://www.tokumine.com/2010/07/18/using-tolk-with-google-translate/
* Installation & Setup
-To install :
+To install add the following to your Gemfile:
- $ script/plugin install git://github.com/dhh/tolk.git
+ gem 'tolk'
-To setup :
+To setup just run:
- 1) Generate tolk migration and migrate your database :
-
- $ script/generate tolk_migration
- $ rake db:migrate
-
- 2) Setup Tolk assets by creating a symlink to tolk/public/tolk inside your application's public directory :
-
- $ cd public
- $ ln -s ../vendor/plugins/tolk/public/tolk tolk
-
- And you're all set!
+ $ rake tolk:setup
* Usage
@@ -13,7 +13,7 @@ def show
@phrases = @locale.phrases_without_translation(params[:page])
end
format.atom { @phrases = @locale.phrases_without_translation(params[:page], :per_page => 50) }
- format.yml { render :text => @locale.to_hash.ya2yaml(:syck_compatible => true) }
+ format.yaml { render :text => @locale.to_hash.ya2yaml(:syck_compatible => true) }
end
end
@@ -2,9 +2,7 @@ module Tolk
class Translation < ActiveRecord::Base
set_table_name "tolk_translations"
- named_scope :containing_text, lambda { |query|
- { :conditions => ["tolk_translations.text LIKE ?", "%#{query}%"] }
- }
+ scope :containing_text, lambda {|query| where("tolk_translations.text LIKE ?", "%#{query}%") }
serialize :text
validates_presence_of :text, :if => proc {|r| r.primary.blank? && !r.explicit_nil }
@@ -15,7 +15,7 @@
<div class="translations">
<% if @phrases.any? %>
- <% form_for @locale do |locale_form| %>
+ <%= form_for @locale do |locale_form| %>
<table class="translations">
<tr>
<th class="translation"><%= @locale.language_name -%></th>
@@ -57,7 +57,7 @@
<p><%= locale_form.submit "Save changes" %></p>
</div>
<div class="paginate">
- <%= will_paginate @phrases, :renderer => Tolk::LinkRenderer %>
+ <%= will_paginate @phrases %>
</div>
<% end %>
<% else %>
@@ -19,7 +19,7 @@
<p>No locales yet.</p>
<% end %>
-<% form_for(Tolk::Locale.new) do |f| %>
+<%= form_for(Tolk::Locale.new) do |f| %>
<div class="submit">
<%= f.error_messages %>
<p>
@@ -19,7 +19,7 @@
<div class="translations">
<% if @phrases.any? %>
- <% form_for @locale do |locale_form| %>
+ <%= form_for @locale do |locale_form| %>
<table class="translations">
<tr>
<th class="translation"><%= @locale.language_name -%></th>
@@ -53,7 +53,7 @@
</div>
<% end %>
<div class="paginate">
- <%= will_paginate @phrases, :renderer => Tolk::LinkRenderer %>
+ <%= will_paginate @phrases %>
</div>
<% else %>
<p style="text-align: left">There aren't any missing or updated phrases that need translation.</p>
@@ -1,4 +1,4 @@
-<% form_tag "/tolk/search", :method => :get do %>
+<%= form_tag "/tolk/search", :method => :get do %>
<%= hidden_field_tag :locale, locale.name %>
Search for
<%= scope_selector_for(@locale) %>
@@ -14,7 +14,7 @@
<div class="translations">
<% if @phrases.any? %>
- <% form_for @locale do |locale_form| %>
+ <%= form_for @locale do |locale_form| %>
<table class="translations">
<tr>
<th class="translation"><%= @locale.language_name -%></th>
@@ -47,7 +47,7 @@
</div>
<% end %>
<div class="paginate">
- <%= will_paginate @phrases, :renderer => Tolk::LinkRenderer %>
+ <%= will_paginate @phrases %>
</div>
<% else %>
<p style="text-align: left">No search results.</p>
View
@@ -1,4 +1,4 @@
-ActionController::Routing::Routes.draw do |map|
+Rails.application.routes.draw do |map|
map.namespace('tolk') do |tolk|
tolk.root :controller => 'locales'
tolk.resources :locales, :member => {:all => :get, :updated => :get}
@@ -1,7 +0,0 @@
-class TolkMigrationGenerator < Rails::Generator::Base
- def manifest
- record do |m|
- m.migration_template "migrate/create_tolk_tables.rb", "db/migrate", :migration_file_name => "create_tolk_tables"
- end
- end
-end
View
@@ -1,10 +1,5 @@
Mime::Type.register_alias "text/yaml", :yml
-will_paginate = File.join(File.dirname(__FILE__), 'vendor/plugins/will_paginate')
-$: << File.join(will_paginate, 'lib')
-
-require File.join(will_paginate, 'init')
-
$KCODE = 'UTF8'
begin
require 'ya2yaml'
@@ -14,6 +14,8 @@ def self.up
t.datetime :updated_at
end
+ add_index :tolk_phrases, :key, :unique => true
+
create_table :tolk_translations do |t|
t.integer :phrase_id
t.integer :locale_id
@@ -29,6 +31,7 @@ def self.up
def self.down
remove_index :tolk_translations, :column => [:phrase_id, :locale_id]
+ remove_index :tolk_phrases, :column => :key
remove_index :tolk_locales, :column => :name
drop_table :tolk_translations
@@ -0,0 +1,19 @@
+class TolkMigrationGenerator < Rails::Generators::Base
+ include Rails::Generators::Migration
+
+ source_root File.expand_path("../templates", __FILE__)
+
+ def create_migration_file
+ migration_template "migrate/create_tolk_tables.rb", "db/migrate/create_tolk_tables.rb"
+ end
+
+ # Implement the required interface for Rails::Generators::Migration.
+ def self.next_migration_number(dirname) #:nodoc:
+ next_migration_number = current_migration_number(dirname) + 1
+ if ActiveRecord::Base.timestamped_migrations
+ [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
+ else
+ "%.3d" % next_migration_number
+ end
+ end
+end
@@ -1,4 +1,13 @@
namespace :tolk do
+ desc "Add database tables, copy over the assets, and import existing translations"
+ task :setup => :environment do
+ Rake::Task['tolk:import_assets'].invoke
+ system("rails generate tolk_migration")
+ Rake::Task['db:migrate'].invoke
+ Rake::Task['tolk:sync'].invoke
+ Rake::Task['tolk:import'].invoke
+ end
+
desc "Sync Tolk with the default locale's yml file"
task :sync => :environment do
Tolk::Locale.sync!
@@ -22,4 +31,13 @@ namespace :tolk do
puts "#{bt.phrase.key} - #{bt.text}"
end
end
+
+ desc "Copies required assets from tolk to application's public/ directory"
+ task :import_assets do
+ tolk_assets = File.expand_path(File.join(File.dirname(__FILE__), '../../public/tolk'))
+ command = "cp -R #{tolk_assets} #{Rails.root}/public/"
+ puts command
+ system(command)
+ end
+
end
View
@@ -1,2 +1,8 @@
+require 'will_paginate'
+require 'ya2yaml'
+require 'tolk/engine'
+require 'tolk/import'
+require 'tolk/sync'
+
module Tolk
end
View
@@ -0,0 +1,7 @@
+require 'rails'
+
+module Tolk
+ class Engine < Rails::Engine
+ engine_name :tolk
+ end
+end
@@ -1,28 +0,0 @@
-module Tolk
- class LinkRenderer < WillPaginate::LinkRenderer
- def to_html
- links = @options[:page_links] ? windowed_links : []
- # previous/next buttons
- links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label])
- links.push page_link_or_span(@collection.next_page, 'disabled next_page', @options[:next_label])
-
- html = links.join(@options[:separator])
- @options[:container] ? @template.content_tag(:div, safe_string(html), html_attributes) : safe_string(html)
- end
-
- protected
-
- def page_link(page, text, attributes = {})
- @template.link_to safe_string(text), url_for(page), attributes
- end
-
- def page_span(page, text, attributes = {})
- @template.content_tag :span, safe_string(text), attributes
- end
-
- def safe_string(string)
- string.respond_to?(:html_safe) ? string.html_safe : string.html_safe!
- end
-
- end
-end
View
@@ -0,0 +1,19 @@
+Gem::Specification.new do |s|
+ s.name = 'tolk'
+ s.version = '1.0'
+ s.summary = 'Rails engine providing web interface for managing i18n yaml files'
+ s.description = 'Tolk is a web interface for doing i18n translations packaged as an engine for Rails applications.'
+
+ s.author = 'David Heinemeier Hansson'
+ s.email = 'david@loudthinking.com'
+ s.homepage = 'http://www.rubyonrails.org'
+
+ s.platform = Gem::Platform::RUBY
+ s.add_dependency('will_paginate', '3.0.pre')
+ s.add_dependency('ya2yaml', '~> 0.26')
+
+ s.files = Dir['README', 'MIT-LICENSE', 'config/routes.rb', 'init.rb', 'lib/**/*', 'app/**/*', 'public/tolk/**/*']
+ s.has_rdoc = false
+
+ s.require_path = 'lib'
+end
@@ -1,43 +0,0 @@
-CHANGELOG.rdoc
-LICENSE
-README.rdoc
-Rakefile
-examples/apple-circle.gif
-examples/index.haml
-examples/index.html
-examples/pagination.css
-examples/pagination.sass
-init.rb
-lib/will_paginate.rb
-lib/will_paginate/array.rb
-lib/will_paginate/collection.rb
-lib/will_paginate/core_ext.rb
-lib/will_paginate/finder.rb
-lib/will_paginate/named_scope.rb
-lib/will_paginate/named_scope_patch.rb
-lib/will_paginate/version.rb
-lib/will_paginate/view_helpers.rb
-test/boot.rb
-test/collection_test.rb
-test/console
-test/database.yml
-test/finder_test.rb
-test/fixtures/admin.rb
-test/fixtures/developer.rb
-test/fixtures/developers_projects.yml
-test/fixtures/project.rb
-test/fixtures/projects.yml
-test/fixtures/replies.yml
-test/fixtures/reply.rb
-test/fixtures/schema.rb
-test/fixtures/topic.rb
-test/fixtures/topics.yml
-test/fixtures/user.rb
-test/fixtures/users.yml
-test/helper.rb
-test/lib/activerecord_test_case.rb
-test/lib/activerecord_test_connector.rb
-test/lib/load_fixtures.rb
-test/lib/view_test_process.rb
-test/tasks.rake
-test/view_test.rb
Oops, something went wrong.

0 comments on commit 5b6f6c1

Please sign in to comment.