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 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'web/lib') 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' -- cgit v1.2.3