webdestroya/sourcemod-translator

View on GitHub
app/views/translations/_form.html.erb

Summary

Maintainability
Test Coverage

<%= form_for(@translation, :html => {:class => "form-horizontal"}) do |f| %>

  <% if params[:random] %>
  <%= hidden_field_tag :random, "1" %>
  <% end %>

  <% if @plugin %>
  <%= hidden_field_tag :plugin_id, @plugin.id %>
  <% end %>

  <%= f.hidden_field :phrase_id %>

  <% if @translation.errors.any? %>
    <%= error_box do %>
      <h4><%= pluralize(@translation.errors.count, "error") %> prevented this translation from being saved:</h4>

      <ul>
      <% @translation.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    <% end %>
  <% end %>

  <div class="control-group">
    <%= f.label SourcemodPlugin.model_name.human, :class => "control-label" %>
    <div class="controls">
      <span class="form-line"><%= link_to @phrase.sourcemod_plugin.name, @phrase.sourcemod_plugin %></span>
    </div>
  </div>

  <div class="control-group">
    <%= f.label Phrase.model_name.human, :class => "control-label" %>
    <div class="controls">
      <span class="form-line"><%= link_to @phrase.name, @phrase %></span>
    </div>
  </div>

  
  <div class="control-group">
    <%= f.label :language_id, :class => "control-label" %>
    <div class="controls">
      <%= select(:translation, :language_id, @languages.collect{|l| [l.name, l.id]}) %>
    </div>
  </div>

  <% if @phrase.format %>
  <div class="control-group">
    <%= f.label Phrase.human_attribute_name(:format), :class => "control-label" %>
    <div class="controls">
      <span class="form-line"><code><%= @phrase.format %></code>
        <% if @phrase.format_infos.count > 0 %>
        <ol class="format-info">
          <% @phrase.format_infos.each do |fmt| %>
          <li><strong><%= fmt.type %></strong> <%= fmt.description %></li>
          <% end %>
        </ol>
        <% end %>
      </span>
    </div>
  </div>
  <% end %>


  <div class="control-group">
    <%= f.label Phrase.human_attribute_name(:english), :class => "control-label" %>
    <div class="controls">
      <span class="form-line"><%= phrase_text @phrase.english.text %></span>
    </div>
  </div>

  <div class="control-group">
    <%= f.label :text, :class => "control-label" %>
    <div class="controls">
      <%= f.text_field :text, :class => "span8" %>
      <span class="help-inline">Add your translation using the language you specified above. 
        <strong>Note:</strong> Make sure to escape all quotes! <code>\&quot;</code>
      </span>
    </div>
  </div>
  <div class="control-group">
    <div class="controls">
      <%= f.submit :class => "btn btn-primary" %>
      <% if params[:random] %>
      <%= link_to "Skip Translation", random_translations_path(:plugin_id => params[:plugin_id]), :class => "btn" %>
      <% end %>
    </div>
  </div>
<% end %>

<% if params[:random] %>
<%= info_box do %>
<strong>You are in random translation mode!</strong>
<br/>
This will let you add translations for any plugin that needs a translation in your language. If you are unsure of a translation, you can press <strong>Skip Translation</strong> at any time.
<% end %>
<% end %>