Skip to content

Commit

Permalink
Merge pull request #354 from blackcandy-org/locales
Browse files Browse the repository at this point in the history
Reorganize i18n file content
  • Loading branch information
aidewoode authored Feb 26, 2024
2 parents a749669 + 3abf4ff commit 658ee33
Show file tree
Hide file tree
Showing 47 changed files with 151 additions and 165 deletions.
2 changes: 1 addition & 1 deletion app/controllers/albums_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def show

def update
if @album.update(album_params)
flash[:success] = t("success.update")
flash[:success] = t("notice.updated")
else
flash_errors_message(@album)
end
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
include Pagy::Backend
include SessionsHelper

helper_method :native_app?, :need_transcode?, :render_flash, :mobile?
helper_method :native_app?, :need_transcode?, :render_flash, :mobile?, :dialog?

before_action :find_current_session
before_action :find_current_request_details
Expand Down Expand Up @@ -83,6 +83,10 @@ def mobile?
browser.device.mobile?
end

def dialog?
is_a? Dialog::DialogController
end

private

def find_current_session
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/artists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def show

def update
if @artist.update(artist_params)
flash[:success] = t("success.update")
flash[:success] = t("notice.updated")
else
flash_errors_message(@artist)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/current_playlist/songs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create
@playlist.playlists_songs.create(song_id: @song.id, position: @current_song_position + 1)
end

flash.now[:success] = t("success.add_to_playlist")
flash.now[:success] = t("notice.added_to_playlist")

redirect_to action: "index", should_play_all: params[:should_play] if @playlist.songs.count == 1
rescue ActiveRecord::RecordNotUnique
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/playlists/songs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def create
@song = Song.find(params[:song_id])
@playlist.songs.push(@song)

flash[:success] = t("success.add_to_playlist")
flash[:success] = t("notice.added_to_playlist")
rescue ActiveRecord::RecordNotUnique
flash[:error] = t("error.already_in_playlist")
ensure
Expand All @@ -22,7 +22,7 @@ def create

def destroy
@playlist.songs.destroy(@song)
flash.now[:success] = t("success.delete_from_playlist")
flash.now[:success] = t("notice.deleted_from_playlist")

# for refresh playlist content, when remove last song from playlist
redirect_to action: "index" if @playlist.songs.empty?
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/playlists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def create
@playlist = Current.user.playlists.new playlist_params

if @playlist.save
flash[:success] = t("success.create")
flash[:success] = t("notice.created")
else
flash_errors_message(@playlist)
end
Expand All @@ -22,7 +22,7 @@ def create

def update
if @playlist.update(playlist_params)
flash[:success] = t("success.update")
flash[:success] = t("notice.updated")
else
flash_errors_message(@playlist)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def update
setting = Setting.instance

if setting.update(setting_params)
flash.now[:success] = t("success.update")
flash.now[:success] = t("notice.updated")
else
flash_errors_message(setting, now: true)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Users::SettingsController < ApplicationController

def update
return unless @user.update(user_setting_params)
flash.now[:success] = t("success.update")
flash.now[:success] = t("notice.updated")
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def create
@user = User.new user_params

if @user.save
flash[:success] = t("success.create")
flash[:success] = t("notice.created")
redirect_to users_path
else
flash_errors_message(@user, now: true)
Expand All @@ -29,7 +29,7 @@ def create

def update
if @user.update(user_params)
flash.now[:success] = t("success.update")
flash.now[:success] = t("notice.updated")
else
flash_errors_message(@user, now: true)
end
Expand All @@ -40,7 +40,7 @@ def destroy
raise BlackCandy::Forbidden if @user == Current.user

@user.destroy
flash.now[:success] = t("success.delete")
flash.now[:success] = t("notice.deleted")
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def is_active?(controller: "", path: "")

def page_title_tag(title)
title_suffix = " - #{t(:app_name)}"
title = "#{title}#{title_suffix unless native_app?}"
title = "#{title}#{title_suffix unless native_app? || dialog?}"

content_for(:title, title)
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/albums/_filters.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<details class='c-dropdown u-mr-small' data-controller="dropdown">
<summary class='c-button c-button--outline c-button--small'>
<span class='o-flex o-flex--align-center'>
<%= t("label.genre") %>
<%= t("field.genre") %>
<%= icon_tag "expand-more" %>
</span>
</summary>
Expand All @@ -26,7 +26,7 @@
<details class='c-dropdown u-mr-small' data-controller="dropdown">
<summary class='c-button c-button--outline c-button--small'>
<span class='o-flex o-flex--align-center'>
<%= t("label.year") %>
<%= t("field.year") %>
<%= icon_tag "expand-more" %>
</span>
</summary>
Expand Down
6 changes: 3 additions & 3 deletions app/views/albums/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
<div class='u-mt-large'>
<%= button_to(
t("label.play_all"),
t("button.play_all"),
current_playlist_album_path(@album),
method: :put,
form_class: "u-display-inline-block",
Expand Down Expand Up @@ -78,7 +78,7 @@
class: "c-dropdown__item"
) %>
<%= button_to(
t("label.play_next"),
t("button.play_next"),
current_playlist_songs_path(song_id: song.id),
form_class: "c-dropdown__item",
form: {
Expand All @@ -90,7 +90,7 @@
}
) %>
<%= button_to(
t("label.play_last"),
t("button.play_last"),
current_playlist_songs_path(song_id: song.id, location: "last"),
form_class: "c-dropdown__item",
form: {
Expand Down
2 changes: 1 addition & 1 deletion app/views/current_playlist/songs/_song.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div class='c-dropdown__menu' data-dropdown-target="menu">
<%= link_to t("label.add_to_playlist"), dialog_playlists_path(song_id: song.id, referer_url: current_url), data: {"turbo-frame" => ("turbo-dialog" unless native_app?)}, class: "c-dropdown__item" %>

<%= button_to t("label.delete"), current_playlist_song_path(song), method: :delete, form_class: "c-dropdown__item", form: {data: {"turbo-frame" => "turbo-playlist"}} %>
<%= button_to t("button.delete"), current_playlist_song_path(song), method: :delete, form_class: "c-dropdown__item", form: {data: {"turbo-frame" => "turbo-playlist"}} %>
</div>
</details>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/current_playlist/songs/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<details class='c-dropdown' data-controller='dropdown' data-test-id='playlist_menu'>
<summary class="c-button c-button--icon"><%= icon_tag "more-vertical", title: t("label.more") %></summary>
<div class='c-dropdown__menu' data-dropdown-target="menu">
<%= button_to t("label.clear"), current_playlist_songs_path, method: :delete, form_class: "c-dropdown__item" %>
<%= button_to t("button.clear"), current_playlist_songs_path, method: :delete, form_class: "c-dropdown__item" %>
</div>
</details>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/dialog/albums/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

<%= form_with model: @album, data: {"turbo-frame" => "_top", "turbo-action" => ("replace" if native_app?), "test-id" => "album_edit_form"}, class: "c-form" do |form| %>
<div class='c-form__field'>
<%= form.label :cover_image, t("label.album_cover") %>
<%= form.label :cover_image, t("field.album_cover") %>
<%= form.file_field :cover_image, accept: "image/png, image/jpeg", class: "c-input" %>
</div>
<div class='c-form__field c-form__field--submit'>
<%= form.submit t("label.save"), class: "c-button c-button--primary c-button--full-width" %>
<%= form.submit t("button.save"), class: "c-button c-button--primary c-button--full-width" %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/dialog/artists/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

<%= form_with model: @artist, data: {"turbo-frame" => "_top", "turbo-action" => ("replace" if native_app?), "test-id" => "artist_edit_form"}, class: "c-form" do |form| %>
<div class='c-form__field'>
<%= form.label :cover_image, t("label.artist_cover") %>
<%= form.label :cover_image, t("field.artist_cover") %>
<%= form.file_field :cover_image, accept: "image/png, image/jpeg", class: "c-input" %>
</div>
<div class='c-form__field c-form__field--submit'>
<%= form.submit t("label.save"), class: "c-button c-button--primary c-button--full-width" %>
<%= form.submit t("button.save"), class: "c-button c-button--primary c-button--full-width" %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/dialog/playlists/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
}
) do |form| %>
<div class='c-form__field'>
<%= form.label :name, t("label.name") %>
<%= form.label :name, t("field.name") %>
<%= form.text_field :name, class: "c-input" %>
</div>

<div class='c-form__field c-form__field--submit'>
<%= form.submit t("label.save"), class: "c-button c-button--primary c-button--full-width" %>
<%= form.submit t("button.save"), class: "c-button c-button--primary c-button--full-width" %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/dialog/playlists/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<%= form_with model: @playlist, class: "c-form", data: {"turbo-frame" => "_top", "turbo-action" => ("replace" if native_app?)} do |form| %>
<div class='c-form__field'>
<%= form.label :name, t("label.name") %>
<%= form.label :name, t("field.name") %>
<%= form.text_field :name, class: "c-input" %>
</div>

<div class='c-form__field c-form__field--submit'>
<%= form.submit t("label.save"), class: "c-button c-button--primary c-button--full-width" %>
<%= form.submit t("button.save"), class: "c-button c-button--primary c-button--full-width" %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/favorite_playlist/songs/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class='u-mt-large'>
<% unless @songs.blank? %>
<%= button_to(
t("label.play_all"),
t("button.play_all"),
current_playlist_playlist_path(@playlist),
method: :put,
class: "c-button c-button--primary",
Expand All @@ -27,7 +27,7 @@
}
}
) %>
<%= button_to t("label.clear"), favorite_playlist_songs_path, class: "c-button c-button--secondary", form_class: "u-display-inline-block", method: :delete %>
<%= button_to t("button.clear"), favorite_playlist_songs_path, class: "c-button c-button--secondary", form_class: "u-display-inline-block", method: :delete %>
<% end %>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/views/media_syncing/_button.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<div id="turbo-media-syncing-button">
<% if syncing %>
<%= button_to(
t("label.syncing"),
t("button.syncing"),
false,
class: "c-button c-button--secondary",
data: {"test-id" => "media_sync_button"},
disabled: true
) %>
<% else %>
<%= button_to(
t("label.sync"),
t("button.sync"),
media_syncing_path,
class: "c-button c-button--secondary",
data: {
"test-id" => "media_sync_button",
"turbo-submits-with" => t("label.syncing")
"turbo-submits-with" => t("button.syncing")
}
) %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/media_syncing/_syncing.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= turbo_stream.replace "turbo-media-syncing-button", partial: "media_syncing/button", locals: {syncing: syncing} %>

<% unless syncing %>
<%= render_flash(message: t("text.sync_completed")) %>
<%= render_flash(message: t("notice.sync_completed")) %>
<% end %>
6 changes: 3 additions & 3 deletions app/views/playlists/songs/_song.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
class: "c-dropdown__item"
) %>
<%= button_to(
t("label.play_next"),
t("button.play_next"),
current_playlist_songs_path(song_id: song.id),
form_class: "c-dropdown__item",
form: {
Expand All @@ -46,7 +46,7 @@
}
) %>
<%= button_to(
t("label.play_last"),
t("button.play_last"),
current_playlist_songs_path(song_id: song.id, location: "last"),
form_class: "c-dropdown__item",
form: {
Expand All @@ -58,7 +58,7 @@
}
) %>
<%= button_to(
t("label.delete"),
t("button.delete"),
playlist_song_path(playlist, song),
method: :delete,
form_class: "c-dropdown__item"
Expand Down
6 changes: 3 additions & 3 deletions app/views/playlists/songs/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class='u-mt-large'>
<% unless @songs.blank? %>
<%= button_to(
t("label.play_all"),
t("button.play_all"),
current_playlist_playlist_path(@playlist),
method: :put,
class: "c-button c-button--primary",
Expand All @@ -38,9 +38,9 @@
</summary>
<div class='c-dropdown__menu c-dropdown__menu--right' data-dropdown-target="menu">
<% unless @songs.blank? %>
<%= button_to t("label.clear"), playlist_songs_path(@playlist), method: :delete, form_class: "c-dropdown__item" %>
<%= button_to t("button.clear"), playlist_songs_path(@playlist), method: :delete, form_class: "c-dropdown__item" %>
<% end %>
<%= button_to t("label.delete"), playlist_path(@playlist), method: :delete, form_class: "c-dropdown__item" %>
<%= button_to t("button.delete"), playlist_path(@playlist), method: :delete, form_class: "c-dropdown__item" %>
</div>
</details>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/albums/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1><%= t("text.search_results", query: params[:query]) %></h1>
<h1><%= t("label.search_results_for", query: params[:query]) %></h1>
<h2><%= t("label.albums") %></h2>
<div class='o-grid o-grid--shelf u-mb-large'>
<%= render partial: "albums/album", collection: @albums %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/artists/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1><%= t("text.search_results", query: params[:query]) %></h1>
<h1><%= t("label.search_results_for", query: params[:query]) %></h1>
<h2><%= t("label.artists") %></h2>
<div class='o-grid o-grid--shelf u-mb-large'>
<%= render partial: "artists/artist", collection: @artists %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/search/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% page_title_tag t("label.search_results") %>

<% if [@albums, @artists, @songs, @playlists].any?(&:present?) %>
<h1><%= t("text.search_results", query: params[:query]) %></h1>
<h1><%= t("label.search_results_for", query: params[:query]) %></h1>

<% if @albums.present? %>
<div class='o-flex o-flex--justify-between o-flex--align-center u-mb-medium'>
Expand Down Expand Up @@ -53,5 +53,5 @@
<%= render partial: "search/songs/table", locals: {songs: @songs} %>
<% end %>
<% else %>
<h1><%= t("text.no_search_results", query: params[:query]) %></h1>
<h1><%= t("label.no_search_results", query: params[:query]) %></h1>
<% end %>
2 changes: 1 addition & 1 deletion app/views/search/playlists/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1><%= t("text.search_results", query: params[:query]) %></h1>
<h1><%= t("label.search_results_for", query: params[:query]) %></h1>
<h2><%= t("label.playlists") %></h2>

<div class='o-grid o-grid--list'>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/songs/_table.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div role='table' class='c-table' data-controller='playlist-songs playlist-songs-bridge' cols-at-medium='3' cols-at-small='2'>
<div role='rowgroup'>
<div role='row'>
<div role='columnheader'><%= t("label.name") %></div>
<div role='columnheader'><%= t("field.name") %></div>
<div role='columnheader' class='u-display-none@medium'><%= t("label.artist") %></div>
<div role='columnheader' class='u-display-none@medium'><%= t("label.album") %></div>
<div role='columnheader' class='u-display-none@small'><%= t("label.duration") %></div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/songs/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<h1><%= t("text.search_results", query: params[:query]) %></h1>
<h1><%= t("label.search_results_for", query: params[:query]) %></h1>
<h2><%= t("label.songs") %></h2>
<%= render partial: "search/songs/table", locals: {songs: @songs} %>
Loading

0 comments on commit 658ee33

Please sign in to comment.