couch_i18n 0.0.7 → 0.0.8
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 +4 -1
- data/app/controllers/couch_i18n/translations_controller.rb +3 -3
- data/app/helpers/couch_i18n/application_helper.rb +9 -9
- data/app/views/couch_i18n/application/_error_messages.html.haml +1 -1
- data/app/views/couch_i18n/translations/edit.html.haml +1 -1
- data/app/views/couch_i18n/translations/index.html.haml +8 -8
- data/app/views/couch_i18n/translations/new.html.haml +1 -1
- data/app/views/layouts/couch_i18n/application.html.haml +1 -1
- data/lib/couch_i18n/active_model_errors.rb +44 -0
- data/lib/couch_i18n/store.rb +2 -2
- data/lib/couch_i18n.rb +1 -0
- metadata +54 -40
data/README.rdoc
CHANGED
@@ -126,7 +126,7 @@ The following helpers are assumed:
|
|
126
126
|
t('Create')
|
127
127
|
end
|
128
128
|
def boolean_text(truefalse)
|
129
|
-
truefalse ? t('boolean true') : t('boolean false')
|
129
|
+
truefalse ? t('general.boolean true') : t('general.boolean false')
|
130
130
|
end
|
131
131
|
def are_you_sure(obj = nil)
|
132
132
|
t('Are you sure')
|
@@ -159,4 +159,7 @@ the planning of being made.
|
|
159
159
|
* Add grouped search/replaces to move one group of translations to another section. Same comment as above
|
160
160
|
* Search through values. If anyone has a better idea than searching by ruby through all the translations or adding lucene please feel free.
|
161
161
|
* A lot of testing
|
162
|
+
* Add referencing to other translations (big miss in I18n)
|
162
163
|
* Add error_messages partial to manual
|
164
|
+
* Only show translations of exact given offset (no children)
|
165
|
+
* Show translation matching exact the given offset (beware of caching or automatically adding structures)
|
@@ -34,7 +34,7 @@ module CouchI18n
|
|
34
34
|
@translation.value = JSON.parse(@translation.value)
|
35
35
|
end
|
36
36
|
if @translation.save
|
37
|
-
redirect_to({:action => :index, :offset => @translation.key.to_s.sub(/\.[\w\s-]+$/, '')}, :notice => I18n.t('action.create.successful', :model => CouchI18n::Translation.model_name.human))
|
37
|
+
redirect_to({:action => :index, :offset => @translation.key.to_s.sub(/\.[\w\s-]+$/, '')}, :notice => I18n.t('couch_i18n.action.create.successful', :model => CouchI18n::Translation.model_name.human))
|
38
38
|
else
|
39
39
|
render :action => :new
|
40
40
|
end
|
@@ -53,7 +53,7 @@ module CouchI18n
|
|
53
53
|
params[:translation]["value"] = JSON.parse(params[:translation]["value"])
|
54
54
|
end
|
55
55
|
if @translation.update_attributes(params[:translation])
|
56
|
-
redirect_to({:action => :index, :offset => @translation.key.to_s.sub(/\.[\w\s-]+$/, '')}, :notice => I18n.t('action.update.successful', :model => CouchI18n::Translation.model_name.human))
|
56
|
+
redirect_to({:action => :index, :offset => @translation.key.to_s.sub(/\.[\w\s-]+$/, '')}, :notice => I18n.t('couch_i18n.action.update.successful', :model => CouchI18n::Translation.model_name.human))
|
57
57
|
else
|
58
58
|
render :action => :edit
|
59
59
|
end
|
@@ -62,7 +62,7 @@ module CouchI18n
|
|
62
62
|
def destroy
|
63
63
|
@translation = CouchI18n::Translation.find(params[:id])
|
64
64
|
if @translation.destroy
|
65
|
-
flash[:notice] = I18n.t('action.destroy.successful', :model => CouchI18n::Translation.model_name.human)
|
65
|
+
flash[:notice] = I18n.t('couch_i18n.action.destroy.successful', :model => CouchI18n::Translation.model_name.human)
|
66
66
|
end
|
67
67
|
redirect_to({:action => :index, :offset => @translation.key.to_s.sub(/\.\w+$/, '')})
|
68
68
|
end
|
@@ -7,31 +7,31 @@ module CouchI18n
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def link_to_new_content(obj)
|
10
|
-
t('
|
10
|
+
t('couch_i18n.action.new.label')
|
11
11
|
end
|
12
12
|
def link_to_edit_content(obj = nil)
|
13
|
-
t('
|
13
|
+
t('couch_i18n.action.edit.label')
|
14
14
|
end
|
15
15
|
def link_to_show_content(obj = nil)
|
16
|
-
t('
|
16
|
+
t('couch_i18n.action.show.label')
|
17
17
|
end
|
18
18
|
def link_to_index_content(singular_name)
|
19
|
-
t('
|
19
|
+
t('couch_i18n.action.index.label')
|
20
20
|
end
|
21
21
|
def link_to_destroy_content(obj = nil)
|
22
|
-
t('
|
22
|
+
t('couch_i18n.action.destroy.label')
|
23
23
|
end
|
24
24
|
def update_button_text(obj = nil)
|
25
|
-
t('
|
25
|
+
t('couch_i18n.action.update.button_text')
|
26
26
|
end
|
27
27
|
def create_button_text(obj = nil)
|
28
|
-
t('
|
28
|
+
t('couch_i18n.action.create.button_text')
|
29
29
|
end
|
30
30
|
def boolean_show(truefalse)
|
31
|
-
truefalse ? t('
|
31
|
+
truefalse ? t('couch_i18n.general.boolean_true') : t('couch_i18n.general.boolean_false')
|
32
32
|
end
|
33
33
|
def are_you_sure(obj = nil)
|
34
|
-
t('
|
34
|
+
t('couch_i18n.general.are_you_sure')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
- title t("couch_i18n.
|
1
|
+
- title t("couch_i18n.action..edit.title")
|
2
2
|
= render 'form'
|
3
3
|
- content_for :page_links do
|
4
4
|
= link_to link_to_index_content(:translations), couch_i18n.translations_path(:offset => params[:offset] || @translation.key.to_s.sub(/\.[\w\s-]+$/, ''))
|
@@ -1,20 +1,20 @@
|
|
1
1
|
- if params[:offset].present?
|
2
2
|
- title params[:offset]
|
3
3
|
- else
|
4
|
-
- title t("couch_i18n.
|
4
|
+
- title t("couch_i18n.action.index.title")
|
5
5
|
.destroy-link
|
6
|
-
= link_to t('couch_i18n.
|
6
|
+
= link_to t('couch_i18n.action.destroy.offset_link'), couch_i18n.destroy_offset_translations_path(:offset => params[:offset]), :method => :delete, :confirm => (defined?(:are_you_sure) ? are_you_sure : t('couch_i18n.general.are_you_sure'))
|
7
7
|
.import-form
|
8
8
|
= form_tag({:action => :import}, :multipart => true) do
|
9
9
|
= file_field_tag :importfile
|
10
|
-
= submit_tag I18n.t('couch_i18n.
|
10
|
+
= submit_tag I18n.t('couch_i18n.import.button')
|
11
11
|
.export-form
|
12
12
|
= form_tag :action => :export do
|
13
13
|
= hidden_field_tag :offset, params[:offset]
|
14
14
|
= select_tag :exportformat, options_for_select(%w[yml csv json], params[:exportformat])
|
15
15
|
= check_box_tag :untranslated
|
16
|
-
= label_tag :untranslated, t('couch_i18n.
|
17
|
-
= submit_tag I18n.t('couch_i18n.
|
16
|
+
= label_tag :untranslated, t('couch_i18n.export.untranslated')
|
17
|
+
= submit_tag I18n.t('couch_i18n.export.execute')
|
18
18
|
.offset-navigation-block.block
|
19
19
|
.offset-navigation-higher
|
20
20
|
- for offset in @available_higher_offsets
|
@@ -22,10 +22,10 @@
|
|
22
22
|
.offset-navigation-form
|
23
23
|
= form_tag({}, :method => :get )do
|
24
24
|
- if params[:offset].present?
|
25
|
-
= link_to I18n.t('couch_i18n.
|
25
|
+
= link_to I18n.t('couch_i18n.general.go_to_zero_offset'), :offset => nil
|
26
26
|
= text_field_tag :offset, params[:offset], :size => 60
|
27
27
|
= "(#{@translations.total_entries})"
|
28
|
-
= submit_tag I18n.t('couch_i18n.
|
28
|
+
= submit_tag I18n.t('couch_i18n.general.go_to_offset')
|
29
29
|
.offset-navigation-deeper
|
30
30
|
- for offset in @available_deeper_offsets
|
31
31
|
= link_to offset[:name], :offset => offset[:offset]
|
@@ -48,7 +48,7 @@
|
|
48
48
|
%td.action.edit= link_to link_to_edit_content(translation), couch_i18n.edit_translation_path(translation)
|
49
49
|
%td.action.destroy= link_to link_to_destroy_content(translation),couch_i18n.translation_path(translation), :confirm => are_you_sure, :method => :delete
|
50
50
|
- else
|
51
|
-
%h3= t("
|
51
|
+
%h3= t("couch_i18n.general.none_found")
|
52
52
|
|
53
53
|
- content_for :page_links do
|
54
54
|
= link_to link_to_new_content(:translation), couch_i18n.new_translation_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.
|
4
|
+
%title= defined?(site_title) ? site_title : I18n.t('couch_i18n.general.site_title')
|
5
5
|
= csrf_meta_tag
|
6
6
|
= stylesheet_link_tag 'couch_i18n/application'
|
7
7
|
= javascript_include_tag 'couch_i18n/application'
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# This file overwrites the default activemode error message lookup behaviour.
|
2
|
+
|
3
|
+
module ActiveModel
|
4
|
+
class Errors
|
5
|
+
|
6
|
+
# The code for this method is base on rails revision: f3531a8fc9f661f96759f0a851540745876e5d6c
|
7
|
+
# The error lookup now consists of:
|
8
|
+
# namespace.errors.messages
|
9
|
+
def generate_message(attribute, type = :invalid, options = {})
|
10
|
+
type = options.delete(:message) if options[:message].is_a?(Symbol)
|
11
|
+
|
12
|
+
value = (attribute != :base ? @base.send(:read_attribute_for_validation, attribute) : nil)
|
13
|
+
|
14
|
+
# Create key. Remove class in model name and add errors.messages
|
15
|
+
key = (@base.class.model_name.underscore.sub(/\w+$/, '').scan(/\w+/) + ['errors.messages', type]).join('.')
|
16
|
+
|
17
|
+
options = {
|
18
|
+
:model => @base.class.model_name.human,
|
19
|
+
:attribute => @base.class.human_attribute_name(attribute),
|
20
|
+
:value => value
|
21
|
+
}.merge(options)
|
22
|
+
|
23
|
+
I18n.translate(key, options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def full_messages
|
27
|
+
map { |attribute, message| full_message(attribute, message) }
|
28
|
+
end
|
29
|
+
|
30
|
+
def full_message(attribute, message)
|
31
|
+
return message if attribute == :base
|
32
|
+
attr_name = attribute.to_s.gsub('.', '_').humanize
|
33
|
+
attr_name = @base.class.human_attribute_name(attribute, :default => attr_name)
|
34
|
+
|
35
|
+
# Create key. Remove class in model name and add errors.messages
|
36
|
+
key = (@base.class.model_name.underscore.sub(/\w+$/, '').scan(/\w+/) + ['errors.conjunction.attribute_message']).join('.')
|
37
|
+
I18n.t(key, {
|
38
|
+
:default => "%{attribute} %{message}",
|
39
|
+
:attribute => attr_name,
|
40
|
+
:message => message
|
41
|
+
})
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/couch_i18n/store.rb
CHANGED
@@ -15,14 +15,14 @@ module CouchI18n
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# alias for read
|
18
|
-
def [](key, options=
|
18
|
+
def [](key, options = {})
|
19
19
|
key = key.to_s.gsub('/', '.')
|
20
20
|
Rails.cache.fetch(key) do
|
21
21
|
old_database_name = get_couchrest_name
|
22
22
|
begin
|
23
23
|
set_couchrest_name CouchPotato::Config.database_name # Set database to original configured name
|
24
24
|
translation = CouchI18n::Translation.find_by_key(key.to_s)
|
25
|
-
translation ||= CouchI18n::Translation.create(:key => key, :value => key.to_s.split('.').last, :translated => false)
|
25
|
+
translation ||= CouchI18n::Translation.create(:key => key, :value => options[:default].presence || key.to_s.split('.').last, :translated => false)
|
26
26
|
ensure
|
27
27
|
set_couchrest_name old_database_name
|
28
28
|
end
|
data/lib/couch_i18n.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "couch_i18n/engine"
|
2
2
|
require 'couch_i18n/store'
|
3
3
|
require 'couch_i18n/backend'
|
4
|
+
require 'couch_i18n/active_model_errors'
|
4
5
|
module CouchI18n
|
5
6
|
# This method imports yaml translations to the couchdb version. When run again new ones will
|
6
7
|
# be added. Translations already stored in the couchdb database are not overwritten
|
metadata
CHANGED
@@ -1,82 +1,96 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: couch_i18n
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.8
|
4
5
|
prerelease:
|
5
|
-
version: 0.0.7
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Benjamin ter Kuile
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
date: 2011-12-14 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activemodel
|
16
|
+
requirement: &70285132887140 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70285132887140
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: simply_stored
|
27
|
+
requirement: &70285132886720 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70285132886720
|
36
|
+
description: couch_i18n is an in database storage for I18n translations, tested for
|
37
|
+
rails, with online management views
|
18
38
|
email: bterkuile@gmail.com
|
19
39
|
executables: []
|
20
|
-
|
21
40
|
extensions: []
|
22
|
-
|
23
41
|
extra_rdoc_files: []
|
24
|
-
|
25
|
-
|
26
|
-
- lib/couch_i18n/engine.rb
|
42
|
+
files:
|
43
|
+
- lib/couch_i18n/active_model_errors.rb
|
27
44
|
- lib/couch_i18n/backend.rb
|
45
|
+
- lib/couch_i18n/engine.rb
|
28
46
|
- lib/couch_i18n/store.rb
|
29
47
|
- lib/couch_i18n.rb
|
30
48
|
- lib/tasks/couch_i18n_tasks.rake
|
31
|
-
- app/models/couch_i18n/translation.rb
|
32
|
-
- app/controllers/couch_i18n/application_controller.rb
|
33
|
-
- app/controllers/couch_i18n/translations_controller.rb
|
34
|
-
- app/assets/javascripts/couch_i18n/structure.js
|
35
|
-
- app/assets/javascripts/couch_i18n/application.js
|
36
49
|
- app/assets/images/couch_i18n/alert.png
|
37
50
|
- app/assets/images/couch_i18n/notice.png
|
51
|
+
- app/assets/javascripts/couch_i18n/application.js
|
52
|
+
- app/assets/javascripts/couch_i18n/structure.js
|
38
53
|
- app/assets/stylesheets/couch_i18n/alerts.css.scss
|
39
|
-
- app/assets/stylesheets/couch_i18n/structure.css.scss
|
40
54
|
- app/assets/stylesheets/couch_i18n/application.css
|
55
|
+
- app/assets/stylesheets/couch_i18n/structure.css.scss
|
56
|
+
- app/controllers/couch_i18n/application_controller.rb
|
57
|
+
- app/controllers/couch_i18n/translations_controller.rb
|
41
58
|
- app/helpers/couch_i18n/application_helper.rb
|
59
|
+
- app/models/couch_i18n/translation.rb
|
42
60
|
- app/views/couch_i18n/application/_alerts.html.haml
|
43
61
|
- app/views/couch_i18n/application/_error_messages.html.haml
|
44
62
|
- app/views/couch_i18n/translations/_form.html.haml
|
45
|
-
- app/views/couch_i18n/translations/index.html.haml
|
46
63
|
- app/views/couch_i18n/translations/edit.html.haml
|
64
|
+
- app/views/couch_i18n/translations/index.html.haml
|
47
65
|
- app/views/couch_i18n/translations/new.html.haml
|
48
66
|
- app/views/layouts/couch_i18n/application.html.haml
|
49
67
|
- config/routes.rb
|
50
68
|
- MIT-LICENSE
|
51
69
|
- Rakefile
|
52
70
|
- README.rdoc
|
53
|
-
has_rdoc: true
|
54
71
|
homepage: http://github.com/bterkuile/couch_i18n
|
55
72
|
licenses: []
|
56
|
-
|
57
73
|
post_install_message:
|
58
74
|
rdoc_options: []
|
59
|
-
|
60
|
-
require_paths:
|
75
|
+
require_paths:
|
61
76
|
- lib
|
62
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
78
|
none: false
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version:
|
68
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
84
|
none: false
|
70
|
-
requirements:
|
71
|
-
- -
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version:
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
74
89
|
requirements: []
|
75
|
-
|
76
90
|
rubyforge_project: couch_i18n
|
77
|
-
rubygems_version: 1.
|
91
|
+
rubygems_version: 1.8.11
|
78
92
|
signing_key:
|
79
93
|
specification_version: 3
|
80
|
-
summary: couch_i18n is an in database storage for I18n translations, tested for rails,
|
94
|
+
summary: couch_i18n is an in database storage for I18n translations, tested for rails,
|
95
|
+
with online management views
|
81
96
|
test_files: []
|
82
|
-
|