%
@page_title = "Translate"
show_filters = ["all", "untranslated", "translated"]
show_filters << "changed" if @from_locale != @to_locale
%>
<%= form_tag(params, :method => :get, :name => 'filter_form') do %>
<%= hidden_field_tag(:filter, params[:filter]) %>
<%= hidden_field_tag(:sort_by, params[:sort_by]) %>
<% if @page_title %>
<%= select_tag(:from_locale, options_for_select(I18n.available_locales, @from_locale.to_sym)) %> to
<%= select_tag(:to_locale, options_for_select(I18n.available_locales, @to_locale.to_sym)) %>
<%= submit_tag "Display" %>
<%= link_to '.. /', '../' %>
<%= link_to @page_title, root_path %>
<%= simple_filter(show_filters).html_safe %>
Found <%= @total_entries %> messages
<%= link_to "Reload messages", translate_reload_path %>
<% end %>
<% flash.each do |key, msg| %>
<%= msg %>
<% end %>
<%= select_tag(:key_type, options_for_select([["Key contains", 'contains'], ["Key starts with", 'starts_with']], params[:key_type])) %>
<%= text_field_tag(:key_pattern, params[:key_pattern], :size => 50, :id => "key_pattern_value", :class => "text-default") %>
<%= select_tag(:text_type, options_for_select([['Text contains','contains'], ['Text equals','equals']], params[:text_type])) %>
<%= text_field_tag(:text_pattern, params[:text_pattern], :size => 50, :id => "text_pattern_value", :class => "text-default") %>
<%= link_to "clear", params.merge({:text_pattern => nil, :key_pattern => nil}), class: 'btn' %>
<%= submit_tag "Search" %>
<%= link_to "Export language file", translate_export_path(:locale => @to_locale), class: 'btn sep' %>
<% end %>
<%= build_namespace(@deep_keys).html_safe %>
<%= render :partial => 'pagination', :locals => {:total_entries => @total_entries, :per_page => per_page} %>
<% if @total_entries > 0 %>
<%= form_tag(translate_path, method: :put) do %>
<%= hidden_field_tag(:filter, params[:filter], :id => "hid_filter") %>
<%= hidden_field_tag(:sort_by, params[:sort_by], :id => "hid_sort_by") %>
<%= hidden_field_tag(:key_type, params[:key_type], :id => "hid_key_type") %>
<%= hidden_field_tag(:key_pattern, params[:key_pattern], :id => "hid_key_pattern") %>
<%= hidden_field_tag(:text_type, params[:text_type], :id => "hid_text_type") %>
<%= hidden_field_tag(:text_pattern, params[:text_pattern], :id => "hid_text_pattern") %>
Translations from <%= @from_locale %> to <%= @to_locale %>
<%= simple_filter(["key", "text"], 'sort_by').html_safe %>
<%= submit_tag "Save Translations", style: 'float:right;' %>
<% @paginated_keys.each do |key|
from_text = lookup(@from_locale, key)
to_text = lookup(@to_locale, key)
line_size = 100
n_lines = n_lines(from_text, line_size)
field_name = "key[#{key}]"
tid = key.split('.').join("_")
%>
<%= hidden_field_tag("version[#{key}]", @versions[key] || '0') %>
<% if n_lines > 1 %>
<%=h key %>
<% if @files[key] %>
<%= @files[key].join("").html_safe %>
<% end %>
<%= text_area_tag(field_name, to_text, :rows => n_lines+1, :id => tid) %>
<% else %>
<%= from_text %>
<%=h key %>
<% if @files[key] %>
<%= @files[key].join("").html_safe %>
<% end %>
<%= text_field_tag(field_name, to_text, :size => line_size, :id => tid) %>
<% end %>
<% end %>
Translations from <%= @from_locale %> to <%= @to_locale %>
<%= submit_tag "Save Translations", style: 'float:right' %>
<% end %>
<% end %>
<%= render :partial => 'pagination', :locals => {:total_entries => @total_entries, :per_page => per_page} %>