expat 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/expat/application.css +5 -0
- data/app/controllers/expat/application_controller.rb +14 -0
- data/app/controllers/expat/locales_controller.rb +1 -7
- data/app/controllers/expat/translations_controller.rb +22 -2
- data/app/views/expat/translations/_form.html.erb +2 -2
- data/app/views/expat/translations/index.html.erb +7 -2
- 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: c9205ebd1f04d3cc1ea7d0635dc4a00e8d3e6b31
|
4
|
+
data.tar.gz: ada39731405acbc07114da232971fc4ffec36e2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4d9138016aa8389c8854e0e5b71ba75570915df550ee4c296f84389021f774f4e6c98de5a272884c8a73bab9c85ae3a7fe348c422700b9f8d1097e48f00854c
|
7
|
+
data.tar.gz: a23282e10acb1ddabf580920bf4afda8940acc84d52d3bc3a284de5b217baa7b4b78e48c7e26bb32579958b69f70f15cd62da09fe623c680f8038e390f48d454
|
@@ -1,5 +1,19 @@
|
|
1
1
|
module Expat
|
2
2
|
class ApplicationController < ActionController::Base
|
3
3
|
protect_from_forgery with: :exception
|
4
|
+
|
5
|
+
protected
|
6
|
+
|
7
|
+
def list_locales
|
8
|
+
locales = []
|
9
|
+
|
10
|
+
Dir.open("#{Rails.root}/config/locales").each do |file|
|
11
|
+
unless ['.', '..'].include?(file) || file[0] == '.'
|
12
|
+
locales << file[0...-4] # strip of .yml
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
locales
|
17
|
+
end
|
4
18
|
end
|
5
19
|
end
|
@@ -3,13 +3,7 @@ require_dependency 'expat/application_controller'
|
|
3
3
|
module Expat
|
4
4
|
class LocalesController < ApplicationController
|
5
5
|
def index
|
6
|
-
@locales =
|
7
|
-
|
8
|
-
Dir.open("#{Rails.root}/config/locales").each do |file|
|
9
|
-
unless ['.', '..'].include?(file) || file[0] == '.'
|
10
|
-
@locales << file[0...-4] # strip of .yml
|
11
|
-
end
|
12
|
-
end
|
6
|
+
@locales = list_locales
|
13
7
|
end
|
14
8
|
end
|
15
9
|
end
|
@@ -5,6 +5,7 @@ module Expat
|
|
5
5
|
before_action :load_translations
|
6
6
|
|
7
7
|
def index
|
8
|
+
@translations = append_missing_translations @locale, @translations
|
8
9
|
end
|
9
10
|
|
10
11
|
def edit
|
@@ -36,9 +37,28 @@ module Expat
|
|
36
37
|
|
37
38
|
def load_translations
|
38
39
|
@locale = params[:locale_id]
|
39
|
-
|
40
|
+
@translations = load_translation @locale
|
41
|
+
end
|
42
|
+
|
43
|
+
def load_translation locale
|
44
|
+
path = "#{Rails.root}/config/locales/#{locale}.yml"
|
40
45
|
yml = YAML.load_file path
|
41
|
-
|
46
|
+
iterate yml[locale], ''
|
47
|
+
end
|
48
|
+
|
49
|
+
def append_missing_translations current, current_translations
|
50
|
+
result = {}
|
51
|
+
|
52
|
+
list_locales.each do |locale|
|
53
|
+
next if current == locale
|
54
|
+
|
55
|
+
translation = load_translation locale
|
56
|
+
(current_translations.keys | translation.keys).each do |key|
|
57
|
+
result[key] = current_translations[key]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
result
|
42
62
|
end
|
43
63
|
|
44
64
|
def save_translations
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%
|
2
|
-
|
2
|
+
unless params[:id].present?
|
3
3
|
url = locale_translations_path
|
4
4
|
method = :post
|
5
5
|
else
|
@@ -9,7 +9,7 @@
|
|
9
9
|
%>
|
10
10
|
<%= form_tag url, method: method do |f| %>
|
11
11
|
|
12
|
-
<%
|
12
|
+
<% unless params[:id].present? %>
|
13
13
|
<%= label_tag :key %>
|
14
14
|
<%= text_field_tag :key %><br />
|
15
15
|
|
@@ -7,8 +7,13 @@
|
|
7
7
|
<%= key %>
|
8
8
|
</td>
|
9
9
|
<td>
|
10
|
-
<%= link_to
|
11
|
-
locale_id: @locale, id: key) %>
|
10
|
+
<%= link_to edit_locale_translation_path(
|
11
|
+
locale_id: @locale, id: key) do %>
|
12
|
+
<%= value %>
|
13
|
+
<% if value.blank? %>
|
14
|
+
<span class="translation_missing">missing</span>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
12
17
|
</td>
|
13
18
|
<td>
|
14
19
|
<%= form_tag locale_translation_path(locale_id: @locale, id: key),
|