Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation #57

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 103 additions & 103 deletions .idea/Rorbua.iml

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
#before_action :set_locale
before_action :set_locale

protected

Expand All @@ -11,8 +11,7 @@ class ApplicationController < ActionController::Base
end

def set_locale
I18n.locale = params[:locale] || session[:locale] || I18n.default_locale
session[:locale] = I18n.locale
I18n.locale = session[:locale] || I18n.default_locale
end

def after_sign_up_path_for(resource)
Expand Down
8 changes: 1 addition & 7 deletions app/controllers/languages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
class LanguagesController < ApplicationController
before_action :set_language, only: %i[ show edit update destroy ]

# POST /languages or /languages.json
def change
puts "CCCCCCCCCCCCCCCCCCCCC #{params[:set_locale]}"
session[:locale] = I18n.locale = params[:set_locale]
session[:locale] = I18n.locale = params[:locale]
redirect_back(fallback_location: root_path)
end

private
# Use callbacks to share common setup or constraints between actions.
def set_language
@language = Language.find(params[:id])
end

# Only allow a list of trusted parameters through.
def language_params
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<%= form_for(resource, as: resource_name, data: { turbo: false}, url: registration_path(resource_name), html: { method: :put }) do |f| %>

<div class="mb-3">
<%= f.label :user_image, "Profilbilde", class: "form-label" %>
<%= f.label :user_image, t(".profile_picture") , class: "form-label" %>
<%= f.file_field :user_image, class: "form-control" %>
<%= error_message_on(f.object, :user_image) %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="mb-3">
<%= f.label :password, t(".password") %>
<br />
<%= f.password_field :password, autocomplete: "new-password", class: "form-control",placeholder: "#{@minimum_password_length} tegn minimum" %>
<%= f.password_field :password, autocomplete: "new-password", class: "form-control",placeholder: "#{@minimum_password_length} #{t(".letters_minimum")}" %>
<%= error_message_on(f.object, :password) %>
</div>

Expand Down
18 changes: 0 additions & 18 deletions app/views/languages/_form.html.erb

This file was deleted.

11 changes: 5 additions & 6 deletions app/views/layouts/_language_selector.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

<aside>
<%= form_tag change_languages_path, class: 'locale' do %>
<%= select_tag 'set_locale', options_for_select(LANGUAGES, I18n.locale.to_s),
onchange: 'this.form.submit()', class: "form-select"%>
<aside class="mr-3">
<%= form_tag change_language_path(I18n.locale.to_s) do %>
<%= select_tag 'locale', options_for_select(LANGUAGES, I18n.locale.to_s),
onchange: 'this.form.submit()', style: "padding: 2px 2px 2px 8px; width: 96px", class: "form-select"%>
<% end %>
</aside>
</aside>
2 changes: 1 addition & 1 deletion app/views/layouts/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<div>
<ul class="nav">
<!-- render 'layouts/language_selector' -->
<%= render 'layouts/language_selector' %>
<% if user_signed_in? %>
<li class="nav-item dropdown">
<a data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<%= link_to t(".new_story"), new_story_path, class:"nav-link" %>
</li>
<li class="nav-item">
<%= link_to "Mine spillelister", playlists_path, class:"nav-link" %>
<%= link_to t(".my_playlists"), playlists_path, class:"nav-link" %>
</li>
<li class="nav-item">
<%= link_to t(".my_stories"), my_stories_path, class:"nav-link" %>
Expand Down
3 changes: 1 addition & 2 deletions app/views/layouts/_welcome_alert.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
</button>

<p class="mx-3">
Storytime er en app hvor brukere kan dele og høre på morsomme historier.
Vær hyggelig og ha det gøy!
<%= t('.welcome_alert_text') %>
</p>

</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/playlists/partials/_new_playlist_btn.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div id="btn-new-playlist">
<%= button_to "Lag ny spilleliste", new_playlist_path, class:"btn btn-primary", method: :post %>
<%= button_to t('.create_new_playlist') , new_playlist_path, class:"btn btn-primary", method: :post %>
</div>
6 changes: 3 additions & 3 deletions app/views/playlists/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
</div>
<div class="col text-end">
<% if @playlist.playlist_stories.count > 0 %>
<%= link_to "Spill av spilleliste", playlist_play_story_path(@playlist, @playlist.playlist_stories.last), class:"btn btn-primary" %>
<%= link_to t('.play_all'), playlist_play_story_path(@playlist, @playlist.playlist_stories.last), class:"btn btn-primary" %>
<% else %>
<h5>Denne spillelisten er tom</h5>
<%= link_to "Utforsk stories", root_path, class:"btn btn-secondary my-3" %>
<h5> <%= t('.this_playlist_is_empty') %> </h5>
<%= link_to t('.discorver stories'), root_path, class:"btn btn-secondary my-3" %>
<% end %>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/profiles/partials/_nav_items.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<% end %>

<% if playlists == true %>
<%= button_to "Spillelister", profile_playlists_path(@user), class: "nav-link active btn" %>
<%= button_to t('.playlists'), profile_playlists_path(@user), class: "nav-link active btn" %>
<% else %>
<%= button_to "Spillelister", profile_playlists_path(@user), class: "nav-link btn" %>
<%= button_to t('.playlists'), profile_playlists_path(@user), class: "nav-link btn" %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/profiles/partials/_playlists.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- brukeren sine spillelister -->
<div class="container">

<h2 class="py-2">Spillelister</h2>
<h2 class="py-2"><%= t('.playlists') %> </h2>

<% if @user == current_user %>
<div id="new_playlist_div">
Expand Down
3 changes: 1 addition & 2 deletions app/views/profiles/partials/_profile_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
<!-- endre-konto-knapp -->
<div style="width:180px">
<% if @user == current_user %>
<%= link_to "Endre min konto", edit_user_registration_path, class: "btn btn-secondary" %>
<%= link_to t('.edit_my_account'), edit_user_registration_path, class: "btn btn-secondary" %>
<% end %>
</div>
</div>


<!-- navbar -->
<div class="row">
<nav class="navbar navbar-expand navbar-light bg-light">
Expand Down
5 changes: 2 additions & 3 deletions app/views/stories/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>

<div class="mb-5" id="thumbnail-input">
<%= form.label :thumbnail, "Velg bildefil", class:"form-label" %>
<%= form.label :thumbnail, t('.choose_image_file'), class:"form-label" %>
<span class="material-icons mx-2" data-bs-toggle="tooltip" data-bs-placement="top" title="Velg bilde som skal vises">
info_outline
</span>
Expand All @@ -41,7 +41,7 @@
</div>

<div class ="field" id="checkboxes">
<%= form.label :story, "Velg en til flere kategorier:", class: "form-label" %>
<%= form.label :story, t('.choose_one_or_more_categories'), class: "form-label" %>
<span class="material-icons mx-2" data-bs-toggle="tooltip" data-bs-placement="top" title="Legg til en eller flere kategorier">
info_outline
</span>
Expand All @@ -50,7 +50,6 @@
b.label(:"data-value" => b.value) { b.check_box + b.label }
end %>
<%= error_message_on(form.object, :category_ids) %>

</div>

<div class="mb-4">
Expand Down
4 changes: 2 additions & 2 deletions app/views/stories/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div id="stories" class="feed_stories_container mt-1">
<div class="container">
<button type="button" class="btn btn-secondary mt-1 " data-bs-toggle="modal" data-bs-target="#category-modal" aria-expanded="false" margin-top="1">Søk i stories</button>
<button type="button" class="btn btn-secondary mt-1 " data-bs-toggle="modal" data-bs-target="#category-modal" aria-expanded="false" margin-top="1"> <%= t('.search_for_stories') %> </button>

<div class="row g-4">

Expand All @@ -13,4 +13,4 @@
<% end %>
</div>
</div>
</div>
</div>
6 changes: 3 additions & 3 deletions app/views/stories/partials/_story_play.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<span type="button" class="btn material-icons" data-bs-toggle="modal" data-bs-target="#playlist-modal" aria-expanded="false" style="color:black;background-color: transparent; border: none">
playlist_add
</span>
<p class="">Lagre</p>
<p class=""> <%= t('.add') %> </p>
</div>
</div>
</div>
Expand Down Expand Up @@ -69,8 +69,8 @@
</div>

<div class="col-12">
<button class="btn btn-sm fw-bold" data-storydescription-target="show_more" data-action="storydescription#toggleDesc">Vis mer</button>
<button class="btn btn-sm fw-bold" data-storydescription-target="show_less" data-action="storydescription#toggleDesc" hidden>Vis mindre</button>
<button class="btn btn-sm fw-bold" data-storydescription-target="show_more" data-action="storydescription#toggleDesc"> <%= t('.show_more') %> </button>
<button class="btn btn-sm fw-bold" data-storydescription-target="show_less" data-action="storydescription#toggleDesc" hidden> <%= t('.show_less') %> </button>
</div>

</div>
Expand Down
1 change: 0 additions & 1 deletion config/initializers/i18.rb

This file was deleted.

10 changes: 9 additions & 1 deletion config/locales/device.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ en:
not_locked: "was not locked"
not_saved:
one: "1 error prohibited this %{resource} from being saved:"
other: "%{count} errors prohibited this %{resource} from being saved:"
other: "%{count} errors prohibited this %{resource} from being saved:"
stories:
partials:
audio_controls:
autoplay_next: ""
playlists:
partials:
story_card:
uploaded: ""
8 changes: 8 additions & 0 deletions config/locales/devise.nb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ nb:
not_saved:
one: "1 feil forhindret dette %{resource} i å bli lagret:"
other: "%{count} feil forhindrer dette %{resource} i å bli lagret:"
stories:
partials:
audio_controls:
autoplay_next: ""
playlists:
partials:
story_card:
uploaded: ""
49 changes: 44 additions & 5 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ en:
registrations:
edit:
title: "Edit account"
profile_picture: "Profile picture"
username: "Username"
new_password: "New password"
leave_empty: "(leave empty if you dont want to change)"
Expand All @@ -57,6 +58,7 @@ en:
new:
username: "Username"
password: "Password"
letters_minimum: "letters minimum"
confirm_password: "Confirm Password"
already_have_an_account: "Already have an account?"
log_in: "Log in"
Expand All @@ -79,7 +81,7 @@ en:
ago: "ago"
remove_from_favourites: "Remove from favourites"
favourites_counter:
videoes: "videoes"
videoes: "videos"
index:
title: "Favourites"

Expand All @@ -91,24 +93,61 @@ en:
sidebar:
home: "Home"
new_story: "New story"
my_playlists: "My Playlists"
my_stories: "My stories"
favorites: "Favorites"
welcome_alert:
welcome_alert_text: "Storytime is an app where users can share and listen to funny stories.
Be nice and have fun!"

playlists:
partials:
new_playlist_btn:
create_new_playlist: "Create new playlist"
story_card:
uploaded: "Uploaded"
ago: "ago"
show:
play_all: "Play all"
this_playlist_is_empty: "This playlist is empty"
discorver stories: "Discover stories"

profiles:
partials:
nav_items:
playlists: "Playlists"
playlists:
playlists: "Playlists"
profile_navbar:
edit_my_account: "Edit my account"

stories:
partials:
audio_controls:
autoplay_next: "Autoplay next"
story_card:
uploaded: "Uploaded"
ago: "ago"
story_play:
edit_story: "Edit Story"
add: "Add"
show_more: "Show more"
show_less: "Show less"
form:
title: "Title"
add_a_title_to_your_story: "Add a title to your story"
description: "Description"
choose_file: "Choose file"
choose_image_file: "Choose image file"
create_story: "Create story"
choose_one_or_more_categories: "Choose one or more categories"
story:
edit_story: "Edit story"
story_card:
uploaded: "Uploaded"
ago: "ago"
edit:
delete_story: "Delete story"
show_story: "Show story"
back_to_stories: "Back to stories"
index:
search_for_stories: "Search for stories"
my_stories:
title: "My stories"
new:
Expand Down
Loading