trendi18n 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/LICENSE +22 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +19 -0
  4. data/Rakefile +54 -0
  5. data/VERSION +1 -0
  6. data/app/models/translation.rb +125 -0
  7. data/generators/trendi18n/templates/migrations/create_translations.rb +22 -0
  8. data/generators/trendi18n/trendi18n_generator.rb +8 -0
  9. data/lib/commands.rb +39 -0
  10. data/lib/file.rb +8 -0
  11. data/lib/trendi18n.rb +78 -0
  12. data/rails/init.rb +5 -0
  13. data/spec/test_application/README +243 -0
  14. data/spec/test_application/Rakefile +10 -0
  15. data/spec/test_application/app/controllers/application_controller.rb +10 -0
  16. data/spec/test_application/app/controllers/translations_controller.rb +41 -0
  17. data/spec/test_application/app/views/layouts/application.rhtml +15 -0
  18. data/spec/test_application/app/views/translations/_form.html.erb +11 -0
  19. data/spec/test_application/app/views/translations/edit.html.erb +6 -0
  20. data/spec/test_application/app/views/translations/index.html.erb +32 -0
  21. data/spec/test_application/app/views/translations/new.html.erb +7 -0
  22. data/spec/test_application/app/views/translations/show.html.erb +5 -0
  23. data/spec/test_application/config/boot.rb +110 -0
  24. data/spec/test_application/config/database.yml +25 -0
  25. data/spec/test_application/config/environment.rb +44 -0
  26. data/spec/test_application/config/environments/cucumber.rb +28 -0
  27. data/spec/test_application/config/environments/development.rb +17 -0
  28. data/spec/test_application/config/environments/production.rb +28 -0
  29. data/spec/test_application/config/environments/test.rb +34 -0
  30. data/spec/test_application/config/initializers/new_rails_defaults.rb +21 -0
  31. data/spec/test_application/config/initializers/session_store.rb +15 -0
  32. data/spec/test_application/config/locales/en.yml +5 -0
  33. data/spec/test_application/config/routes.rb +46 -0
  34. data/spec/test_application/db/migrate/20091208195455_create_translations.rb +22 -0
  35. data/spec/test_application/db/schema.rb +31 -0
  36. data/spec/test_application/db/seeds.rb +7 -0
  37. data/spec/test_application/features/dynamic_translation.feature +5 -0
  38. data/spec/test_application/features/managing_translations.feature +62 -0
  39. data/spec/test_application/features/static_translation.feature +13 -0
  40. data/spec/test_application/features/step_definitions/translations_steps.rb +12 -0
  41. data/spec/test_application/features/step_definitions/webrat_steps.rb +189 -0
  42. data/spec/test_application/features/support/env.rb +47 -0
  43. data/spec/test_application/features/support/paths.rb +42 -0
  44. data/spec/test_application/features/support/version_check.rb +31 -0
  45. data/spec/test_application/lib/tasks/cucumber.rake +46 -0
  46. data/spec/test_application/lib/tasks/rspec.rake +146 -0
  47. data/spec/test_application/public/404.html +30 -0
  48. data/spec/test_application/public/422.html +30 -0
  49. data/spec/test_application/public/500.html +30 -0
  50. data/spec/test_application/public/favicon.ico +0 -0
  51. data/spec/test_application/public/robots.txt +5 -0
  52. data/spec/test_application/script/about +4 -0
  53. data/spec/test_application/script/autospec +6 -0
  54. data/spec/test_application/script/console +3 -0
  55. data/spec/test_application/script/cucumber +17 -0
  56. data/spec/test_application/script/dbconsole +3 -0
  57. data/spec/test_application/script/destroy +3 -0
  58. data/spec/test_application/script/generate +3 -0
  59. data/spec/test_application/script/performance/benchmarker +3 -0
  60. data/spec/test_application/script/performance/profiler +3 -0
  61. data/spec/test_application/script/plugin +3 -0
  62. data/spec/test_application/script/runner +3 -0
  63. data/spec/test_application/script/server +3 -0
  64. data/spec/test_application/script/spec +10 -0
  65. data/spec/test_application/spec/backend_spec.rb +158 -0
  66. data/spec/test_application/spec/models/translation_spec.rb +109 -0
  67. data/spec/test_application/spec/rcov.opts +3 -0
  68. data/spec/test_application/spec/spec.opts +4 -0
  69. data/spec/test_application/spec/spec_helper.rb +54 -0
  70. metadata +156 -0
@@ -0,0 +1,41 @@
1
+ class TranslationsController < ApplicationController
2
+
3
+ def index
4
+ params[:condition] = "all" if params[:condition].blank?
5
+ @translations = Translation.localization(params[:localization]).send(params[:condition].downcase.to_sym) if ["untranslated", "translated", "all"].include?(params[:condition].downcase)
6
+ end
7
+
8
+ def new
9
+ @translation = Translation.new
10
+ end
11
+
12
+ def create
13
+ @translation = Translation.new(params[:translation])
14
+ if @translation.save
15
+ flash[:notice] = "Translation created!"
16
+ redirect_to translations_path
17
+ else
18
+ render :action => "new"
19
+ end
20
+ end
21
+
22
+ def edit
23
+ @translation = Translation.find(params[:id])
24
+ end
25
+
26
+ def update
27
+ @translation = Translation.find(params[:id])
28
+ if @translation.update_attributes(params[:translation])
29
+ flash[:notice] = "Translation updated"
30
+ redirect_to translations_path
31
+ else
32
+ render :action => "edit"
33
+ end
34
+ end
35
+
36
+ # show some static translations for tests
37
+ def show
38
+ @controller_message = I18n.t(:Key1)
39
+ end
40
+
41
+ end
@@ -0,0 +1,15 @@
1
+ <%#
2
+ # To change this template, choose Tools | Templates
3
+ # and open the template in the editor.
4
+ %>
5
+
6
+ <html>
7
+ <head>
8
+
9
+ </head>
10
+ <body>
11
+ <%= flash%>
12
+ <%= yield %>
13
+ </body>
14
+ </html>
15
+
@@ -0,0 +1,11 @@
1
+ <table>
2
+ <tr><td>Locale:</td><td> <%= text_field(:translation, :locale) %></td></tr>
3
+ <tr><td>Key:</td><td><%= text_field(:translation, :key) %></td></tr>
4
+ <tr><td>Scope:</td><td><%= text_field(:translation, :scope) %></td></tr>
5
+ <tr><td>Default:</td><td><%= text_field(:translation, :default) %></td></tr>
6
+ <tr><td>Translation:</td><td><%= text_field(:translation, :translation) %></td></tr>
7
+ <tr><td>Zero:</td><td><%= text_field(:translation, :zero) %></td></tr>
8
+ <tr><td>One:</td><td><%= text_field(:translation, :one) %></td></tr>
9
+ <tr><td>Many:</td><td><%= text_field(:translation, :many) %></td></tr>
10
+ <tr><td>Few:</td><td><%= text_field(:translation, :few) %></td></tr>
11
+ </table>
@@ -0,0 +1,6 @@
1
+ <%= error_messages_for 'translation' %>
2
+
3
+ <% form_for @translation, :url => {:action => "update"} do %>
4
+ <%= render :partial => "form" %>
5
+ <%= submit_tag("Save") %>
6
+ <% end %>
@@ -0,0 +1,32 @@
1
+ <table>
2
+ <tr>
3
+ <td>key</td>
4
+ <td>translation</td>
5
+ <td>scope</td>
6
+ <td>locale</td>
7
+ <td>default</td>
8
+ <td>zero</td>
9
+ <td>one</td>
10
+ <td>few</td>
11
+ <td>many</td>
12
+ <td>state</td>
13
+ <td>actions</td>
14
+ </tr>
15
+ <% for t in @translations %>
16
+ <tr>
17
+ <td><%= h t.key %></td>
18
+ <td><%= h t.translation%></td>
19
+ <td><%= h t.scope %>
20
+ <td><%= h t.locale %></td>
21
+ <td><%= h t.default %></td>
22
+ <td><%= h t.zero %></td>
23
+ <td><%= h t.one %></td>
24
+ <td><%= h t.few %></td>
25
+ <td><%= h t.many %></td>
26
+ <td><%= h t.state %></td>
27
+ <td><%= link_to("Edit translation", edit_translation_path(t)) %></td>
28
+ </tr>
29
+ <% end %>
30
+ </table>
31
+
32
+ <%= link_to("New translation", new_translation_path) %>
@@ -0,0 +1,7 @@
1
+ <%= error_messages_for 'translation'%>
2
+
3
+ <% form_tag @translation do %>
4
+ <%= render :partial => "form" %>
5
+ <%= submit_tag("Create") %>
6
+ <% end %>
7
+
@@ -0,0 +1,5 @@
1
+ <p><%= @controller_message %></p>
2
+ <p><%= I18n.t(:Key2, :scope => "scope1.subscope1") %></p>
3
+ <p><%= I18n.t(:Key3, :locale => "pl") %></p>
4
+ <p><%= I18n.t(:Key3) %></p>
5
+ <p><%= I18n.t(:Key4) %></p>
@@ -0,0 +1,110 @@
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
3
+
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
+
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
14
+
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
26
+
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exist?(preinitializer_path)
29
+ end
30
+
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
35
+
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
42
+
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ Rails::Initializer.run(:install_gem_spec_stubs)
47
+ Rails::GemDependency.add_frozen_gem_path
48
+ end
49
+ end
50
+
51
+ class GemBoot < Boot
52
+ def load_initializer
53
+ self.class.load_rubygems
54
+ load_rails_gem
55
+ require 'initializer'
56
+ end
57
+
58
+ def load_rails_gem
59
+ if version = self.class.gem_version
60
+ gem 'rails', version
61
+ else
62
+ gem 'rails'
63
+ end
64
+ rescue Gem::LoadError => load_error
65
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
+ exit 1
67
+ end
68
+
69
+ class << self
70
+ def rubygems_version
71
+ Gem::RubyGemsVersion rescue nil
72
+ end
73
+
74
+ def gem_version
75
+ if defined? RAILS_GEM_VERSION
76
+ RAILS_GEM_VERSION
77
+ elsif ENV.include?('RAILS_GEM_VERSION')
78
+ ENV['RAILS_GEM_VERSION']
79
+ else
80
+ parse_gem_version(read_environment_rb)
81
+ end
82
+ end
83
+
84
+ def load_rubygems
85
+ min_version = '1.3.2'
86
+ require 'rubygems'
87
+ unless rubygems_version >= min_version
88
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
+ exit 1
90
+ end
91
+
92
+ rescue LoadError
93
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
+ exit 1
95
+ end
96
+
97
+ def parse_gem_version(text)
98
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
+ end
100
+
101
+ private
102
+ def read_environment_rb
103
+ File.read("#{RAILS_ROOT}/config/environment.rb")
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ # All that for this:
110
+ Rails.boot!
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test: &TEST
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: db/production.sqlite3
21
+ pool: 5
22
+ timeout: 5000
23
+
24
+ cucumber:
25
+ <<: *TEST
@@ -0,0 +1,44 @@
1
+ # Be sure to restart your server when you modify this file
2
+
3
+ # Specifies gem version of Rails to use when vendor/rails is not present
4
+ RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
5
+
6
+ # Bootstrap the Rails environment, frameworks, and default configuration
7
+ require File.join(File.dirname(__FILE__), 'boot')
8
+
9
+ Rails::Initializer.run do |config|
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Add additional load paths for your own custom dirs
15
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
16
+
17
+ # Specify gems that this application depends on and have them installed with rake gems:install
18
+ # config.gem "bj"
19
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
20
+ config.gem "sqlite3-ruby", :lib => "sqlite3"
21
+ # config.gem "aws-s3", :lib => "aws/s3"
22
+
23
+ # Only load the plugins named here, in the order given (default is alphabetical).
24
+ # :all can be used as a placeholder for all plugins not explicitly named
25
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26
+
27
+ # Skip frameworks you're not going to use. To use Rails without a database,
28
+ # you must remove the Active Record framework.
29
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
30
+
31
+ # Activate observers that should always be running
32
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
33
+
34
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
35
+ # Run "rake -D time" for a list of tasks for finding time zone names.
36
+ config.time_zone = 'UTC'
37
+
38
+
39
+
40
+
41
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
42
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
43
+ # config.i18n.default_locale = :de
44
+ end
@@ -0,0 +1,28 @@
1
+ # IMPORTANT: This file was generated by Cucumber 0.4.4
2
+ # Edit at your own peril - it's recommended to regenerate this file
3
+ # in the future when you upgrade to a newer version of Cucumber.
4
+
5
+ config.cache_classes = true # This must be true for Cucumber to operate correctly!
6
+
7
+ # Log error messages when you accidentally call methods on nil.
8
+ config.whiny_nils = true
9
+
10
+ # Show full error reports and disable caching
11
+ config.action_controller.consider_all_requests_local = true
12
+ config.action_controller.perform_caching = false
13
+
14
+ # Disable request forgery protection in test environment
15
+ config.action_controller.allow_forgery_protection = false
16
+
17
+ # Tell Action Mailer not to deliver emails to the real world.
18
+ # The :test delivery method accumulates sent emails in the
19
+ # ActionMailer::Base.deliveries array.
20
+ config.action_mailer.delivery_method = :test
21
+
22
+ config.gem 'cucumber', :lib => false, :version => '>=0.4.4' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber'))
23
+ config.gem 'webrat', :lib => false, :version => '>=0.5.3' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
24
+ config.gem 'rspec', :lib => false, :version => '>=1.2.9' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
25
+ config.gem 'rspec-rails', :lib => false, :version => '>=1.2.9' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
26
+
27
+
28
+
@@ -0,0 +1,17 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_view.debug_rjs = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,28 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The production environment is meant for finished, "live" apps.
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.action_controller.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+ config.action_view.cache_template_loading = true
11
+
12
+ # See everything in the log (default is :info)
13
+ # config.log_level = :debug
14
+
15
+ # Use a different logger for distributed setups
16
+ # config.logger = SyslogLogger.new
17
+
18
+ # Use a different cache store in production
19
+ # config.cache_store = :mem_cache_store
20
+
21
+ # Enable serving of images, stylesheets, and javascripts from an asset server
22
+ # config.action_controller.asset_host = "http://assets.example.com"
23
+
24
+ # Disable delivery errors, bad email addresses will be ignored
25
+ # config.action_mailer.raise_delivery_errors = false
26
+
27
+ # Enable threaded mode
28
+ # config.threadsafe!
@@ -0,0 +1,34 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+ config.cache_classes = true
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+ config.action_view.cache_template_loading = true
16
+
17
+ # Disable request forgery protection in test environment
18
+ config.action_controller.allow_forgery_protection = false
19
+
20
+ # Tell Action Mailer not to deliver emails to the real world.
21
+ # The :test delivery method accumulates sent emails in the
22
+ # ActionMailer::Base.deliveries array.
23
+ config.action_mailer.delivery_method = :test
24
+
25
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
26
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
27
+ # like if you have constraints or database-specific column types
28
+ # config.active_record.schema_format = :sql
29
+
30
+ config.gem "rspec", :lib => false
31
+ config.gem "rspec-rails", :lib => false
32
+ config.gem "webrat", :lib => false
33
+ config.gem "cucumber", :lib => false
34
+ config.gem "rcov", :lib => false
@@ -0,0 +1,21 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # These settings change the behavior of Rails 2 apps and will be defaults
4
+ # for Rails 3. You can remove this initializer when Rails 3 is released.
5
+
6
+ if defined?(ActiveRecord)
7
+ # Include Active Record class name as root for JSON serialized output.
8
+ ActiveRecord::Base.include_root_in_json = true
9
+
10
+ # Store the full class name (including module namespace) in STI type column.
11
+ ActiveRecord::Base.store_full_sti_class = true
12
+ end
13
+
14
+ ActionController::Routing.generate_best_match = false
15
+
16
+ # Use ISO 8601 format for JSON serialized times and dates.
17
+ ActiveSupport.use_standard_json_time_format = true
18
+
19
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
20
+ # if you're including raw json in an HTML page.
21
+ ActiveSupport.escape_html_entities_in_json = false
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying cookie session data integrity.
4
+ # If you change this key, all old sessions will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ ActionController::Base.session = {
8
+ :key => '_praktyki_session',
9
+ :secret => '3a5952fd8e413d86a4d5631df2aba673bed55b5ce28a943aa7d74067107f860c66cc181c01a94c5068150a7df56feb9c61c7dc014c1104aa80b4f8bc9744bf00'
10
+ }
11
+
12
+ # Use the database for sessions instead of the cookie-based default,
13
+ # which shouldn't be used to store highly confidential information
14
+ # (create the session table with "rake db:sessions:create")
15
+ # ActionController::Base.session_store = :active_record_store
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,46 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+
4
+ # Sample of regular route:
5
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6
+ # Keep in mind you can assign values other than :controller and :action
7
+
8
+ # Sample of named route:
9
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
10
+ # This route can be invoked with purchase_url(:id => product.id)
11
+
12
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
13
+ # map.resources :products
14
+
15
+ # Sample resource route with options:
16
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
17
+
18
+ # Sample resource route with sub-resources:
19
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
20
+
21
+ # Sample resource route with more complex sub-resources
22
+ # map.resources :products do |products|
23
+ # products.resources :comments
24
+ # products.resources :sales, :collection => { :recent => :get }
25
+ # end
26
+
27
+ # Sample resource route within a namespace:
28
+ # map.namespace :admin do |admin|
29
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
30
+ # admin.resources :products
31
+ # end
32
+
33
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
34
+ # map.root :controller => "welcome"
35
+
36
+ # See how all your routes lay out with "rake routes"
37
+
38
+ # Install the default routes as the lowest priority.
39
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
40
+ # consider removing or commenting them out if you're using named routes and resources.
41
+
42
+ map.resources :translations
43
+
44
+ # map.connect ':controller/:action/:id'
45
+ # map.connect ':controller/:action/:id.:format'
46
+ end
@@ -0,0 +1,22 @@
1
+ class CreateTranslations < ActiveRecord::Migration
2
+ def self.up
3
+ create_table ActiveRecord::Base.pluralize_table_names ? :translations : :translation do |t|
4
+ t.string :locale, :null => false, :limit => 6
5
+ t.string :key, :null => false
6
+ t.string :scope
7
+ t.text :default, :null => false
8
+ t.text :translation
9
+ t.text :zero
10
+ t.text :one
11
+ t.text :many
12
+ t.text :few
13
+ t.string :state, :null => false
14
+ t.timestamps
15
+ end
16
+ add_index :translations, [:locale, :key, :scope], :unique => true
17
+ end
18
+
19
+ def self.down
20
+ drop_table ActiveRecord::Base.pluralize_table_names ? :translations : :translation
21
+ end
22
+ end
@@ -0,0 +1,31 @@
1
+ # This file is auto-generated from the current state of the database. Instead of editing this file,
2
+ # please use the migrations feature of Active Record to incrementally modify your database, and
3
+ # then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6
+ # to create the application database on another system, you should be using db:schema:load, not running
7
+ # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
9
+ #
10
+ # It's strongly recommended to check this file into your version control system.
11
+
12
+ ActiveRecord::Schema.define(:version => 20091208195455) do
13
+
14
+ create_table "translations", :force => true do |t|
15
+ t.string "locale", :limit => 6, :null => false
16
+ t.string "key", :null => false
17
+ t.string "scope"
18
+ t.text "default", :null => false
19
+ t.text "translation"
20
+ t.text "zero"
21
+ t.text "one"
22
+ t.text "many"
23
+ t.text "few"
24
+ t.string "state", :null => false
25
+ t.datetime "created_at"
26
+ t.datetime "updated_at"
27
+ end
28
+
29
+ add_index "translations", ["locale", "key", "scope"], :name => "index_translations_on_locale_and_key_and_scope", :unique => true
30
+
31
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Major.create(:name => 'Daley', :city => cities.first)
@@ -0,0 +1,5 @@
1
+ Feature: Dynamic translation
2
+ In order to understand the web page
3
+ As a language idiot
4
+ I want to be given data from the database in a selected language
5
+
@@ -0,0 +1,62 @@
1
+ Feature: Managing translations
2
+ In order to have more free time
3
+ As a clever developer
4
+ I want to be able to manage all translations through a Translation model
5
+
6
+ Scenario: List of translations
7
+ Given I have translated "Key1" to "Key1Translation" in "en" locale
8
+ And I have translated "Key2" to "Key2Translation" in "en" locale
9
+ When I go to the list of translations
10
+ Then I should see "Key1"
11
+ And I should see "Key1Translation"
12
+ And I should see "Key2"
13
+ And I should see "Key2Translation"
14
+
15
+ Scenario: List of finished translations
16
+ Given I have translated "Key1" to "Key1Translation" in "en" locale
17
+ And I have translated "Key2" to "" in "en" locale
18
+ When I go to the list of finished translations
19
+ Then I should see "Key1"
20
+ And I should not see "Key2"
21
+
22
+ Scenario: List of unfinished translations
23
+ Given I have translated "Key1" to "Key1Translation" in "en" locale
24
+ And I have translated "Key2" to "" in "en" locale
25
+ When I go to the list of unfinished translations
26
+ Then I should see "Key2"
27
+ And I should not see "Key1"
28
+
29
+ Scenario: List of translation in current locale
30
+ Given I have translated "Key1" to "Key1Translation" in "en" locale
31
+ And I have translated "Key1" to "Klucz1Tłumaczenie" in "pl" locale
32
+ When I go to the list of polish translations
33
+ Then I should see "Klucz1Tłumaczenie"
34
+ And I should not see "Key1Translation"
35
+
36
+ Scenario: Adding new translation
37
+ When I go to the list of translations
38
+ And I follow "New translation"
39
+ Then I should be on the new translation form
40
+ When I fill in "translation[key]" with "New translation"
41
+ And I fill in "translation[translation]" with "New translation is translated"
42
+ And I press "Create"
43
+ Then I should be on the list of translations
44
+ And I should see "Translation created!"
45
+ And I should see "New translation"
46
+ And I should see "New translation is translated"
47
+
48
+ Scenario: Editing translations
49
+ Given I have translated "Key1" to "Key1Translation" in "en" locale
50
+ When I go to the list of translations
51
+ And I follow "Edit translation"
52
+ Then I should be on the edit translation form
53
+ And I fill in "translation[translation]" with "Key1NewTranslation"
54
+ And I fill in "translation[many]" with "Key1Many"
55
+ And I press "Save"
56
+ Then I should be on the list of translations
57
+ And I should see "Translation updated"
58
+ And I should not see "Key1Translation"
59
+ And I should see "Key1NewTranslation"
60
+ And I should see "Key1Many"
61
+
62
+
@@ -0,0 +1,13 @@
1
+ Feature: Static translation
2
+ In order to understand the web page
3
+ As a language idiot
4
+ I want to be given static page elements in a selected language
5
+
6
+ #Scenario: Simple translations test
7
+ Given I have translated "Key1" to "Key1Translation" in "en" locale
8
+ And I have tranlated "Key2" to "Key2Translation" with scope "scope1.subscope1" in "en" locale
9
+ And I have translated "Key3" to "Klucz3Tłumaczenie" in "pl" locale
10
+ When I go to the translations test page
11
+ Then I should see "Key1Translation"
12
+ And I should see "Key2Translation"
13
+ And I should see "Klucz3Tłumaczenie"