add traductions

This commit is contained in:
2021-04-24 23:46:16 +02:00
parent f43ba76984
commit 9082e5255e
62 changed files with 413 additions and 38 deletions

View File

@@ -2,11 +2,25 @@ class ApplicationController < ActionController::Base
around_action :switch_locale
def switch_locale(&action)
locale = I18n.locale_available?(request.headers['Locale']) ? request.headers['Locale'] : I18n.default_locale
locale = extract_locale
I18n.with_locale(locale, &action)
end
def new_session_path(_scope)
new_user_session_path
end
def extract_locale
if params[:locale]
I18n.locale_available?(params[:locale]) ? params[:locale] : I18n.default_locale
elsif request.env['HTTP_ACCEPT_LANGUAGE']
I18n.locale_available?(request.env['HTTP_ACCEPT_LANGUAGE']) ? request.env['HTTP_ACCEPT_LANGUAGE'] : I18n.default_locale
else
I18n.default_locale
end
end
def default_url_options
{ locale: I18n.locale }
end
end

View File

@@ -12,6 +12,7 @@ import "bootstrap"
import "../stylesheets/application"
import "@fortawesome/fontawesome-free/css/all"
import "flag-icon-css/sass/flag-icon"
document.addEventListener("turbolinks:load", () => {
$('[data-toggle="tooltip"]').tooltip()

View File

@@ -0,0 +1,19 @@
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-globe-europe"></i>
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-de"></span>'.html_safe, root_path(locale: 'de-de') %></li>
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-gb"></span>'.html_safe, root_path(locale: 'en-gb') %></li>
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-us"></span>'.html_safe, root_path(locale: 'en-us') %></li>
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-mx"></span>'.html_safe, root_path(locale: 'es-mx') %></li>
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-br"></span>'.html_safe, root_path(locale: 'pt-br') %></li>
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-es"></span>'.html_safe, root_path(locale: 'es-es') %></li>
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-fr"></span>'.html_safe, root_path(locale: 'fr-fr') %></li>
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-it"></span>'.html_safe, root_path(locale: 'it') %></li>
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-ru"></span>'.html_safe, root_path(locale: 'ru-ru') %></li>
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-kr"></span>'.html_safe, root_path(locale: 'ko') %></li>
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-tw"></span>'.html_safe, root_path(locale: 'zh-tw') %></li>
<li class="dropdown-item"><%= link_to '<span class="flag-icon flag-icon-cn"></span>'.html_safe, root_path(locale: 'zh-cn') %></li>
</ul>
</li>

View File

@@ -5,16 +5,19 @@
<% if user_signed_in? %>
<ul class="navbar-nav mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="<%= wow_characters_path %>">Characters</a>
<a class="nav-link active" aria-current="page" href="<%= wow_characters_path %>"><%= t('layouts.navbar.characters') %></a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="<%= wow_mounts_path %>">Mounts</a>
<a class="nav-link active" aria-current="page" href="<%= wow_mounts_path %>"><%= t('layouts.navbar.mounts') %></a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="<%= wow_pets_path %>">Pets</a>
<a class="nav-link active" aria-current="page" href="<%= wow_pets_path %>"><%= t('layouts.navbar.pets') %></a>
</li>
</ul>
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<%= render 'layouts/locales' %>
</ul>
<ul class="navbar-nav mb-2 mb-lg-0">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Menu
@@ -26,7 +29,10 @@
</ul>
</li>
<% else %>
<%= link_to 'Sign in with <i class="fab fa-battle-net"></i>'.html_safe, user_bnet_omniauth_authorize_path, method: :post, class: "btn btn-primary nav-item" %>
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<%= render 'layouts/locales' %>
<%= link_to 'Sign in with <i class="fab fa-battle-net"></i>'.html_safe, user_bnet_omniauth_authorize_path, method: :post, class: "btn btn-primary nav-item" %>
</ul>
<% end %>
</ul>
</div>

View File

@@ -4,13 +4,13 @@
<thead>
<tr>
<th scope="col"></th>
<th scope="col"><%= t('character_list.name') %></th>
<th scope="col"><%= t('character_list.gender') %></th>
<th scope="col"><%= t('character_list.realm') %></th>
<th scope="col"><%= t('character_list.race') %></th>
<th scope="col"><%= t('character_list.class') %></th>
<th scope="col"><%= t('character_list.faction') %></th>
<th scope="col"><%= t('character_list.level') %></th>
<th scope="col"><%= t('wow_characters.character_list.name') %></th>
<th scope="col"><%= t('wow_characters.character_list.gender') %></th>
<th scope="col"><%= t('wow_characters.character_list.realm') %></th>
<th scope="col"><%= t('wow_characters.character_list.race') %></th>
<th scope="col"><%= t('wow_characters.character_list.class') %></th>
<th scope="col"><%= t('wow_characters.character_list.faction') %></th>
<th scope="col"><%= t('wow_characters.character_list.level') %></th>
</tr>
</thead>
<tbody>

View File

@@ -3,9 +3,9 @@
<table class="table table-hover table-dark table-image">
<thead>
<tr>
<th scope="col"><%= t('mount_list.name') %></th>
<th scope="col"><%= t('mount_list.description') %></th>
<th scope="col"><%= t('mount_list.owned') %></th>
<th scope="col"><%= t('wow_mounts.mount_list.name') %></th>
<th scope="col"><%= t('wow_mounts.mount_list.description') %></th>
<th scope="col"><%= t('wow_mounts.mount_list.owned') %></th>
</tr>
</thead>
<tbody>

View File

@@ -3,9 +3,9 @@
<table class="table table-hover table-dark table-image">
<thead>
<tr>
<th scope="col"><%= t('pet_list.name') %></th>
<th scope="col"><%= t('pet_list.description') %></th>
<th scope="col"><%= t('pet_list.owned') %></th>
<th scope="col"><%= t('wow_pets.pet_list.name') %></th>
<th scope="col"><%= t('wow_pets.pet_list.description') %></th>
<th scope="col"><%= t('wow_pets.pet_list.owned') %></th>
</tr>
</thead>
<tbody>