dimarzio-model_translations 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +1 -1
- data/README +48 -5
- data/VERSION +1 -1
- data/model_translations.gemspec +2 -2
- metadata +2 -2
data/MIT-LICENSE
CHANGED
data/README
CHANGED
@@ -5,10 +5,9 @@ Plugin for translating data of your models.
|
|
5
5
|
|
6
6
|
features:
|
7
7
|
* dynamic additions of the languages
|
8
|
-
* all translations
|
8
|
+
* all translations go in one 'translations' table (version with the child translation tables for each model is in plans)
|
9
9
|
|
10
|
-
|
11
|
-
It uses I18n.locale to set and retrieve data.
|
10
|
+
Now it uses current locale to retrieve and set data.
|
12
11
|
Currently there is no way to dynamically switch the language except set I18n.locale (will be done in the future version).
|
13
12
|
|
14
13
|
Example
|
@@ -21,8 +20,52 @@ class Post < ActiveRecord::Base
|
|
21
20
|
:content
|
22
21
|
end
|
23
22
|
|
23
|
+
Don't create attributes to translate in the migration - it will not be used.
|
24
24
|
|
25
|
-
|
25
|
+
|
26
|
+
Install
|
27
|
+
=======
|
28
|
+
|
29
|
+
To install the plugin as gem add the following lines to your environment.rb
|
30
|
+
|
31
|
+
config.gem 'dimarzio-model_translations',
|
32
|
+
:lib => 'model_translations',
|
33
|
+
:source => 'http://gems.github.com'
|
34
|
+
|
35
|
+
and while I ain't created the generator (it will be done soon) you should add the following migration and model to your app:
|
36
|
+
|
37
|
+
class CreateTranslations < ActiveRecord::Migration
|
38
|
+
def self.up
|
39
|
+
create_table :translations do |t|
|
40
|
+
t.string :field, :null => false
|
41
|
+
t.string :value, :null => false
|
42
|
+
t.string :locale, :null => false
|
43
|
+
t.references :owner, :polymorphic => true, :null => false
|
44
|
+
|
45
|
+
t.timestamps
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.down
|
50
|
+
drop_table :translations
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Translation < ActiveRecord::Base
|
55
|
+
belongs_to :owner,
|
56
|
+
:polymorphic => true
|
57
|
+
|
58
|
+
validates_presence_of :field,
|
59
|
+
:value,
|
60
|
+
:locale,
|
61
|
+
:owner_id,
|
62
|
+
:owner_type
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
The suggestions and/or pull requests are all welcome!
|
26
69
|
|
27
70
|
|
28
|
-
Copyright (c) 2009 Dmitry
|
71
|
+
Copyright (c) 2009 Dmitry Afanasyev, released under the MIT license
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/model_translations.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{model_translations}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dmitry Afanasyev"]
|
12
|
-
s.date = %q{2009-08-
|
12
|
+
s.date = %q{2009-08-17}
|
13
13
|
s.description = %q{Rails plugin for translating data of your models.}
|
14
14
|
s.email = %q{dimarzio1986@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dimarzio-model_translations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Afanasyev
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|