From 39dc0d1af37cf3bcf3d8789cc6d1828d95349292 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Mon, 19 May 2014 09:17:12 +0200 Subject: Add translations overview --- web/lib/ui/taginfo.rb | 24 ++++++++++++++++++++++++ web/views/taginfo/index.erb | 3 ++- web/views/taginfo/translations.erb | 17 +++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 web/views/taginfo/translations.erb 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 @@

Menu

Software Version

<%= @commit %>

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 @@ +
+

Translations Overview

+
+
+ +<% 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 %> + + + + + + + +<% end %> +
<%= locale.code %><%= locale.title %><%= @num_texts[locale.code] %>/<%= @num_texts['en'] %><%= percent %>%see texts
+
-- cgit v1.2.3