aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2014-05-19 09:17:12 +0200
committerJochen Topf <jochen@topf.org>2014-05-19 09:17:12 +0200
commit39dc0d1af37cf3bcf3d8789cc6d1828d95349292 (patch)
tree8df7196feed5615366a85f7d37a2c87e7ec14e01
parent26737986b64effc3c424e3518672ab132fd9afd6 (diff)
downloadtaginfo-39dc0d1af37cf3bcf3d8789cc6d1828d95349292.tar
taginfo-39dc0d1af37cf3bcf3d8789cc6d1828d95349292.tar.gz
Add translations overview
-rw-r--r--web/lib/ui/taginfo.rb24
-rw-r--r--web/views/taginfo/index.erb3
-rw-r--r--web/views/taginfo/translations.erb17
3 files changed, 43 insertions, 1 deletions
diff --git a/web/lib/ui/taginfo.rb b/web/lib/ui/taginfo.rb
index 2e61d1a..e688f82 100644
--- a/web/lib/ui/taginfo.rb
+++ b/web/lib/ui/taginfo.rb
@@ -1,6 +1,16 @@
# web/lib/ui/taginfo.rb
class Taginfo < Sinatra::Base
+ def count_texts(data)
+ data.values.map{ |value|
+ if value.is_a?(Hash)
+ count_texts(value)
+ else
+ 1
+ end
+ }.inject(0, :+)
+ end
+
def i18n_walk(line, level, path, en, other)
out = ''
en.keys.sort.each do |key|
@@ -43,6 +53,20 @@ class Taginfo < Sinatra::Base
end
end
+ get '/taginfo/translations' do
+ @title = 'Translations Overview'
+ @section = 'taginfo'
+ @section_title = t.taginfo.meta
+
+ @num_texts = {}
+ r18n.available_locales.each do |lang|
+ data = YAML.load_file("i18n/#{lang.code}.yml")
+ @num_texts[lang.code] = count_texts(data)
+ end
+
+ erb :'taginfo/translations'
+ end
+
get '/taginfo/i18n' do
@title = 'Translations of taginfo texts'
@section = 'taginfo'
diff --git a/web/views/taginfo/index.erb b/web/views/taginfo/index.erb
index 9bd0752..32f904c 100644
--- a/web/views/taginfo/index.erb
+++ b/web/views/taginfo/index.erb
@@ -6,7 +6,8 @@
<h2>Menu</h2>
<ul>
<li><a href="/taginfo/apidoc"><%= t.taginfo.apidoc %></a></li>
- <li><a href="/taginfo/i18n">taginfo text translations</a></li>
+ <li><a href="/taginfo/translations">Translations Overview</a></li>
+ <li><a href="/taginfo/i18n">Translated Texts</a></li>
</ul>
<h2>Software Version</h2>
<p><%= @commit %></p>
diff --git a/web/views/taginfo/translations.erb b/web/views/taginfo/translations.erb
new file mode 100644
index 0000000..ce84bc9
--- /dev/null
+++ b/web/views/taginfo/translations.erb
@@ -0,0 +1,17 @@
+<div class="pre">
+ <h1>Translations Overview</h1>
+</div>
+<div class="box resize">
+ <table class="list">
+<% r18n.available_locales.sort{ |a,b| a.code <=> b.code }.each do |locale| %>
+<% percent = (@num_texts[locale.code].to_f / @num_texts['en'].to_f * 100).to_i %>
+ <tr>
+ <td><span class="lang"><%= locale.code %></span></td>
+ <td><%= locale.title %></td>
+ <td class="tr"><%= @num_texts[locale.code] %>/<%= @num_texts['en'] %></td>
+ <td class="tr <%= percent > 90 ? 'good' : ( percent <= 80 ? 'bad' : 'okay' ) %>"><%= percent %>%</td>
+ <td><a href="/taginfo/i18n?lang=<%= locale.code %>">see texts</a></td>
+ </tr>
+<% end %>
+ </table>
+</div>