translation_client 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/translation_client/application_controller.rb +6 -3
- data/app/controllers/translation_client/translations_controller.rb +67 -0
- data/app/helpers/translation_client/application_helper.rb +9 -0
- data/app/views/translation_client/translations/_form.html.erb +14 -0
- data/app/views/translation_client/translations/edit.html.erb +3 -0
- data/app/views/translation_client/translations/index.html.erb +27 -0
- data/app/views/translation_client/translations/new.html.erb +3 -0
- data/config/initializers/locale.rb +14 -0
- data/config/locales/resources/translations/en.yml +11 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20150312203345_initial_schema.rb +15 -0
- data/lib/translation_client.rb +6 -1
- data/lib/translation_client/concerns/model/translation.rb +13 -0
- data/lib/translation_client/engine.rb +14 -0
- data/lib/translation_client/version.rb +1 -1
- metadata +25 -3
- data/app/views/layouts/translation_client/application.html.erb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e160210a9efcf32662b105509566b5e076474ba
|
4
|
+
data.tar.gz: b5b65bb51a252390c302f5b8969dc01c7ca71aa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f379b467b35e129e5af6760949eaf62bf411d09c7e91f9d092bec0e6c3cb2120a1f04448baff11bc14c9200d18ecfa612e47262f7e1fadb4152b146baaba8a9
|
7
|
+
data.tar.gz: e6045935f986ca8d3490b5683cc6b7adc1f69c959dbf36aa9792262a65d8d5568f6837392d746f6f7904f4d72a9f2ddd6988eac78b246ffe543152acf5f2bc9a
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
class TranslationClient::ApplicationController < ActionController::Base
|
2
|
+
before_filter :my_method
|
3
|
+
|
4
|
+
def my_method
|
5
|
+
raise 'ok3:' + translation_client.translations_path
|
3
6
|
end
|
4
|
-
end
|
7
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class TranslationClient::TranslationsController < ApplicationController
|
2
|
+
before_filter :find_resource, only: [:edit, :update, :destroy]
|
3
|
+
|
4
|
+
respond_to :html
|
5
|
+
|
6
|
+
before_filter :authenticate_user!
|
7
|
+
|
8
|
+
def index
|
9
|
+
@translations = Translation.order('translation_key ASC')
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@translation = Translation.new(params[:i18n_backend_active_record_translation])
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
@translation = Translation.new(params[:i18n_backend_active_record_translation])
|
18
|
+
|
19
|
+
if @translation.save
|
20
|
+
I18n.backend.reload!
|
21
|
+
|
22
|
+
redirect_to [:edit, @translation], notice: t('general.form.successfully_created')
|
23
|
+
else
|
24
|
+
render :new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def edit
|
29
|
+
end
|
30
|
+
|
31
|
+
def update
|
32
|
+
if @translation.update_attributes(params[:i18n_backend_active_record_translation])
|
33
|
+
I18n.backend.reload!
|
34
|
+
|
35
|
+
redirect_to [:edit, @translation], notice: t('general.form.successfully_updated')
|
36
|
+
else
|
37
|
+
render :edit
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def destroy
|
42
|
+
@translation.destroy
|
43
|
+
I18n.backend.reload!
|
44
|
+
|
45
|
+
redirect_to translation_client.translations_path, notice: t('general.form.destroyed')
|
46
|
+
end
|
47
|
+
|
48
|
+
def resource
|
49
|
+
@translation
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def find_resource
|
55
|
+
@translation = Translation.find(params[:id])
|
56
|
+
end
|
57
|
+
|
58
|
+
def method_missing(m, *args, &block)
|
59
|
+
if m.to_s.match(/i18n_backend_active_record_translation/) && m.to_s.match(/path|url/)
|
60
|
+
translation_client.send m.to_s.gsub('i18n_backend_active_record_translation', 'translation'), *args, &block
|
61
|
+
elsif m.to_s.match(/path|url/) && main_app.respond_to?(m)
|
62
|
+
main_app.send m, *args, &block
|
63
|
+
else
|
64
|
+
super m, *args, &block
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -1,4 +1,13 @@
|
|
1
1
|
module TranslationClient
|
2
2
|
module ApplicationHelper
|
3
|
+
def method_missing(m, *args, &block)
|
4
|
+
if m.to_s.match(/i18n_backend_active_record_translation/) && m.to_s.match(/path|url/)
|
5
|
+
translation_client.send m.to_s.gsub('i18n_backend_active_record_translation', 'translation'), *args, &block
|
6
|
+
elsif m.to_s.match(/path|url/) && main_app.respond_to?(m)
|
7
|
+
main_app.send m, *args, &block
|
8
|
+
else
|
9
|
+
super m, *args, &block
|
10
|
+
end
|
11
|
+
end
|
3
12
|
end
|
4
13
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= simple_form_for @translation, html: { class: 'form-horizontal'} do |f| %>
|
2
|
+
<%= devise_error_messages! %>
|
3
|
+
|
4
|
+
<%= f.input :locale %>
|
5
|
+
<%= f.input :translation_key %>
|
6
|
+
<%= f.input :value %>
|
7
|
+
<%#= f.input :interpolations %>
|
8
|
+
|
9
|
+
<div class="form-group">
|
10
|
+
<div class="col-sm-offset-3 col-sm-9">
|
11
|
+
<%= f.button :submit %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<% content_for :title do %><%= t 'translation_client.translations.index.title' %><% end %>
|
2
|
+
<% if @translations.none? %>
|
3
|
+
<p><%= t('translation_client.translations.empty_collection') %></p>
|
4
|
+
<% else %>
|
5
|
+
<table class="table table-striped">
|
6
|
+
<thead>
|
7
|
+
<tr class="<%= cycle('odd', 'even') %>">
|
8
|
+
<th style="width: 25px; vertical-align:top;"><%= t('translation_client.translations.locale') %></th>
|
9
|
+
<th style="width: 200px; vertical-align:top;"><%= t('translation_client.translations.key') %></th>
|
10
|
+
<th></th>
|
11
|
+
</tr>
|
12
|
+
</thead>
|
13
|
+
<tbody>
|
14
|
+
<% @translations.each do |translation| %>
|
15
|
+
<tr class="<%= cycle('odd', 'even') %>">
|
16
|
+
<td><%= translation.locale %></td>
|
17
|
+
<td><%= link_to translation.translation_key, translation_client.edit_translation_path(translation) %></td>
|
18
|
+
<td><%= link_to t('general.destroy'), translation_client.translation_path(translation), method: :delete, class: 'btn btn-danger' %></td>
|
19
|
+
</tr>
|
20
|
+
<% end %>
|
21
|
+
</table>
|
22
|
+
<p>
|
23
|
+
<%= link_to translation_client.new_translation_path, class: 'btn btn-default' do %>
|
24
|
+
<span class="glyphicon glyphicon-plus"></span> <%= t('translation_client.translations.new.title') %>
|
25
|
+
<% end %>
|
26
|
+
</p>
|
27
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'i18n/backend/active_record'
|
2
|
+
|
3
|
+
Translation = I18n::Backend::ActiveRecord::Translation
|
4
|
+
|
5
|
+
if Translation.table_exists?
|
6
|
+
I18n.backend = I18n::Backend::ActiveRecord.new
|
7
|
+
|
8
|
+
I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Memoize)
|
9
|
+
I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Flatten)
|
10
|
+
I18n::Backend::Simple.send(:include, I18n::Backend::Memoize)
|
11
|
+
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
|
12
|
+
|
13
|
+
I18n.backend = I18n::Backend::Chain.new(I18n.backend, I18n::Backend::Simple.new)
|
14
|
+
end
|
data/config/routes.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
class InitialSchema < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :translations do |t|
|
4
|
+
t.string :locale
|
5
|
+
t.string :translation_key
|
6
|
+
t.text :value
|
7
|
+
t.text :interpolations
|
8
|
+
t.boolean :is_proc, :default => false
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :translations, [:locale, :translation_key], unique: true
|
14
|
+
end
|
15
|
+
end
|
data/lib/translation_client.rb
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
module TranslationClient
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace TranslationClient
|
4
|
+
|
5
|
+
config.autoload_paths << File.expand_path("../../../app/models/concerns", __FILE__)
|
6
|
+
config.autoload_paths << File.expand_path("../../../app/controllers/concerns", __FILE__)
|
7
|
+
config.i18n.load_path += Dir[File.expand_path("../../../config/locales/**/*.{rb,yml}", __FILE__)]
|
8
|
+
|
9
|
+
config.generators{|g| g.orm :active_record }
|
10
|
+
|
11
|
+
config.to_prepare do
|
12
|
+
I18n::Backend::ActiveRecord::Translation.send :include, ::TranslationClient::Concerns::Model::Translation
|
13
|
+
end
|
14
|
+
|
15
|
+
initializer 'translation_client.add_view_helpers' do |config|
|
16
|
+
ActionView::Base.send :include, TranslationClient::ApplicationHelper
|
17
|
+
end
|
4
18
|
end
|
5
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: translation_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Gawlista
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: i18n-active_record
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.2
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: home_page
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,11 +80,19 @@ files:
|
|
66
80
|
- Rakefile
|
67
81
|
- app/assets/stylesheets/translation_client/application.css
|
68
82
|
- app/controllers/translation_client/application_controller.rb
|
83
|
+
- app/controllers/translation_client/translations_controller.rb
|
69
84
|
- app/helpers/translation_client/application_helper.rb
|
70
|
-
- app/views/
|
85
|
+
- app/views/translation_client/translations/_form.html.erb
|
86
|
+
- app/views/translation_client/translations/edit.html.erb
|
87
|
+
- app/views/translation_client/translations/index.html.erb
|
88
|
+
- app/views/translation_client/translations/new.html.erb
|
89
|
+
- config/initializers/locale.rb
|
90
|
+
- config/locales/resources/translations/en.yml
|
71
91
|
- config/routes.rb
|
92
|
+
- db/migrate/20150312203345_initial_schema.rb
|
72
93
|
- lib/tasks/translation_client_tasks.rake
|
73
94
|
- lib/translation_client.rb
|
95
|
+
- lib/translation_client/concerns/model/translation.rb
|
74
96
|
- lib/translation_client/engine.rb
|
75
97
|
- lib/translation_client/version.rb
|
76
98
|
homepage: http://Volontari.at
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>TranslationClient</title>
|
5
|
-
<%= stylesheet_link_tag "translation_client/application", media: "all" %>
|
6
|
-
<%= javascript_include_tag "translation_client/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|