monglobal 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -7
- data/app/Gemfile +1 -1
- data/app/config/environment.rb +0 -4
- data/app/config/initializers/monglobal.rb +4 -0
- data/lib/generators/monglobal/setup_generator.rb +2 -26
- data/lib/generators/monglobal/templates/model.rb +0 -13
- data/lib/generators/monglobal/templates/monglobal.rb +4 -0
- data/lib/monglobal/version.rb +1 -1
- data/lib/monglobal.rb +5 -0
- metadata +4 -2
data/README.rdoc
CHANGED
@@ -8,12 +8,9 @@ First add to your Gemfile
|
|
8
8
|
|
9
9
|
Then run bundle install
|
10
10
|
|
11
|
-
Then, you need to set up the LANGS
|
11
|
+
Then, you need to set up the LANGS constant.
|
12
12
|
|
13
|
-
|
14
|
-
for lang in I18n.available_locales
|
15
|
-
LANGS << lang.to_sym
|
16
|
-
end
|
13
|
+
rails g monglobal:setup
|
17
14
|
|
18
15
|
|
19
16
|
Then in your model:
|
@@ -50,6 +47,4 @@ Now your controller is pretty much the same with one difference to how you updat
|
|
50
47
|
The sample app here might help with some of the details of switching the locale and setting up the default locale.
|
51
48
|
|
52
49
|
|
53
|
-
TODO:
|
54
|
-
Get this set up on the gem repos
|
55
50
|
|
data/app/Gemfile
CHANGED
data/app/config/environment.rb
CHANGED
@@ -3,33 +3,9 @@ module Monglobal
|
|
3
3
|
class SetupGenerator < Rails::Generators::Base
|
4
4
|
source_root File.expand_path("../templates/", __FILE__)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# all public methods in here will be run in order
|
10
|
-
|
11
|
-
def build_translate_models
|
12
|
-
template "model.rb", "app/models/#{class_file_name}"
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
protected
|
18
|
-
|
19
|
-
def newklass
|
20
|
-
klass = model_name.constantize
|
21
|
-
return klass
|
22
|
-
end
|
23
|
-
|
24
|
-
def class_name
|
25
|
-
"#{model_name}Translation"
|
6
|
+
def build_initializer
|
7
|
+
template "monglobal.rb", "config/initializers/monglobal.rb"
|
26
8
|
end
|
27
9
|
|
28
|
-
def class_file_name
|
29
|
-
#"test"
|
30
|
-
"#{class_name}.rb"
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
10
|
end
|
35
11
|
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class <%= class_name %>
|
2
|
-
|
3
|
-
#This class was generated by Monglobal
|
4
|
-
#You should think twice before you edit this file
|
5
|
-
|
6
|
-
include MongoMapper::Document
|
7
|
-
include Monglobal::Translates
|
8
|
-
|
9
|
-
<% newklass.keys.each do |key, val| %><% if val.name != "_id" %>
|
10
|
-
<%= "key :#{val.name}, #{val.type}" %><% if val.default_value %>, :default => <%= val.default_value %><% end %><% end %><% end %>
|
11
|
-
key :locale, String
|
12
|
-
|
13
|
-
end
|
data/lib/monglobal/version.rb
CHANGED
data/lib/monglobal.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require "monglobal/version"
|
2
2
|
require 'active_support'
|
3
3
|
|
4
|
+
LANGS = []
|
5
|
+
for lang in I18n.available_locales
|
6
|
+
LANGS << lang.to_sym
|
7
|
+
end
|
4
8
|
|
5
9
|
module Monglobal
|
6
10
|
|
@@ -10,6 +14,7 @@ module Monglobal
|
|
10
14
|
end
|
11
15
|
|
12
16
|
def update_translation(locale, params)
|
17
|
+
|
13
18
|
if locale == "#{I18n.default_locale}"
|
14
19
|
#just update the main record
|
15
20
|
self.update_attributes(params)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: monglobal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Wylie Thomas
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2013-01-03 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- app/config/initializers/backtrace_silencers.rb
|
64
64
|
- app/config/initializers/inflections.rb
|
65
65
|
- app/config/initializers/mime_types.rb
|
66
|
+
- app/config/initializers/monglobal.rb
|
66
67
|
- app/config/initializers/mongo.rb
|
67
68
|
- app/config/initializers/secret_token.rb
|
68
69
|
- app/config/initializers/session_store.rb
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- app/vendor/plugins/.gitkeep
|
98
99
|
- lib/generators/monglobal/setup_generator.rb
|
99
100
|
- lib/generators/monglobal/templates/model.rb
|
101
|
+
- lib/generators/monglobal/templates/monglobal.rb
|
100
102
|
- lib/generators/monglobal/usage
|
101
103
|
- lib/monglobal.rb
|
102
104
|
- lib/monglobal/version.rb
|