r18n-rails 0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path('../../config/boot', __FILE__)
3
+ require 'commands/server'
@@ -0,0 +1,77 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+
3
+ describe 'R18n for Rails', :type => :controller do
4
+ controller_name :test
5
+ integrate_views
6
+
7
+ it 'should use default locale' do
8
+ get :locales
9
+ response.should be_success
10
+ response.body.should == 'en'
11
+ end
12
+
13
+ it 'should get locale from param' do
14
+ get :locales, :locale => 'ru'
15
+ response.should be_success
16
+ response.body.should == 'ru, en'
17
+ end
18
+
19
+ it 'should get locale from session' do
20
+ get :locales, {}, { :locale => 'ru' }
21
+ response.should be_success
22
+ response.body.should == 'ru, en'
23
+ end
24
+
25
+ it 'should get locales from http' do
26
+ request.env['HTTP_ACCEPT_LANGUAGE'] = 'ru,fr;q=0.9'
27
+ get :locales
28
+ response.should be_success
29
+ response.body.should == 'ru, fr, en'
30
+ end
31
+
32
+ it 'should load translations' do
33
+ get :translations
34
+ response.should be_success
35
+ response.body.should == 'R18n: supported. Rails I18n: supported'
36
+ end
37
+
38
+ it 'should return available translations' do
39
+ get :available
40
+ response.should be_success
41
+ response.body.should == 'ru, en'
42
+ end
43
+
44
+ it 'should add helpers' do
45
+ get :helpers
46
+ response.should be_success
47
+ response.body.should == "Name\nName\nName\nName\n"
48
+ end
49
+
50
+ it 'should format untranslated' do
51
+ get :untranslated
52
+ response.should be_success
53
+ response.body.should == "user.<span style='color: red'>not.exists</span>"
54
+ end
55
+
56
+ it "should translate models" do
57
+ ActiveRecord::Schema.verbose = false
58
+ ActiveRecord::Schema.define(:version => 20091218130034) do
59
+ create_table "posts", :force => true do |t|
60
+ t.string "title_en"
61
+ t.string "title_ru"
62
+ end
63
+ end
64
+
65
+ @post = Post.new
66
+ @post.title_en = 'Record'
67
+
68
+ R18n.set(R18n::I18n.new('ru'))
69
+ @post.title.should == 'Record'
70
+
71
+ @post.title = 'Запись'
72
+ @post.title_ru.should == 'Запись'
73
+ @post.title_en.should == 'Record'
74
+ @post.title.should == 'Запись'
75
+ end
76
+
77
+ end
@@ -0,0 +1,6 @@
1
+ require 'pp'
2
+
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+ require File.expand_path(File.join(File.dirname(__FILE__), 'app/config/environment'))
5
+ require 'spec'
6
+ require 'spec/rails'
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: r18n-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.4"
5
+ platform: ruby
6
+ authors:
7
+ - Andrey "A.I." Sitnik
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-03 00:00:00 +03:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: r18n-rails-api
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: " Out-of-box R18n support for Ruby on Rails.\n It is just a wrapper for R18n Rails API and R18n core libraries.\n R18n has nice Ruby-style syntax, filters, flexible locales, custom loaders,\n translation support for any classes, time and number localization, several\n user language support, agnostic core package with out-of-box support for\n Rails, Sinatra, Merb and desktop applications.\n"
26
+ email: andrey@sitnik.ru
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ - LICENSE
34
+ files:
35
+ - lib/r18n-rails/helpers.rb
36
+ - lib/r18n-rails/controller.rb
37
+ - lib/r18n-rails.rb
38
+ - LICENSE
39
+ - README.rdoc
40
+ has_rdoc: true
41
+ homepage: http://r18n.rubyforge.org/
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ requirements: []
62
+
63
+ rubyforge_project: r18n-rails
64
+ rubygems_version: 1.3.5
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: R18n for Rails
68
+ test_files:
69
+ - spec/rails_spec.rb
70
+ - spec/spec_helper.rb
71
+ - spec/app/db/migrate/20091218123631_create_posts.rb
72
+ - spec/app/db/test.sqlite3
73
+ - spec/app/config/routes.rb
74
+ - spec/app/config/environment.rb
75
+ - spec/app/config/locales/en.yml
76
+ - spec/app/config/boot.rb
77
+ - spec/app/config/database.yml
78
+ - spec/app/config/initializers/session_store.rb
79
+ - spec/app/config/environments/development.rb
80
+ - spec/app/config/environments/production.rb
81
+ - spec/app/config/environments/test.rb
82
+ - spec/app/app/views/test/helpers.html.erb
83
+ - spec/app/app/helpers/application_helper.rb
84
+ - spec/app/app/i18n/ru.yml
85
+ - spec/app/app/i18n/en.yml
86
+ - spec/app/app/controllers/test_controller.rb
87
+ - spec/app/app/controllers/application_controller.rb
88
+ - spec/app/app/models/post.rb
89
+ - spec/app/log/test.log
90
+ - spec/app/script/server