translate-rails3-plus 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,6 +53,45 @@
53
53
  document.getElementsByTagName("head")[0].appendChild(s);
54
54
  }
55
55
 
56
+ function checkErrors()
57
+ {
58
+ var errors = []
59
+ $$('.translation-error').each(function(item) {
60
+ item.removeClassName("translation-error")
61
+ item.select('.error-text')[0].innerHTML = ""
62
+ });
63
+
64
+ $$('.single-translation').each(function(item) {
65
+ var val = item.select('.edit-field')[0].value
66
+ if( !val.blank() )
67
+ {
68
+ var patt1=/\{[^\{\}]*\}/g;
69
+ var val_subs = val.match(patt1)
70
+ var key = item.select('.translation-text')[0].innerHTML
71
+ 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
+ {
76
+ item.addClassName("translation-error");
77
+ errors.push( item )
78
+ item.select('.error-text')[0].innerHTML = "Mismatched {} substitution strings."
79
+ }
80
+ }
81
+ });
82
+ return errors
83
+ }
84
+
85
+ function testAndSave()
86
+ {
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
+ }
93
+ }
94
+
56
95
  /*
57
96
  prototypeUtils.js from http://jehiah.com/
58
97
  Licensed under Creative Commons.
@@ -299,10 +338,10 @@
299
338
  padding:0.7em 0.5em 0.5em 1.5em;
300
339
  }
301
340
  div.translation{
302
- padding:1em;
303
- border-bottom:solid 0.2em #d46021;
304
- border-left: solid 0.1em #D46021;
305
- margin:0 1em 1em 1.6em;
341
+ padding: 11px;
342
+ border-bottom:solid 1px #d46021;
343
+ border-left: solid 1px #D46021;
344
+ margin:14px 12px 12px 19px;
306
345
  }
307
346
  div.translation input, div.translation textarea{
308
347
  width:98%;
@@ -332,10 +371,10 @@
332
371
  font-weight:bold;
333
372
  }
334
373
  div.selected{
335
- margin:0 1em 1em 1em;
336
- border-left:solid 0.6em #d46021;
337
- border-right:solid 0.2em #d46021;
338
- border-top:solid 0.2em #d46021;
374
+ margin:12px 10px 12px 12px;
375
+ border-left:solid 8px #d46021;
376
+ border-right:solid 2px #d46021;
377
+ border-top:solid 2px #d46021;
339
378
  background:#f1f1f1;
340
379
  }
341
380
  .display{display:block !important;}
@@ -359,24 +398,33 @@
359
398
  color: #597B5C;
360
399
  background-color: #BCFFBD;
361
400
  }
401
+ .translation-error .edit-field
402
+ {
403
+ border: 1px solid red;
404
+ }
405
+ .error-text
406
+ {
407
+ color: red;
408
+ }
362
409
  .big-locale
363
410
  {
364
411
  font-size: 32px;
365
- color: red;
366
412
  }
367
413
  </style>
368
414
  <script type="text/javascript">
369
415
  onload = function (){
370
416
  $$("div.translation input, div.translation textarea").each(function (e){
371
417
  Event.observe(e,'focus', function (elm){
372
- this.up(1).down(".translation-text").addClassName("focus-text");
373
- this.up(1).addClassName("selected");
418
+ this.up(".single-translation").down(".translation-text").addClassName("focus-text");
419
+ this.up(".translation").addClassName("selected");
374
420
  });
375
421
  Event.observe(e,'blur', function (elm,e){
376
- this.up(1).down(".translation-text").removeClassName("focus-text");
377
- this.up(1).removeClassName("selected");
422
+ this.up(".single-translation").down(".translation-text").removeClassName("focus-text");
423
+ this.up(".translation").removeClassName("selected");
378
424
  });
379
425
  });
426
+
427
+ checkErrors()
380
428
  }
381
429
  </script>
382
430
  </head>
@@ -6,7 +6,7 @@
6
6
 
7
7
  <div class="translation">
8
8
  <% if from_text.present? %>
9
- <p class="translation-text">
9
+
10
10
  <ol>
11
11
  <% from_text.each_with_index do |from_text_section, index| %>
12
12
  <%
@@ -17,18 +17,21 @@
17
17
  # for this element yet...
18
18
  to_text = Array.new if to_text.blank?
19
19
  %>
20
- <li><%= from_text_section %></li>
21
- <p class="edit-form">
22
- <% if n_lines > 1 %>
23
- <%= text_area_tag("#{field_name}[#{index}]", to_text[index], :size => "#{line_size}x#{n_lines}", :id => "#{key}[#{index}]") %>
24
- <% else %>
25
- <%= text_field_tag("#{field_name}[#{index}]", to_text[index], :size => line_size, :id => "#{key}[#{index}]") %>
26
- <% end %>
27
- <%= translate_link("#{key}[#{index}]", from_text_section, @from_locale, @to_locale) %>
20
+ <li class="single-translation">
21
+ <p class="translation-text"><%= from_text_section %></p>
22
+ <p class="edit-form" >
23
+ <% if n_lines > 1 %>
24
+ <%= text_area_tag("#{field_name}[#{index}]", to_text[index], :size => "#{line_size}x#{n_lines}", :id => "#{key}[#{index}]", :class=>'edit-field') %>
25
+ <% else %>
26
+ <%= text_field_tag("#{field_name}[#{index}]", to_text[index], :size => line_size, :id => "#{key}[#{index}]", :class=>'edit-field') %>
27
+ <% end %>
28
+ <%= translate_link("#{key}[#{index}]", from_text_section, @from_locale, @to_locale) %>
28
29
  </p>
30
+ <div class="error-text"></div>
31
+ </li>
29
32
  <% end %>
30
33
  </ol>
31
- </p>
34
+
32
35
  <% end %>
33
36
  <p>
34
37
  <em>
@@ -6,23 +6,22 @@
6
6
  field_name = "key[#{key}]"
7
7
  %>
8
8
 
9
- <div class="translation">
9
+ <div class="translation single-translation" >
10
10
  <% if from_text.present? %>
11
- <p class="translation-text">
12
- <% if from_text.starts_with?(" ") || from_text.ends_with?(" ")%>
13
- <%= simple_format("&rarr;" + h(from_text) + "&larr;") %>
14
- <% else %>
15
- <%= simple_format(h(from_text)) %>
16
- <% end %>
17
- </p>
11
+ <% if from_text.starts_with?(" ") || from_text.ends_with?(" ")%>
12
+ <%= simple_format("&rarr;" + h(from_text) + "&larr;", :class => "translation-text" ) %>
13
+ <% else %>
14
+ <%= simple_format(h(from_text), :class => "translation-text") %>
15
+ <% end %>
18
16
  <% end %>
19
17
  <p class="edit-form">
20
18
  <% if n_lines > 1 %>
21
- <%= text_area_tag(field_name, to_text, :size => "#{line_size}x#{n_lines}", :id => key) %>
19
+ <%= text_area_tag(field_name, to_text, :size => "#{line_size}x#{n_lines}", :id => key, :class=>'edit-field') %>
22
20
  <% else %>
23
- <%= text_field_tag(field_name, to_text, :size => line_size, :id => key) %>
21
+ <%= text_field_tag(field_name, to_text, :size => line_size, :id => key, :class=>'edit-field') %>
24
22
  <% end %>
25
23
  </p>
24
+ <div class="error-text"></div>
26
25
  <p>
27
26
  <em>
28
27
  <%= translate_link(key, from_text, @from_locale, @to_locale) %>
@@ -60,7 +60,7 @@ show_filters << "changed" if @from_locale != @to_locale
60
60
  </div>
61
61
 
62
62
  <% if @total_entries > 0 %>
63
- <%= form_tag(translate_path) do %>
63
+ <%= form_tag(translate_path, :name => 'translate_form') do %>
64
64
  <div>
65
65
  <%= hidden_field_tag(:filter, params[:filter], :id => "hid_filter") %>
66
66
  <%= hidden_field_tag(:sort_by, params[:sort_by], :id => "hid_sort_by") %>
@@ -72,7 +72,7 @@ show_filters << "changed" if @from_locale != @to_locale
72
72
  <div class="translations">
73
73
  <h2>Translations from <span class='big-locale'><%= @from_locale %></span> to <span class='big-locale'><%= @to_locale %></span></h2>
74
74
  <p class="translate">
75
- <%= submit_tag "Save Translations" %>
75
+ <%= button_to_function 'Save Translations', 'testAndSave()' %>
76
76
  </p>
77
77
  <% @paginated_keys.each do |key| %>
78
78
  <%=
@@ -85,7 +85,7 @@ show_filters << "changed" if @from_locale != @to_locale
85
85
  %>
86
86
  <% end %>
87
87
  <p class="translate">
88
- <%= submit_tag "Save Translations" %>
88
+ <%= button_to_function 'Save Translations', 'testAndSave()' %>
89
89
  </p>
90
90
  </div>
91
91
  <% end %>
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.1
4
+ version: 0.0.3
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: &23168796 !ruby/object:Gem::Requirement
19
+ requirement: &22370988 !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: *23168796
27
+ version_requirements: *22370988
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.
@@ -81,7 +81,6 @@ files:
81
81
  - spec/log_spec.rb
82
82
  - spec/spec_helper.rb
83
83
  - spec/storage_spec.rb
84
- - translate-rails3-plus.gemspec
85
84
  homepage: https://github.com/gsmedley/translate
86
85
  licenses: []
87
86
  post_install_message:
@@ -1,70 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "translate-rails3-plus"
8
- s.version = "0.0.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Peter Marklund", "Milan Novota", "Roman Shterenzon", "Garth Smedley"]
12
- s.date = "2012-07-09"
13
- s.description = "This plugin provides a web interface for translating Rails I18n texts\n(requires Rails 3.0 or higher) from one locale to another.\nThe plugin has been tested only with the simple I18n backend that ships\nwith Rails.\nI18n texts are read from and written to YAML files under config/locales.\n\nThis gem is a fork of https://github.com/romanbsd/translate.\nFrom the original https://github.com/mynewsdesk/translate\nwhich also includes work from this fork: https://github.com/milann/translate\n"
14
- s.email = "gsmedley@kanayo.com"
15
- s.extra_rdoc_files = [
16
- "README.md"
17
- ]
18
- s.files = [
19
- "MIT-LICENSE",
20
- "README.md",
21
- "Rakefile",
22
- "VERSION",
23
- "app/controllers/translate_controller.rb",
24
- "app/helpers/translate_helper.rb",
25
- "app/views/layouts/translate.html.erb",
26
- "app/views/translate/_array_form.html.erb",
27
- "app/views/translate/_pagination.html.erb",
28
- "app/views/translate/_string_form.html.erb",
29
- "app/views/translate/index.html.erb",
30
- "config/routes.rb",
31
- "init.rb",
32
- "lib/tasks/translate.rake",
33
- "lib/translate.rb",
34
- "lib/translate/file.rb",
35
- "lib/translate/keys.rb",
36
- "lib/translate/log.rb",
37
- "lib/translate/routes.rb",
38
- "lib/translate/storage.rb",
39
- "spec/controllers/translate_controller_spec.rb",
40
- "spec/file_spec.rb",
41
- "spec/files/translate/app/models/article.rb",
42
- "spec/files/translate/app/views/category.erb",
43
- "spec/files/translate/app/views/category.html",
44
- "spec/files/translate/app/views/category.html.erb",
45
- "spec/files/translate/app/views/category.rhtml",
46
- "spec/files/translate/public/javascripts/application.js",
47
- "spec/keys_spec.rb",
48
- "spec/log_spec.rb",
49
- "spec/spec_helper.rb",
50
- "spec/storage_spec.rb",
51
- "translate-rails3-plus.gemspec"
52
- ]
53
- s.homepage = "https://github.com/gsmedley/translate"
54
- s.require_paths = ["lib"]
55
- s.rubygems_version = "1.8.16"
56
- s.summary = "Newsdesk translate plugin for Rails 3"
57
-
58
- if s.respond_to? :specification_version then
59
- s.specification_version = 3
60
-
61
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
62
- s.add_runtime_dependency(%q<ya2yaml>, ["~> 0.30"])
63
- else
64
- s.add_dependency(%q<ya2yaml>, ["~> 0.30"])
65
- end
66
- else
67
- s.add_dependency(%q<ya2yaml>, ["~> 0.30"])
68
- end
69
- end
70
-