i18nline 0.0.8.alpha → 0.0.10.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/i18nline/_base.css +4 -0
- data/app/controllers/i18nline/translations_controller.rb +28 -14
- data/app/views/i18nline/translations/edit_key.html.erb +12 -2
- data/lib/generators/i18nline/templates/config/initializers/i18nline.rb +6 -0
- data/lib/i18nline/version.rb +1 -1
- data/lib/i18nline.rb +3 -0
- data/test/dummy/config/initializers/i18nline.rb +6 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +7184 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1fed974ece9b46e9543a13bd2cfd39c6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/68dc686a51587b32dfe7df0ed46af6e5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/68ec19b2e986f843a7153c1c4e947469 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9bdaf3e65b045b8b71837f5662d72c5a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b009f80f9687a780c4fab949cb1bcc60 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c50a18c681d1e0b8bdc1d2f4569776ca +0 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84be485a4a066f3df39cb5e042119dd5fc148fd8
|
4
|
+
data.tar.gz: 3795a0deaff69a57779f1eb6d4456ec9d629fd23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2e0c707fe888eed80b4b9d181ea0029bd296748589f05a151f0af94fd8dd67e5a7b3e05e5f0f7358c90c72a8a2bccfc8610d2614a5109b954f484e6705ae1f9
|
7
|
+
data.tar.gz: ba3161979348cbf5708444b5bd7b27593d61d95326be4a0df7d09db84cb2d4d7466cb23e0240184bc5dea2e845b6e57a983a8d5a39b01cdaf5807fcc9b9694a7
|
@@ -31,6 +31,8 @@ module I18nline
|
|
31
31
|
is_proc: translations.first.is_proc
|
32
32
|
)
|
33
33
|
|
34
|
+
@should_show_yaml_warning = check_yaml_warning(translations)
|
35
|
+
|
34
36
|
render "edit_key" and return
|
35
37
|
end
|
36
38
|
|
@@ -52,12 +54,12 @@ module I18nline
|
|
52
54
|
params[:tr_set][:translation].each do |translation|
|
53
55
|
db_translation = Translation.find(translation.first)
|
54
56
|
if db_translation
|
55
|
-
db_translation.value = translation.last[:value]
|
57
|
+
db_translation.value = convert_to_object(translation.last[:value])
|
56
58
|
db_translation.is_proc = is_proc
|
57
59
|
if translation.last[:make_nil].presence == "1"
|
58
60
|
# it is likely that if value was nil and now is not, 'make_nil' has been left marked
|
59
61
|
# as a mistake, so in that case we ignore it and apply the new value:
|
60
|
-
unless db_translation.value_changed?
|
62
|
+
unless db_translation.value_changed? && db_translation.value_was.nil? && db_translation.value.present?
|
61
63
|
db_translation.value = nil
|
62
64
|
end
|
63
65
|
end
|
@@ -69,18 +71,6 @@ module I18nline
|
|
69
71
|
redirect_to :translations, notice: "Update successful."
|
70
72
|
end
|
71
73
|
|
72
|
-
# PATCH/PUT /translations/1
|
73
|
-
def update
|
74
|
-
if translation_params[:make_nil].presence == "1"
|
75
|
-
params[:translation][:value] = nil
|
76
|
-
end
|
77
|
-
if @translation.update(translation_params)
|
78
|
-
redirect_to @translation, notice: 'Translation was successfully updated.'
|
79
|
-
else
|
80
|
-
render action: 'edit'
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
74
|
private
|
85
75
|
# Use callbacks to share common setup or constraints between actions.
|
86
76
|
def set_translation
|
@@ -91,5 +81,29 @@ module I18nline
|
|
91
81
|
def translation_params
|
92
82
|
params.require(:translation).permit(:value, :is_proc, :make_nil)
|
93
83
|
end
|
84
|
+
|
85
|
+
def convert_to_object(value)
|
86
|
+
# gsub part is keeping integrity of serialized objects, such as arrays:
|
87
|
+
result = value.gsub("\r\n", "\n")
|
88
|
+
if value.start_with?("---")
|
89
|
+
begin
|
90
|
+
result = YAML::load(value)
|
91
|
+
rescue Exception => exception
|
92
|
+
logger.debug "I18nline: Exception found trying to parse yaml to convert translation value to object:"
|
93
|
+
logger.debug exception
|
94
|
+
end
|
95
|
+
end
|
96
|
+
result
|
97
|
+
end
|
98
|
+
|
99
|
+
def check_yaml_warning(translations)
|
100
|
+
should_show = false
|
101
|
+
if I18nline.show_yaml_warning
|
102
|
+
if translations.select{|tt| tt.value and tt.value.class != String}.any?
|
103
|
+
should_show = true
|
104
|
+
end
|
105
|
+
end
|
106
|
+
should_show
|
107
|
+
end
|
94
108
|
end
|
95
109
|
end
|
@@ -22,6 +22,14 @@
|
|
22
22
|
</div>
|
23
23
|
</div>
|
24
24
|
</div>
|
25
|
+
<% if @should_show_yaml_warning %>
|
26
|
+
<div class="panel panel-default panel-warning">
|
27
|
+
<div class="panel-body">
|
28
|
+
Please, <b>note:</b> <br>
|
29
|
+
At least one translation below is using <a href="http://en.wikipedia.org/wiki/Yaml">Yaml</a>. If you are not familiar with Yaml and serialization, please don't touch the dashes at the beginning of some lines.
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
<% end %>
|
25
33
|
<% @tr_set.translations.each do |translation| %>
|
26
34
|
<% panel_color = translation.value.nil? ? "panel-danger" : "panel-info" %>
|
27
35
|
<div class="panel panel-default <%= panel_color %>">
|
@@ -29,8 +37,10 @@
|
|
29
37
|
<%= f.fields_for "translation[]", translation do |tl_form| %>
|
30
38
|
<div class="input-group col-sm-offset-2">
|
31
39
|
<span class="input-group-addon"><%= translation.locale %></span>
|
32
|
-
<%
|
33
|
-
|
40
|
+
<% translation.value = translation.value.to_yaml if translation.value && translation.value.class != String %>
|
41
|
+
<% rows = (translation.value.to_s.length / 120) + 1 %>
|
42
|
+
<% height = rows * 36 %>
|
43
|
+
<%= tl_form.text_area :value, class: "form-control", style: "height:#{height}px !important;" %>
|
34
44
|
</div>
|
35
45
|
<div class="form-group">
|
36
46
|
<div class="col-sm-offset-2 col-sm-10">
|
@@ -18,4 +18,10 @@ I18nline.setup do |config|
|
|
18
18
|
|
19
19
|
# Missing translations will be generated for this locales.
|
20
20
|
#config.enabled_locales = %w(en es it)
|
21
|
+
|
22
|
+
# Complex translations use serialized yaml objects. If the translator changes
|
23
|
+
# the serialization markers, the translation can be made unusable.
|
24
|
+
# If 'show_yaml_warning' is set to true, a warning message will appear
|
25
|
+
# when accessing a translation set presenting serialized data.
|
26
|
+
#config.show_yaml_warning = true
|
21
27
|
end
|
data/lib/i18nline/version.rb
CHANGED
data/lib/i18nline.rb
CHANGED
@@ -18,4 +18,10 @@ I18nline.setup do |config|
|
|
18
18
|
|
19
19
|
# Missing translations will be generated for this locales.
|
20
20
|
config.enabled_locales = %w(en es it pt)
|
21
|
+
|
22
|
+
# Complex translations use serialized yaml objects. If the translator changes
|
23
|
+
# the serialization markers, the translation can be made unusable.
|
24
|
+
# If 'show_yaml_warning' is set to true, a warning message will appear
|
25
|
+
# when accessing a translation set presenting serialized data.
|
26
|
+
config.show_yaml_warning = true
|
21
27
|
end
|
Binary file
|