translate-rails3-plus 0.0.4 → 0.0.5

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.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/app/views/layouts/translate.html.erb +320 -270
  3. metadata +4 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.5
@@ -7,6 +7,51 @@
7
7
 
8
8
  <%= translate_javascript_includes %>
9
9
  <script type="text/javascript">
10
+
11
+ // Return elements which are in A but not in arg0 through argn
12
+ Array.prototype.diff =
13
+ function() {
14
+ var a1 = this;
15
+ var a = a2 = null;
16
+ var n = 0;
17
+ while(n < arguments.length) {
18
+ a = [];
19
+ a2 = arguments[n];
20
+ var l = a1.length;
21
+ var l2 = a2.length;
22
+ var diff = true;
23
+ for(var i=0; i<l; i++) {
24
+ for(var j=0; j<l2; j++) {
25
+ if (a1[i] === a2[j]) {
26
+ diff = false;
27
+ break;
28
+ }
29
+ }
30
+ diff ? a.push(a1[i]) : diff = true;
31
+ }
32
+ a1 = a;
33
+ n++;
34
+ }
35
+ return a.unique();
36
+ };
37
+
38
+ // Return new array with duplicate values removed
39
+ Array.prototype.unique =
40
+ function() {
41
+ var a = [];
42
+ var l = this.length;
43
+ for(var i=0; i<l; i++) {
44
+ for(var j=i+1; j<l; j++) {
45
+ // If this[i] is found later in the array
46
+ if (this[i] === this[j])
47
+ j = ++i;
48
+ }
49
+ a.push(this[i]);
50
+ }
51
+ return a;
52
+ };
53
+
54
+
10
55
  var source_ids = [];
11
56
 
12
57
  function googleCallback(response) {
@@ -55,41 +100,46 @@
55
100
 
56
101
  function checkErrors()
57
102
  {
58
- var errors = []
59
- $$('.translation-error').each(function(item) {
60
- item.removeClassName("translation-error")
61
- item.select('.error-text')[0].innerHTML = ""
62
- });
103
+ var errors = []
104
+ $$('.translation-error').each(function(item) {
105
+ item.removeClassName("translation-error")
106
+ item.select('.error-text')[0].innerHTML = ""
107
+ });
63
108
 
64
- $$('.single-translation').each(function(item) {
109
+ $$('.single-translation').each(function(item) {
65
110
  var val = item.select('.edit-field')[0].value
66
111
  if( !val.blank() )
67
112
  {
68
- var patt1=/\{[^\{\}]*\}/g;
69
- var val_subs = val.match(patt1)
70
- var key = item.select('.translation-text')[0].innerHTML
113
+ var patt1=/%\{[^\{\}]*\}/g;
114
+ var val_subs = val.match(patt1)
115
+ var key = item.select('.translation-text')[0].innerHTML
71
116
  var key_subs = key.match(patt1)
72
- if( val_subs == null ){ val_subs = [] }
73
- if( key_subs == null ){ key_subs = [] }
74
- if( val_subs.sort().join('') != key_subs.sort().join('') )
75
- {
117
+ if( val_subs == null ){ val_subs = [] }
118
+ if( key_subs == null ){ key_subs = [] }
119
+ if( val_subs.sort().join('') != key_subs.sort().join('') )
120
+ {
121
+ missing_subs = key_subs.diff( val_subs )
76
122
  item.addClassName("translation-error");
77
123
  errors.push( item )
78
- item.select('.error-text')[0].innerHTML = "Mismatched {} substitution strings."
79
- }
80
- }
124
+ item.select('.error-text')[0].innerHTML = "Missing substitution strings: " + missing_subs.join(', ')
125
+ }
126
+ }
81
127
  });
82
- return errors
128
+ return errors
83
129
  }
84
130
 
85
131
  function testAndSave()
86
132
  {
87
- var errors = checkErrors()
88
-
89
- if( errors.length == 0 || confirm( "Some transtalations have errors, save anyway?"))
90
- {
91
- document.forms["translate_form"].submit();
92
- }
133
+ var errors = checkErrors()
134
+
135
+ if( errors.length == 0 )
136
+ {
137
+ document.forms["translate_form"].submit();
138
+ }
139
+ else
140
+ {
141
+ alert( "Some transtalations have errors. Please review and correct errors before saving.")
142
+ }
93
143
  }
94
144
 
95
145
  /*
@@ -162,232 +212,232 @@
162
212
 
163
213
 
164
214
  <style type="text/css">
165
- /*reset.css*/
166
- /* v1.0 | 20080212 */
167
- html, body, div, span, applet, object, iframe,
168
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
169
- a, abbr, acronym, address, big, cite, code,
170
- del, dfn, em, font, img, ins, kbd, q, s, samp,
171
- small, strike, strong, sub, sup, tt, var,
172
- b, u, i, center,
173
- dl, dt, dd, ol, ul, li,
174
- fieldset, form, label, legend,
175
- table, caption, tbody, tfoot, thead, tr, th, td {
176
- margin: 0;
177
- padding: 0;
178
- border: 0;
179
- outline: 0;
180
- font-size: 100%;
181
- vertical-align: baseline;
182
- background: transparent;
183
- }
184
- body {
185
- line-height: 1;
186
- }
187
- ol, ul {
188
- list-style: none;
189
- }
190
- blockquote, q {
191
- quotes: none;
192
- }
193
- blockquote:before, blockquote:after,
194
- q:before, q:after {
195
- content: '';
196
- content: none;
197
- }
215
+ /*reset.css*/
216
+ /* v1.0 | 20080212 */
217
+ html, body, div, span, applet, object, iframe,
218
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
219
+ a, abbr, acronym, address, big, cite, code,
220
+ del, dfn, em, font, img, ins, kbd, q, s, samp,
221
+ small, strike, strong, sub, sup, tt, var,
222
+ b, u, i, center,
223
+ dl, dt, dd, ol, ul, li,
224
+ fieldset, form, label, legend,
225
+ table, caption, tbody, tfoot, thead, tr, th, td {
226
+ margin: 0;
227
+ padding: 0;
228
+ border: 0;
229
+ outline: 0;
230
+ font-size: 100%;
231
+ vertical-align: baseline;
232
+ background: transparent;
233
+ }
234
+ body {
235
+ line-height: 1;
236
+ }
237
+ ol, ul {
238
+ list-style: none;
239
+ }
240
+ blockquote, q {
241
+ quotes: none;
242
+ }
243
+ blockquote:before, blockquote:after,
244
+ q:before, q:after {
245
+ content: '';
246
+ content: none;
247
+ }
198
248
 
199
- /* remember to define focus styles! */
200
- :focus {
201
- outline: 0;
202
- }
249
+ /* remember to define focus styles! */
250
+ :focus {
251
+ outline: 0;
252
+ }
203
253
 
204
- /* remember to highlight inserts somehow! */
205
- ins {
206
- text-decoration: none;
207
- }
208
- del {
209
- text-decoration: line-through;
210
- }
254
+ /* remember to highlight inserts somehow! */
255
+ ins {
256
+ text-decoration: none;
257
+ }
258
+ del {
259
+ text-decoration: line-through;
260
+ }
211
261
 
212
- /* tables still need 'cellspacing="0"' in the markup */
213
- table {
214
- border-collapse: collapse;
215
- border-spacing: 0;
216
- }
217
- /*clear fix*/
218
- .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}
219
- .clearfix{display:inline-block;}
220
- html[xmlns] .clearfix {
221
- display: block;
222
- }
223
- * html .clearfix{height:1%;}
224
- /*start layout*/
225
- body{
226
- background:#fff;
227
- color:#333;
228
- font-size:75%;
229
- font-family:Arial;
230
- margin:2em auto;
231
- line-height:1.5em;
232
- }
233
- textarea,input,select{
234
- font-family:Arial;
235
- font-size:1em;
236
- }
237
- h1{
238
- color:#d46021;
239
- font-size:2em;
240
- margin-bottom:0.5em;
241
- }
242
- h2{
243
- text-align:left;
244
- color:#d46021;
245
- font-size:1.3em;
246
- padding-left:0;
247
- }
248
- a{
249
- color:#2158C7;
250
- }
251
- div#container{
252
- width:960px;
253
- margin:0 auto;
254
- font-size:1em;
255
- }
256
- /*paging*/
257
- div.paging{
258
- margin-bottom:1em;
259
- text-align:left;
260
- }
261
- div.paging div{
262
- border:solid 1px red;
263
- margin:1em 1em 0;
264
- padding:0.5em;
265
- border:solid 1px #d5d6d5;
266
- background:#f1f1f1;
267
- }
268
- ul.paging{
269
- display:inline-block;
270
- }
271
- ul.paging li{
272
- display:block;
273
- margin:0.2em 0;
274
- float:left;
275
- }
276
- ul.paging li.selected a{
277
- color:#fff;
278
- background:#2158C7;
279
- font-weight:bold;
280
- padding:0.5em 0.7em;
281
- }
282
- ul.paging li a{
283
- display:inline-block;
284
- line-height:1em;
285
- padding:0.5em 0.5em;
286
- }
287
- /*forms filter*/
288
- fieldset{
289
- padding:1em;
290
- margin:1em;
291
- border:solid 2px #d46021;
292
- }
293
- legend{
294
- font-size:1.2em;
295
- font-weight:bold;
296
- padding:0 1em;
297
- padding-bottom:0.5em;
298
- }
299
- label{
300
- font-weight:bold;
301
- }
302
- fieldset span{padding-right:0.5em;}
303
- div#show-sort label,
304
- div#languages label,
305
- div#filter-pattern label{
306
- display:inline-block;
307
- width:100px;
308
- line-height:2em;
309
- }
310
- div#show-sort select,
311
- div#languages select,
312
- div#filter-pattern select{
313
- width:120px;
314
- margin-right:0.5em;
315
- }
316
- div#show-sort input.text-default,
317
- div#languages input.text-default,
318
- div#filter-pattern input.text-default{
319
- width:200px;
320
- }
321
- p.hits{
322
- margin-top:1em;
323
- }
324
- /*translation edit*/
325
- div.translations{
326
- margin:1em;
327
- padding:1em;
328
- border:solid 2px #d46021;
329
- }
330
- div.translations h2{
331
- margin-bottom:1em;
332
- }
333
- p.translate{
334
- background:red;
335
- border:solid 1px #d5d6d5;
336
- background:#f1f1f1;
337
- margin:0.5em;
338
- padding:0.7em 0.5em 0.5em 1.5em;
339
- }
340
- div.translation{
341
- padding: 11px;
342
- border-bottom:solid 1px #d46021;
262
+ /* tables still need 'cellspacing="0"' in the markup */
263
+ table {
264
+ border-collapse: collapse;
265
+ border-spacing: 0;
266
+ }
267
+ /*clear fix*/
268
+ .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}
269
+ .clearfix{display:inline-block;}
270
+ html[xmlns] .clearfix {
271
+ display: block;
272
+ }
273
+ * html .clearfix{height:1%;}
274
+ /*start layout*/
275
+ body{
276
+ background:#fff;
277
+ color:#333;
278
+ font-size:75%;
279
+ font-family:Arial;
280
+ margin:2em auto;
281
+ line-height:1.5em;
282
+ }
283
+ textarea,input,select{
284
+ font-family:Arial;
285
+ font-size:1em;
286
+ }
287
+ h1{
288
+ color:#d46021;
289
+ font-size:2em;
290
+ margin-bottom:0.5em;
291
+ }
292
+ h2{
293
+ text-align:left;
294
+ color:#d46021;
295
+ font-size:1.3em;
296
+ padding-left:0;
297
+ }
298
+ a{
299
+ color:#2158C7;
300
+ }
301
+ div#container{
302
+ width:960px;
303
+ margin:0 auto;
304
+ font-size:1em;
305
+ }
306
+ /*paging*/
307
+ div.paging{
308
+ margin-bottom:1em;
309
+ text-align:left;
310
+ }
311
+ div.paging div{
312
+ border:solid 1px red;
313
+ margin:1em 1em 0;
314
+ padding:0.5em;
315
+ border:solid 1px #d5d6d5;
316
+ background:#f1f1f1;
317
+ }
318
+ ul.paging{
319
+ display:inline-block;
320
+ }
321
+ ul.paging li{
322
+ display:block;
323
+ margin:0.2em 0;
324
+ float:left;
325
+ }
326
+ ul.paging li.selected a{
327
+ color:#fff;
328
+ background:#2158C7;
329
+ font-weight:bold;
330
+ padding:0.5em 0.7em;
331
+ }
332
+ ul.paging li a{
333
+ display:inline-block;
334
+ line-height:1em;
335
+ padding:0.5em 0.5em;
336
+ }
337
+ /*forms filter*/
338
+ fieldset{
339
+ padding:1em;
340
+ margin:1em;
341
+ border:solid 2px #d46021;
342
+ }
343
+ legend{
344
+ font-size:1.2em;
345
+ font-weight:bold;
346
+ padding:0 1em;
347
+ padding-bottom:0.5em;
348
+ }
349
+ label{
350
+ font-weight:bold;
351
+ }
352
+ fieldset span{padding-right:0.5em;}
353
+ div#show-sort label,
354
+ div#languages label,
355
+ div#filter-pattern label{
356
+ display:inline-block;
357
+ width:100px;
358
+ line-height:2em;
359
+ }
360
+ div#show-sort select,
361
+ div#languages select,
362
+ div#filter-pattern select{
363
+ width:120px;
364
+ margin-right:0.5em;
365
+ }
366
+ div#show-sort input.text-default,
367
+ div#languages input.text-default,
368
+ div#filter-pattern input.text-default{
369
+ width:200px;
370
+ }
371
+ p.hits{
372
+ margin-top:1em;
373
+ }
374
+ /*translation edit*/
375
+ div.translations{
376
+ margin:1em;
377
+ padding:1em;
378
+ border:solid 2px #d46021;
379
+ }
380
+ div.translations h2{
381
+ margin-bottom:1em;
382
+ }
383
+ p.translate{
384
+ background:red;
385
+ border:solid 1px #d5d6d5;
386
+ background:#f1f1f1;
387
+ margin:0.5em;
388
+ padding:0.7em 0.5em 0.5em 1.5em;
389
+ }
390
+ div.translation{
391
+ padding: 11px;
392
+ border-bottom:solid 1px #d46021;
343
393
  border-left: solid 1px #D46021;
344
- margin:14px 12px 12px 19px;
345
- }
346
- div.translation input, div.translation textarea{
347
- width:98%;
348
- margin:1em 0;
349
- display:inline-block;
350
- padding:0.3em;
351
- }
352
- div.translation textarea{
353
- height:50px;
354
- }
355
- div.translation em strong{
356
- color:#333;
357
- padding-right:0.5em;
358
- }
359
- p.translation em{
360
- display:block;
361
- font-size:0.8333em;
362
- }
363
- div.translation a{
364
- padding:1em;
365
- }
366
- div.translation input.btnDefault{
367
- margin:0 0 1em;
368
- width:auto;
369
- }
370
- .focus-text{
371
- font-weight:bold;
372
- }
373
- div.selected{
374
- margin:12px 10px 12px 12px;
375
- border-left:solid 8px #d46021;
376
- border-right:solid 2px #d46021;
377
- border-top:solid 2px #d46021;
378
- background:#f1f1f1;
379
- }
380
- .display{display:block !important;}
381
- /*feedback*/
382
- div#notice, div#error {
383
- font-size:1em;
384
- margin:1em;
394
+ margin:14px 12px 12px 19px;
395
+ }
396
+ div.translation input, div.translation textarea{
397
+ width:98%;
398
+ margin:1em 0;
399
+ display:inline-block;
400
+ padding:0.3em;
401
+ }
402
+ div.translation textarea{
403
+ height:50px;
404
+ }
405
+ div.translation em strong{
406
+ color:#333;
407
+ padding-right:0.5em;
408
+ }
409
+ p.translation em{
410
+ display:block;
411
+ font-size:0.8333em;
412
+ }
413
+ div.translation a{
414
+ padding:1em;
415
+ }
416
+ div.translation input.btnDefault{
417
+ margin:0 0 1em;
418
+ width:auto;
419
+ }
420
+ .focus-text{
421
+ font-weight:bold;
422
+ }
423
+ div.selected{
424
+ margin:12px 10px 12px 12px;
425
+ border-left:solid 8px #d46021;
426
+ border-right:solid 2px #d46021;
427
+ border-top:solid 2px #d46021;
428
+ background:#f1f1f1;
429
+ }
430
+ .display{display:block !important;}
431
+ /*feedback*/
432
+ div#notice, div#error {
433
+ font-size:1em;
434
+ margin:1em;
385
435
  padding: 1em;
386
- border: 1px solid red;
436
+ border: 1px solid red;
437
+ }
438
+ div#notice span, div#error span{
439
+ font-size:1.5em;
387
440
  }
388
- div#notice span, div#error span{
389
- font-size:1.5em;
390
- }
391
441
 
392
442
  div#error {
393
443
  background-color: #F3C6CC;
@@ -400,11 +450,11 @@
400
450
  }
401
451
  .translation-error .edit-field
402
452
  {
403
- border: 1px solid red;
453
+ border: 1px solid red;
404
454
  }
405
455
  .error-text
406
456
  {
407
- color: red;
457
+ color: red;
408
458
  }
409
459
  .big-locale
410
460
  {
@@ -412,34 +462,34 @@
412
462
  color: red;
413
463
  }
414
464
  </style>
415
- <script type="text/javascript">
416
- onload = function (){
417
- $$("div.translation input, div.translation textarea").each(function (e){
418
- Event.observe(e,'focus', function (elm){
419
- this.up(".single-translation").down(".translation-text").addClassName("focus-text");
420
- this.up(".translation").addClassName("selected");
421
- });
422
- Event.observe(e,'blur', function (elm,e){
423
- this.up(".single-translation").down(".translation-text").removeClassName("focus-text");
424
- this.up(".translation").removeClassName("selected");
425
- });
426
- });
465
+ <script type="text/javascript">
466
+ onload = function (){
467
+ $$("div.translation input, div.translation textarea").each(function (e){
468
+ Event.observe(e,'focus', function (elm){
469
+ this.up(".single-translation").down(".translation-text").addClassName("focus-text");
470
+ this.up(".translation").addClassName("selected");
471
+ });
472
+ Event.observe(e,'blur', function (elm,e){
473
+ this.up(".single-translation").down(".translation-text").removeClassName("focus-text");
474
+ this.up(".translation").removeClassName("selected");
475
+ });
476
+ });
427
477
 
428
- checkErrors()
429
- }
430
- </script>
478
+ checkErrors()
479
+ }
480
+ </script>
431
481
  </head>
432
482
  <body>
433
- <div id="container">
434
- <% if @page_title -%><h1><%=h @page_title %></h1><% end -%>
435
- <% [:notice, :error].each do |message| %>
436
- <%if flash[message] %>
437
- <div id="<%= message %>">
438
- <span><%= h(flash[message]) if flash[message] %></span>
439
- </div>
440
- <% end %>
441
- <% end %>
442
- <%= yield %>
483
+ <div id="container">
484
+ <% if @page_title -%><h1><%=h @page_title %></h1><% end -%>
485
+ <% [:notice, :error].each do |message| %>
486
+ <%if flash[message] %>
487
+ <div id="<%= message %>">
488
+ <span><%= h(flash[message]) if flash[message] %></span>
489
+ </div>
490
+ <% end %>
491
+ <% end %>
492
+ <%= yield %>
443
493
  </div>
444
494
  </body>
445
495
  </html>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translate-rails3-plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,7 +16,7 @@ date: 2012-07-09 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: ya2yaml
19
- requirement: &24746952 !ruby/object:Gem::Requirement
19
+ requirement: &26156184 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ~>
@@ -24,7 +24,7 @@ dependencies:
24
24
  version: '0.30'
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *24746952
27
+ version_requirements: *26156184
28
28
  description: ! 'This plugin provides a web interface for translating Rails I18n texts
29
29
 
30
30
  (requires Rails 3.0 or higher) from one locale to another.
@@ -106,3 +106,4 @@ signing_key:
106
106
  specification_version: 3
107
107
  summary: Newsdesk translate plugin for Rails 3
108
108
  test_files: []
109
+ has_rdoc: