armot 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,31 +3,31 @@ Armot
3
3
 
4
4
  Armot is a minimal rails 3 library for handle your model translations. It's
5
5
  heavily based on [puret](https://github.com/jo/puret), by Johannes Jörg
6
- Schmidt, since it does basically the same but relying on i18n ActiveRecord
6
+ Schmidt, as it does basically the same but relying on the i18n ActiveRecord
7
7
  backend to store and fetch translations instead of custom tables.
8
8
 
9
9
  Choosing between puret or armot is as always a decision based on your custom
10
10
  requirements:
11
11
 
12
- 1. If your application is multilingual, and it's translated with default yaml
12
+ 1. If your application is multilingual and it's translated with default yaml
13
13
  files with i18n Simple backend, you should definitely go with Puret. In this
14
14
  scenario your application contents are multilingual but doesn't dynamically
15
15
  change, they're always the same.
16
16
 
17
- 2. If your application is multilingual, and also you want to give access to
18
- change it's contents, you might have chose to use another i18n backend like
19
- activerecord to be able to edit the translations in live. If this is your
20
- scenario, armot may give you a few advantages:
17
+ 2. If your application is multilingual and also you want to give access to
18
+ change it's contents, you might have chosen another i18n backend like
19
+ activerecord to be able to edit the translations in live. In this case
20
+ armot gives you some advantages:
21
21
 
22
22
  - Your translations are centralized. If you're giving your users (maybe the
23
23
  admins of the site) the ability to change it's multilingual contents, it
24
24
  means that you already have an interface to edit I18n translations. Use it
25
25
  to edit your model translations too.
26
- - Use of all i18n benefits for free, like fallbacks or speed up model
26
+ - Use all i18n advantages for free, like fallbacks or being able to speed up model
27
27
  translations with Flatten and Memoize.
28
- - No worry for eager loading translations every time you load translated
28
+ - Don't worry about eager loading translations every time you load translated
29
29
  models.
30
- - Easy setup, no external tables.
30
+ - Easy to set up, no external tables.
31
31
 
32
32
 
33
33
  Installing armot
@@ -71,8 +71,21 @@ Your translated model will have different contents for each locale transparently
71
71
 
72
72
 
73
73
  Be aware that armot doesn't take care of any cache expiration. If you're using
74
- Memoize with I18n ActiveRecord backend you must take care yourself to reload
75
- the backend with an observer, for example.
74
+ Memoize with I18n ActiveRecord backend you must remember to reload the backend
75
+ with an observer, for example.
76
+
77
+
78
+ Development with armot
79
+ ----------------------
80
+
81
+ Since armot stores model translations in an I18n ActiveRecord backend, in
82
+ development you also need to use that backend in order to see model
83
+ translations.
84
+
85
+ If you're using Simple backend in development I recomend you to chain it with
86
+ the ActiveRecord backend, this way you can see both of them.
87
+
88
+ I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend)
76
89
 
77
90
 
78
91
 
@@ -18,7 +18,7 @@ module Armot
18
18
  begin
19
19
  I18n.t "#{attribute}_#{id}", :scope => "armot.#{self.class.to_s.underscore.pluralize}.#{attribute}", :raise => true
20
20
  rescue I18n::MissingTranslationData
21
- self[attribute] || "translation missing: #{I18n.locale}.armot.#{self.class.to_s.underscore.pluralize}.#{attribute}.#{attribute}_#{id}"
21
+ self[attribute]
22
22
  end
23
23
  end
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module Armot
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -10,6 +10,7 @@ class PuretMigrationTest < ActiveSupport::TestCase
10
10
  I18n::Backend::ActiveRecord::Translation.delete_all
11
11
 
12
12
  PostTranslation.create(:post_id => Post.first.id, :locale => "en", :title => 'English title', :text => "Some text")
13
+ PostTranslation.create(:post_id => Post.first.id, :locale => "es", :title => 'Titulo español')
13
14
  PostTranslation.create(:post_id => Post.last.id, :locale => "en", :title => 'Second english title')
14
15
  end
15
16
 
@@ -20,17 +21,17 @@ class PuretMigrationTest < ActiveSupport::TestCase
20
21
  test "db setup" do
21
22
  assert_equal 0, I18n::Backend::ActiveRecord::Translation.count
22
23
  assert_equal 2, Post.count
23
- assert_equal 2, PostTranslation.count
24
+ assert_equal 3, PostTranslation.count
24
25
  end
25
26
 
26
27
  test "armot should not work" do
27
- assert_equal "translation missing: en.armot.posts.title.title_1", Post.first.title
28
+ assert_equal nil, Post.first.title
28
29
  end
29
30
 
30
31
  test "should create i18n records for exiting puret translations" do
31
32
  Armot::PuretIntegration.migrate
32
33
 
33
- assert_equal 3, I18n::Backend::ActiveRecord::Translation.count
34
+ assert_equal 4, I18n::Backend::ActiveRecord::Translation.count
34
35
  end
35
36
 
36
37
  test "translations with armot should work after migrate" do
@@ -43,7 +44,17 @@ class PuretMigrationTest < ActiveSupport::TestCase
43
44
  test "non existing translations reamain the same" do
44
45
  Armot::PuretIntegration.migrate
45
46
 
46
- assert_equal "translation missing: en.armot.posts.text.text_2", Post.last.text
47
+ assert_equal nil, Post.last.text
48
+ end
49
+
50
+ test "should preserve translations" do
51
+ Armot::PuretIntegration.migrate
52
+
53
+ post = Post.first
54
+ I18n.locale = :es
55
+ assert_equal "Titulo español", post.title
56
+ I18n.locale = :en
57
+ assert_equal "English title", post.title
47
58
  end
48
59
 
49
60
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: armot
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
4
+ hash: 25
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roger Campos
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-07 00:00:00 +01:00
18
+ date: 2011-03-14 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  requirements: []
150
150
 
151
151
  rubyforge_project: armot
152
- rubygems_version: 1.3.7
152
+ rubygems_version: 1.4.2
153
153
  signing_key:
154
154
  specification_version: 3
155
155
  summary: translation support for your models with an I18n active-record backend