couch_i18n 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- - title t("couch_i18n.store.new title")
1
+ - title t("couch_i18n.translation.new 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_translations), couch_i18n.translations_path(:offset => params[:offset])
@@ -1,7 +1,7 @@
1
1
  !!!
2
2
  %html
3
3
  %head
4
- %title= defined?(site_title) ? site_title : I18n.t('couch_i18n.store.site_title')
4
+ %title= defined?(site_title) ? site_title : I18n.t('couch_i18n.translation.site_title')
5
5
  = csrf_meta_tag
6
6
  = stylesheet_link_tag 'couch_i18n/application'
7
7
  = javascript_include_tag 'couch_i18n/application'
@@ -17,12 +17,30 @@ module CouchI18n
17
17
  # alias for read
18
18
  def [](key, options=nil)
19
19
  Rails.cache.fetch(key) do
20
- translation = CouchI18n::Translation.find_by_key(key.to_s)
21
- translation ||= CouchI18n::Translation.create(:key => key, :value => key.to_s.split('.').last, :translated => false)
20
+ old_database_name = get_couchrest_name
21
+ begin
22
+ set_couchrest_name CouchPotato::Config.database_name # Set database to original configured name
23
+ translation = CouchI18n::Translation.find_by_key(key.to_s)
24
+ translation ||= CouchI18n::Translation.create(:key => key, :value => key.to_s.split('.').last, :translated => false)
25
+ ensure
26
+ set_couchrest_name old_database_name
27
+ end
22
28
  translation.value
23
29
  end
24
30
  end
25
31
 
32
+ def set_couchrest_name(name)
33
+ d = CouchPotato.database.couchrest_database
34
+ d.instance_variable_set('@name', name)
35
+ d.instance_variable_set('@uri', "/#{name.gsub('/', '%2F')}")
36
+ d.instance_variable_set('@bulk_save_cache', [])
37
+ d.instance_variable_set('@root', d.host + d.uri)
38
+ end
39
+
40
+ def get_couchrest_name
41
+ CouchPotato.database.couchrest_database.name
42
+ end
43
+
26
44
  def keys
27
45
  CouchI18n::Translation.all.map(&:key)
28
46
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: couch_i18n
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.5
5
+ version: 0.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Benjamin ter Kuile