couch_i18n 0.0.2 → 0.0.3
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/README.rdoc
CHANGED
@@ -57,3 +57,11 @@ And in _config/authorization_rules.rb_ put your personalized version of:
|
|
57
57
|
Beware that a permission denied message will appear when the server is restarted
|
58
58
|
this way. This is because the current user is set in ApplicationController which
|
59
59
|
is not part of the CouchI18n controller stack.
|
60
|
+
|
61
|
+
== TODO
|
62
|
+
Here my todo list for this project. Makes it insightful for everybody what is on
|
63
|
+
the planning of being made.
|
64
|
+
* Check on locale inclusion with are you sure? force creation of new locale. Mostly a stupic mistake omitting these.
|
65
|
+
* Add grouped deletes. Dangerous, but controllable using the declarative_authorization example
|
66
|
+
* Add grouped search/replaces to move one group of translations to another section. Same comment as above
|
67
|
+
* Search through values. If anyone has a better idea than searching by ruby through all the translations or adding lucene please feel free.
|
@@ -11,7 +11,7 @@ module CouchI18n
|
|
11
11
|
:offset => @levels[0..i].join('.')
|
12
12
|
}
|
13
13
|
end
|
14
|
-
@couch_i18n_stores = CouchI18n::Store.find_all_by_key(params[:offset]..
|
14
|
+
@couch_i18n_stores = CouchI18n::Store.find_all_by_key("#{params[:offset]}.".."#{params[:offset]}.\u9999", :page => params[:page], :per_page => 30)
|
15
15
|
@available_deeper_offsets = CouchI18n::Store.get_keys_by_level(@levels.size, :startkey => @levels, :endkey => @levels + [{}]).
|
16
16
|
map{|dl| {:name => dl, :offset => [params[:offset], dl].join('.')}}
|
17
17
|
else
|
@@ -32,7 +32,7 @@ module CouchI18n
|
|
32
32
|
def create
|
33
33
|
@couch_i18n_store = CouchI18n::Store.new params[:couch_i18n_store]
|
34
34
|
if @couch_i18n_store.save
|
35
|
-
redirect_to({:action => :index, :offset => @couch_i18n_store.key.to_s.sub(
|
35
|
+
redirect_to({:action => :index, :offset => @couch_i18n_store.key.to_s.sub(/\.[\w\s-]+$/, '')}, :notice => I18n.t('action.create.successful', :model => CouchI18n::Store.model_name.human))
|
36
36
|
else
|
37
37
|
render :action => :new
|
38
38
|
end
|
@@ -43,7 +43,7 @@ module CouchI18n
|
|
43
43
|
def update
|
44
44
|
@couch_i18n_store = CouchI18n::Store.find(params[:id])
|
45
45
|
if @couch_i18n_store.update_attributes(params[:couch_i18n_store])
|
46
|
-
redirect_to({:action => :index, :offset => @couch_i18n_store.key.to_s.sub(
|
46
|
+
redirect_to({:action => :index, :offset => @couch_i18n_store.key.to_s.sub(/\.[\w\s-]+$/, '')}, :notice => I18n.t('action.update.successful', :model => CouchI18n::Store.model_name.human))
|
47
47
|
else
|
48
48
|
render :action => :edit
|
49
49
|
end
|
@@ -1,4 +1,4 @@
|
|
1
1
|
- title t("couch_i18n.store.Edit title")
|
2
2
|
= render 'form'
|
3
3
|
- content_for :page_links do
|
4
|
-
= link_to link_to_index_content(:couch_i18n_stores), couch_i18n_stores_path(:offset => params[:offset])
|
4
|
+
= link_to link_to_index_content(:couch_i18n_stores), couch_i18n_stores_path(:offset => params[:offset] || @couch_i18n_store.key.to_s.sub(/\.[\w\s-]+$/, ''))
|
data/lib/couch_i18n/store.rb
CHANGED
data/lib/couch_i18n.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
require "i18n/backend/cache"
|
1
2
|
require "couch_i18n/engine"
|
2
3
|
require 'couch_i18n/store'
|
4
|
+
I18n::Backend::KeyValue.send(:include, I18n::Backend::Cache)
|
3
5
|
module CouchI18n
|
4
6
|
# This method imports yaml translations to the couchdb version. When run again new ones will
|
5
7
|
# be added. Translations already stored in the couchdb database are not overwritten
|
@@ -7,6 +9,7 @@ module CouchI18n
|
|
7
9
|
raise "I18.backend not a I18n::Backend::Chain" unless I18n.backend.is_a?(I18n::Backend::Chain)
|
8
10
|
#
|
9
11
|
yml_backend = I18n.backend.backends.last
|
12
|
+
|
10
13
|
raise "Last backend not a I18n::Backend::Simple" unless yml_backend.is_a?(I18n::Backend::Simple)
|
11
14
|
yml_backend.load_translations
|
12
15
|
flattened_hash = traverse_flatten_keys({}, yml_backend.send(:translations))
|
@@ -14,7 +17,6 @@ module CouchI18n
|
|
14
17
|
CouchI18n::Store.create :key => key, :value => value
|
15
18
|
end
|
16
19
|
end
|
17
|
-
private
|
18
20
|
|
19
21
|
# Recursive flattening.
|
20
22
|
def self.traverse_flatten_keys(store, obj, path = nil)
|
@@ -22,10 +24,10 @@ module CouchI18n
|
|
22
24
|
when Hash
|
23
25
|
obj.each{|k, v| traverse_flatten_keys(store, v, [path, k].compact.join('.'))}
|
24
26
|
when Array
|
25
|
-
store[path
|
27
|
+
store[path] = obj.to_json
|
26
28
|
#obj.each_with_index{|v, i| traverse_flatten_keys(store, v, [path, i].compact.join('.'))}
|
27
29
|
else
|
28
|
-
store[path
|
30
|
+
store[path] = obj
|
29
31
|
end
|
30
32
|
return store
|
31
33
|
end
|
@@ -33,3 +35,4 @@ end
|
|
33
35
|
|
34
36
|
# Now extend the I18n backend
|
35
37
|
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::KeyValue.new(CouchI18n::Store), I18n.backend)
|
38
|
+
I18n.cache_store = ActiveSupport::Cache.lookup_store(:memory_store)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Benjamin ter Kuile
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-05-
|
17
|
+
date: 2011-05-16 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|