tolk 1.3.9 → 1.3.10
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/app/assets/javascripts/tolk/actions.js +6 -11
- data/app/assets/javascripts/tolk/interpolations.js +14 -30
- data/app/assets/javascripts/tolk/layout.js +10 -2
- data/app/assets/stylesheets/tolk/screen.css +11 -10
- data/app/helpers/tolk/application_helper.rb +11 -1
- data/app/models/tolk/locale.rb +2 -5
- data/app/models/tolk/translation.rb +1 -0
- data/app/views/tolk/locales/all.html.erb +6 -10
- data/app/views/tolk/locales/show.html.erb +9 -11
- data/app/views/tolk/searches/show.html.erb +11 -13
- data/lib/tolk.rb +1 -0
- data/lib/tolk/export.rb +28 -0
- data/lib/tolk/version.rb +1 -1
- metadata +3 -2
@@ -5,23 +5,18 @@ $(function () {
|
|
5
5
|
e.preventDefault();
|
6
6
|
|
7
7
|
var row = $(this).parents("tr")
|
8
|
-
,
|
8
|
+
, original_text = row.find(".original textarea").val();
|
9
9
|
|
10
|
-
row.find(".translation textarea").
|
11
|
-
|
12
|
-
// Bind the dirty callback after copy
|
13
|
-
window.onbeforeunload = confirm;
|
10
|
+
row.find(".translation textarea").val(original_text.trim()).trigger("change");
|
14
11
|
});
|
15
12
|
|
16
13
|
// avoid lose data
|
17
|
-
$(".translations textarea").bind("
|
18
|
-
|
19
|
-
window.onbeforeunload = confirm;
|
20
|
-
}
|
14
|
+
$(".translations textarea").bind("keydown", function () {
|
15
|
+
window.onbeforeunload = confirm;
|
21
16
|
});
|
22
17
|
|
23
|
-
$(".translations textarea").bind("
|
24
|
-
|
18
|
+
$(".translations textarea").bind("change", function () {
|
19
|
+
window.onbeforeunload = confirm;
|
25
20
|
});
|
26
21
|
|
27
22
|
$("input.save, input.apply").click(function () {
|
@@ -1,37 +1,21 @@
|
|
1
1
|
$(function () {
|
2
|
-
var interpolation = new RegExp("%{\\w+}", "g");
|
3
|
-
|
4
|
-
$(".phrase .value").each(function () {
|
5
|
-
var text = $('<div/>').text($(this).text()).html()
|
6
|
-
, token_text;
|
7
|
-
|
8
|
-
token_text = text.replace(interpolation, function (match) {
|
9
|
-
return '<span class="interpolation" title="Don\'t translate this word">' + match + '</span>';
|
10
|
-
});
|
11
|
-
|
12
|
-
$(this).html(token_text);
|
13
|
-
});
|
14
2
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
, translated_text = $(this).val()
|
25
|
-
, original_interpolations = original_text.match(interpolation) || []
|
26
|
-
, translated_interpolations = translated_text.match(interpolation) || []
|
27
|
-
, not_match;
|
3
|
+
var interpolation = new RegExp("%{\\w+}", "g");
|
4
|
+
|
5
|
+
$(".translations textarea").bind("change", function () {
|
6
|
+
var row = $(this).parents("tr")
|
7
|
+
, original_text = row.find(".original textarea").val()
|
8
|
+
, translated_text = $(this).val()
|
9
|
+
, original_interpolations = original_text.match(interpolation) || []
|
10
|
+
, translated_interpolations = translated_text.match(interpolation) || []
|
11
|
+
, not_match;
|
28
12
|
|
29
|
-
|
30
|
-
|
31
|
-
|
13
|
+
not_match = translated_text.length > 0 &&
|
14
|
+
($(original_interpolations).not(translated_interpolations).length !== 0 ||
|
15
|
+
$(translated_interpolations).not(original_interpolations).length !== 0);
|
32
16
|
|
33
|
-
|
17
|
+
row.find(".actions .warning").toggle(not_match);
|
34
18
|
|
35
|
-
|
19
|
+
});
|
36
20
|
|
37
21
|
});
|
@@ -1,9 +1,17 @@
|
|
1
|
-
|
2
1
|
$(function () {
|
3
2
|
|
4
3
|
// Fit text area height
|
5
|
-
$('
|
4
|
+
$('.translations textarea').each(function () {
|
6
5
|
$(this).css({ height: $(this).parent('td').css('height')});
|
7
6
|
});
|
8
7
|
|
8
|
+
// Mark active textarea
|
9
|
+
$(".translations textarea").bind("focus", function () {
|
10
|
+
$(this).parents("tr").toggleClass('active');
|
11
|
+
});
|
12
|
+
|
13
|
+
$(".translations textarea").bind("blur", function () {
|
14
|
+
$(this).parents("tr").toggleClass('active');
|
15
|
+
});
|
16
|
+
|
9
17
|
});
|
@@ -241,7 +241,7 @@ span.notice {
|
|
241
241
|
display: inline-block;
|
242
242
|
}
|
243
243
|
|
244
|
-
div.
|
244
|
+
div.previous {
|
245
245
|
color: #999;
|
246
246
|
margin: 5px 0;
|
247
247
|
padding: 1px 8px 4px;
|
@@ -252,7 +252,7 @@ div.updated {
|
|
252
252
|
padding: 1px 8px 4px;
|
253
253
|
}
|
254
254
|
|
255
|
-
table.translations div.
|
255
|
+
table.translations div.previous span.key {
|
256
256
|
margin: 0 0 -2px;
|
257
257
|
padding: 0;
|
258
258
|
}
|
@@ -332,7 +332,7 @@ table.translations td.actions .warning {
|
|
332
332
|
color: orange;
|
333
333
|
padding: 2px 4px;
|
334
334
|
display: none;
|
335
|
-
cursor:
|
335
|
+
cursor: help;
|
336
336
|
}
|
337
337
|
|
338
338
|
table.translations tr.active td {
|
@@ -343,20 +343,21 @@ table.translations .highlight {
|
|
343
343
|
background-color: yellow;
|
344
344
|
}
|
345
345
|
|
346
|
-
table.translations .original {
|
346
|
+
table.translations .original textarea {
|
347
347
|
display: none;
|
348
348
|
}
|
349
349
|
|
350
|
-
table.translations .interpolation
|
350
|
+
table.translations .original .interpolation,
|
351
|
+
table.translations .original .carriage_return,
|
352
|
+
table.translations .original .boolean {
|
351
353
|
color: #2fadcf;
|
352
|
-
font-family: Courier;
|
354
|
+
font-family: Courier, monospace;
|
353
355
|
font-weight: bold;
|
354
|
-
cursor:
|
356
|
+
cursor: help;
|
355
357
|
}
|
356
358
|
|
357
|
-
table.translations .
|
358
|
-
|
359
|
-
font-weight: bold;
|
359
|
+
table.translations .original .carriage_return:before {
|
360
|
+
content: "¶";
|
360
361
|
}
|
361
362
|
|
362
363
|
/*-------------------------------------------------
|
@@ -1,7 +1,17 @@
|
|
1
1
|
module Tolk
|
2
2
|
module ApplicationHelper
|
3
3
|
def format_i18n_value(value)
|
4
|
-
h(yaml_value(value))
|
4
|
+
value = h(yaml_value(value))
|
5
|
+
value = highlight_linebreaks(value)
|
6
|
+
value = highligh_interpolations(value)
|
7
|
+
end
|
8
|
+
|
9
|
+
def highlight_linebreaks(value)
|
10
|
+
value.gsub(/\n/, '<span class="carriage_return" title="Line break"><br /></span>').html_safe
|
11
|
+
end
|
12
|
+
|
13
|
+
def highligh_interpolations(value)
|
14
|
+
value.gsub(/%{\w+}/, '<span class="interpolation" title="Leave this word untranslated">\0</span>').html_safe
|
5
15
|
end
|
6
16
|
|
7
17
|
def format_i18n_text_area_value(value)
|
data/app/models/tolk/locale.rb
CHANGED
@@ -51,12 +51,9 @@ module Tolk
|
|
51
51
|
all - [primary_locale]
|
52
52
|
end
|
53
53
|
|
54
|
-
def dump_all(to =
|
54
|
+
def dump_all(to = nil, exporter = Tolk::Export)
|
55
55
|
secondary_locales.each do |locale|
|
56
|
-
|
57
|
-
data = locale.to_hash
|
58
|
-
data.respond_to?(:ya2yaml) ? file.write(data.ya2yaml(:syck_compatible => true)) : file.write(YAML.dump(data).force_encoding file.external_encoding.name)
|
59
|
-
end
|
56
|
+
exporter.dump(name: locale.name, data: locale.to_hash, destination: to)
|
60
57
|
end
|
61
58
|
end
|
62
59
|
|
@@ -30,25 +30,21 @@
|
|
30
30
|
<a class="copy" href="#" tabindex="-1" title="Copy original translation">←</a><br>
|
31
31
|
<span class="warning" title="Interpolation keys don't match">⚠</span>
|
32
32
|
</td>
|
33
|
-
<td class="
|
34
|
-
|
33
|
+
<td class="original">
|
34
|
+
<%= text_area_tag :"translations[][original_text]", format_i18n_text_area_value(phrase.translations.primary.text), :disabled => true %>
|
35
|
+
|
35
36
|
<% if action_name == 'updated' %>
|
36
37
|
<div class="updated">
|
37
38
|
<span class="key">Updated</span>
|
38
39
|
<%= format_i18n_value(phrase.translations.primary.text) -%>
|
39
40
|
<%= boolean_warning if phrase.translations.primary.boolean? -%>
|
40
41
|
</div>
|
41
|
-
<div class="
|
42
|
-
<span class="key">
|
42
|
+
<div class="previous">
|
43
|
+
<span class="key">Previous</span>
|
43
44
|
<%= format_i18n_value(phrase.translations.primary.previous_text) -%>
|
44
45
|
</div>
|
45
46
|
<% else %>
|
46
|
-
|
47
|
-
<%= format_i18n_value(phrase.translations.primary.text) -%>
|
48
|
-
</div>
|
49
|
-
<div class="value">
|
50
|
-
<%= format_i18n_value(phrase.translations.primary.text) -%>
|
51
|
-
</div>
|
47
|
+
<%= format_i18n_value(phrase.translations.primary.text) -%>
|
52
48
|
<%= boolean_warning if phrase.translations.primary.boolean? -%>
|
53
49
|
<% end %>
|
54
50
|
|
@@ -34,18 +34,16 @@
|
|
34
34
|
<a class="copy" href="#" tabindex="-1" title="Copy original translation">←</a><br>
|
35
35
|
<span class="warning" title="Interpolation keys don't match">⚠</span>
|
36
36
|
</td>
|
37
|
-
<td class="
|
38
|
-
|
37
|
+
<td class="original">
|
38
|
+
<%= text_area_tag :"translations[][original_text]", format_i18n_text_area_value(phrase.translations.primary.text), :disabled => true %>
|
39
|
+
|
40
|
+
<% if params[:q].present? -%>
|
41
|
+
<%= highlight(format_i18n_value(phrase.translations.primary.text), params[:q]) -%>
|
42
|
+
<% else -%>
|
39
43
|
<%= format_i18n_value(phrase.translations.primary.text) -%>
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
<%= highlight(format_i18n_value(phrase.translations.primary.text), params[:q]) -%>
|
44
|
-
<% else -%>
|
45
|
-
<%= format_i18n_value(phrase.translations.primary.text) -%>
|
46
|
-
<% end -%>
|
47
|
-
<%= boolean_warning if phrase.translations.primary.boolean? -%>
|
48
|
-
</div>
|
44
|
+
<% end -%>
|
45
|
+
<%= boolean_warning if phrase.translations.primary.boolean? -%>
|
46
|
+
|
49
47
|
<span class="key" title="<%= phrase.key %>"><%= truncate(phrase.key, :length => 100) %></span>
|
50
48
|
</td>
|
51
49
|
</tr>
|
@@ -31,21 +31,19 @@
|
|
31
31
|
<a class="copy" href="#" tabindex="-1" title="Copy original translation">←</a><br>
|
32
32
|
<span class="warning" title="Interpolation keys don't match">⚠</span>
|
33
33
|
</td>
|
34
|
-
<td class="
|
35
|
-
|
34
|
+
<td class="original">
|
35
|
+
<%= text_area_tag :"translations[][original_text]", format_i18n_text_area_value(phrase.translations.primary.text), :disabled => true %>
|
36
|
+
|
37
|
+
<% if params[:q].present? -%>
|
38
|
+
<%= highlight(format_i18n_value(phrase.translations.primary.text), params[:q]) -%>
|
39
|
+
<% else -%>
|
36
40
|
<%= format_i18n_value(phrase.translations.primary.text) -%>
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
<%= highlight(format_i18n_value(phrase.translations.primary.text), params[:q]) -%>
|
41
|
-
<% else -%>
|
42
|
-
<%= format_i18n_value(phrase.translations.primary.text) -%>
|
43
|
-
<% end -%>
|
44
|
-
<%= boolean_warning if phrase.translations.primary.boolean? -%>
|
45
|
-
</div>
|
41
|
+
<% end -%>
|
42
|
+
<%= boolean_warning if phrase.translations.primary.boolean? -%>
|
43
|
+
|
46
44
|
<span class="key" title="<%= phrase.key %>"><%= params[:k].present? ?
|
47
|
-
|
48
|
-
|
45
|
+
highlight(h(truncate(phrase.key, :length => 100)), params[:k]) :
|
46
|
+
h(truncate(phrase.key, :length => 100)) %></span>
|
49
47
|
</td>
|
50
48
|
</tr>
|
51
49
|
<% end %>
|
data/lib/tolk.rb
CHANGED
data/lib/tolk/export.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Tolk
|
2
|
+
class Export
|
3
|
+
attr_reader :name, :data, :destination
|
4
|
+
|
5
|
+
def initialize(args)
|
6
|
+
@name = args.fetch(:name, '')
|
7
|
+
@data = args.fetch(:data, {})
|
8
|
+
@destination = args.fetch(:destination, self.class.dump_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def dump
|
12
|
+
File.open("#{destination}/#{name}.yml", "w+") do |file|
|
13
|
+
data.respond_to?(:ya2yaml) ? file.write(data.ya2yaml(:syck_compatible => true)) : file.write(YAML.dump(data).force_encoding file.external_encoding.name)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def dump(args)
|
19
|
+
new(args).dump
|
20
|
+
end
|
21
|
+
|
22
|
+
def dump_path
|
23
|
+
Tolk::Locale._dump_path
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/lib/tolk/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tolk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2013-
|
16
|
+
date: 2013-07-04 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: will_paginate
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/tasks/tolk_tasks.rake
|
65
65
|
- lib/tolk/config.rb
|
66
66
|
- lib/tolk/engine.rb
|
67
|
+
- lib/tolk/export.rb
|
67
68
|
- lib/tolk/import.rb
|
68
69
|
- lib/tolk/sync.rb
|
69
70
|
- lib/tolk/version.rb
|