rails-i18nterface 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/app/assets/javascripts/rails_i18nterface/base.js +17 -1
- data/app/assets/stylesheets/rails_i18nterface/application.css +40 -3
- data/app/controllers/rails_i18nterface/translate_controller.rb +14 -0
- data/app/views/rails_i18nterface/translate/index.html.erb +31 -21
- data/config/routes.rb +1 -0
- data/lib/rails-i18nterface/version.rb +1 -1
- data/spec/internal/log/test.log +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b88e2c4e5270456757b8c9a9b998f5ddb7def00
|
4
|
+
data.tar.gz: 64757f096941c68ed2ffa7862379a76a9f9c04e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70d0037c6d3ffc3386801e895de0843a8560cb39b2d861abfd6de87e8553233940da641f9e4c89b7116bc5675292aab1a625a381ece2dbe725773e12eba4d2ed
|
7
|
+
data.tar.gz: cc9315ef2a375204dba6cb998125f12b42cb1d94bc71fd3353f3fab79264854b7c45a971cf5c3ae1aafbfd7382a2b1734c5e069d63d7fe86b6cf9f3983f53c43
|
data/README.md
CHANGED
@@ -45,10 +45,12 @@ rake db:migrate
|
|
45
45
|
### Protect access
|
46
46
|
|
47
47
|
You may want to protect the translation engine to admin and create a constraint
|
48
|
-
in your routes:
|
48
|
+
in your routes (note that you don't want to mount it when you launch tests):
|
49
49
|
```ruby
|
50
50
|
constraints AdminConstraint.new do
|
51
|
-
|
51
|
+
unless Rails.env.test?
|
52
|
+
mount RailsI18nterface::Engine => "/translate", :as => "translate_engine"
|
53
|
+
end
|
52
54
|
end
|
53
55
|
```
|
54
56
|
|
@@ -58,5 +58,21 @@ $.domReady(function() {
|
|
58
58
|
filter = $(this).data("id");
|
59
59
|
filterThat(filter,false);
|
60
60
|
});
|
61
|
-
|
61
|
+
$(".delete").on("click", function(e) {
|
62
|
+
e.preventDefault();
|
63
|
+
e.stopPropagation();
|
64
|
+
key = $(this).previous().text();
|
65
|
+
if (confirm("Are you sure you want to delete the key "+key+" from database ?")) {
|
66
|
+
$.ajax({
|
67
|
+
url: 'delete/'+key,
|
68
|
+
method: 'delete',
|
69
|
+
success: function(resp) {
|
70
|
+
alert(resp);
|
71
|
+
},
|
72
|
+
error: function(resp,msg) {
|
73
|
+
alert("Error: "+resp.statusText);
|
74
|
+
}
|
75
|
+
})
|
76
|
+
}
|
77
|
+
});
|
62
78
|
});
|
@@ -390,16 +390,53 @@ div.translation em strong {
|
|
390
390
|
.translation .right {
|
391
391
|
float: right;
|
392
392
|
}
|
393
|
-
.translation .
|
394
|
-
padding:
|
393
|
+
.translation .files {
|
394
|
+
padding: 1px 5px;
|
395
395
|
background-color: #369;
|
396
396
|
color: #fff;
|
397
|
-
border-radius: 3px;
|
397
|
+
border-radius: 3px 3px 0 0;
|
398
|
+
float: right;
|
399
|
+
display: inline;
|
400
|
+
margin-left: 10px;
|
401
|
+
position: relative;
|
402
|
+
cursor: pointer;
|
403
|
+
}
|
404
|
+
|
405
|
+
.translation .files .count {
|
406
|
+
display: inline-block;
|
407
|
+
|
408
|
+
}
|
409
|
+
.translation .files .filelist {
|
410
|
+
display: none;
|
411
|
+
position: absolute;
|
412
|
+
top: 15px;
|
413
|
+
right: 0;
|
414
|
+
left: auto;
|
415
|
+
width: 300px;
|
416
|
+
background-color: #fff;
|
417
|
+
padding: 5px 10px;
|
418
|
+
border: 1px solid #369;
|
419
|
+
z-index: 1;
|
420
|
+
color: #000;
|
421
|
+
}
|
422
|
+
.translation .files:hover .filelist {
|
398
423
|
display: block;
|
399
424
|
}
|
400
425
|
.translation .key {
|
401
426
|
color: #666;
|
402
427
|
}
|
428
|
+
.translation .delete {
|
429
|
+
padding: 0 5px;
|
430
|
+
text-decoration: none;
|
431
|
+
background-color: #999;
|
432
|
+
color: #fff;
|
433
|
+
border-radius: 10px;
|
434
|
+
font-size: 10px;
|
435
|
+
font-weight: bold;
|
436
|
+
}
|
437
|
+
.translation .delete:hover {
|
438
|
+
background-color: #900;
|
439
|
+
}
|
403
440
|
.translation .keytext {
|
404
441
|
padding: 5px;
|
405
442
|
color: #678;
|
@@ -17,11 +17,25 @@ module RailsI18nterface
|
|
17
17
|
@total_entries = @keys.size
|
18
18
|
end
|
19
19
|
|
20
|
+
def destroy
|
21
|
+
term = Translation.find_by_key(params[:key])
|
22
|
+
if term.destroy!
|
23
|
+
render json: 'ok'
|
24
|
+
else
|
25
|
+
render json: 'error'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
20
29
|
def load_db_translations
|
21
30
|
@versions = {}
|
22
31
|
@dbvalues = {@to_locale => {}}
|
23
32
|
(Translation.where(:locale => @to_locale) || []).each { |translation|
|
24
33
|
@versions[translation.key] = translation.updated_at.to_i
|
34
|
+
yaml_value = I18n.backend.send(:lookup, @to_locale, translation.key)
|
35
|
+
if (yaml_value and translation.value != yaml_value)
|
36
|
+
translation.value = yaml_value
|
37
|
+
Translation.where(key: translation.key).first.update_attribute(:value, yaml_value)
|
38
|
+
end
|
25
39
|
@dbvalues[@to_locale][translation.key] = translation.value
|
26
40
|
@keys << translation.key
|
27
41
|
}
|
@@ -79,14 +79,19 @@
|
|
79
79
|
<div class="translation">
|
80
80
|
<p class="edit-form">
|
81
81
|
<%= hidden_field_tag("version[#{key}]", @versions[key] || '0') %>
|
82
|
-
|
83
|
-
<
|
82
|
+
<% if n_lines > 1 %>
|
83
|
+
<div class="right">
|
84
|
+
<% if @files[key] %>
|
85
|
+
<div class="files">
|
86
|
+
<div class="count">found in <%= @files[key].count %> files</div>
|
87
|
+
<div class="filelist">
|
88
|
+
<div><%= @files[key].join("</div><div>").html_safe %></div>
|
89
|
+
</div>
|
90
|
+
</div>
|
91
|
+
<% end %>
|
84
92
|
<span class="key"><%=h key %></span>
|
85
|
-
|
86
|
-
|
87
|
-
<% end %>
|
88
|
-
</span>
|
89
|
-
</span>
|
93
|
+
<a href="#" class="delete" title="Delete this key from database">X</a>
|
94
|
+
</div>
|
90
95
|
<div class="long-translation">
|
91
96
|
<div class="translation-text">
|
92
97
|
<pre id="<%= tid %>_original"><%= from_text %></pre>
|
@@ -98,21 +103,26 @@
|
|
98
103
|
</div>
|
99
104
|
<div class="clear"></div>
|
100
105
|
</div>
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
106
|
+
<% else %>
|
107
|
+
<div class="right">
|
108
|
+
<% if @files[key] %>
|
109
|
+
<div class="files">
|
110
|
+
<div class="count">found in <%= @files[key].count %> files</div>
|
111
|
+
<div class="filelist">
|
112
|
+
<div><%= @files[key].join("</div><div>").html_safe %></div>
|
113
|
+
</div>
|
114
|
+
</div>
|
115
|
+
<% end %>
|
116
|
+
<span class="key" ><%=h key %></span>
|
117
|
+
<a href="#" class="delete" title="Delete this key from database">X</a>
|
118
|
+
</div>
|
119
|
+
<div class="translation-text">
|
120
|
+
<code class="keytext" id="<%= tid %>_original"><%= from_text %></code>
|
121
|
+
</div>
|
112
122
|
|
113
|
-
|
114
|
-
|
115
|
-
|
123
|
+
<%= text_field_tag(field_name, to_text, :size => line_size, :id => tid) %>
|
124
|
+
<% end %>
|
125
|
+
</p>
|
116
126
|
<p>
|
117
127
|
</p>
|
118
128
|
</div>
|
data/config/routes.rb
CHANGED
@@ -4,4 +4,5 @@ RailsI18nterface::Engine.routes.draw do
|
|
4
4
|
put '/translate' => 'translate#update'
|
5
5
|
get '/reload' => 'translate#reload', :as => 'translate_reload'
|
6
6
|
get '/export' => 'translate#export', :as => 'translate_export'
|
7
|
+
delete '/delete/*key' => 'translate#destroy', format: false
|
7
8
|
end
|
data/spec/internal/log/test.log
CHANGED
@@ -519,3 +519,13 @@ Migrating to CreateTranslations (20110921112044)
|
|
519
519
|
[1m[35m (0.4ms)[0m CREATE TABLE "translations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar(255), "key" varchar(255), "value" text, "interpolations" text, "is_proc" boolean DEFAULT 'f', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
520
520
|
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')[0m
|
521
521
|
[1m[35m (151.3ms)[0m commit transaction
|
522
|
+
Connecting to database specified by database.yml
|
523
|
+
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
524
|
+
[1m[35m (214.8ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
525
|
+
[1m[36m (158.7ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
526
|
+
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
527
|
+
Migrating to CreateTranslations (20110921112044)
|
528
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
529
|
+
[1m[35m (0.3ms)[0m CREATE TABLE "translations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar(255), "key" varchar(255), "value" text, "interpolations" text, "is_proc" boolean DEFAULT 'f', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
530
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')[0m
|
531
|
+
[1m[35m (129.3ms)[0m commit transaction
|