Skip to content

Commit

Permalink
Add missing translation keys (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickskyline committed Mar 21, 2024
1 parent f8a4a74 commit 5296c9f
Show file tree
Hide file tree
Showing 49 changed files with 450 additions and 249 deletions.
24 changes: 12 additions & 12 deletions app/controllers/cars_controller.rb
Expand Up @@ -114,7 +114,7 @@ def create

respond_to do |format|
if @car.save!
format.html { redirect_to car_url(@car), :notice => 'Car was successfully created.' }
format.html { redirect_to car_url(@car), :notice => t("rva.cars.controller.create") }
format.json { render :show, :status => :created, :location => @car, :layout => false }

Rails.cache.delete(category_cache_key(params[:category]))
Expand All @@ -129,7 +129,7 @@ def create
def update
respond_to do |format|
if @car.update(car_params)
format.html { redirect_to car_url(@car), :notice => 'Car was successfully updated.' }
format.html { redirect_to car_url(@car), :notice => t("rva.cars.controller.update") }
format.json { render :show, :status => :ok, :location => @car, :layout => false }
else
format.html { render :edit, :status => :unprocessable_entity }
Expand All @@ -144,43 +144,43 @@ def import
file = params[:file]
if file.nil?
respond_to do |format|
format.html { redirect_to new_car_path, :notice => 'You must select a CSV file.' }
format.json { render :json => 'You must select a CSV file.', :status => :bad_request, :layout => false }
format.html { redirect_to new_car_path, :notice => t("misc.controller.import.select") }
format.json { render :json => t("misc.controller.import.select"), :status => :bad_request, :layout => false }
end and return
end

unless SYS::CSV_TYPES.include?(file.content_type)
respond_to do |format|
format.html { redirect_to new_car_path, :notice => 'You may only upload CSV files.' }
format.json { render :json => 'You may only upload CSV files.', :status => :bad_request, :layout => false }
format.html { redirect_to new_car_path, :notice => t("misc.controller.import.upload") }
format.json { render :json => t("misc.controller.import.upload"), :status => :bad_request, :layout => false }
end and return
end

if params[:season].nil? || params[:season].empty?
respond_to do |format|
format.html { redirect_to new_car_path, :notice => 'You must select a Season.' }
format.html { redirect_to new_car_path, :notice => t("misc.controller.import.season") }
format.json { render :json => 'You must select a Season.', :status => :bad_request, :layout => false }
end and return
end

if params[:category].nil? || params[:category].empty?
respond_to do |format|
format.html { redirect_to new_car_path, :notice => 'You must select a Category.' }
format.json { render :json => 'You must select a car Category.', :status => :bad_request, :layout => false }
format.html { redirect_to new_car_path, :notice => t("misc.controller.import.category") }
format.json { render :json => t("misc.controller.import.category"), :status => :bad_request, :layout => false }
end and return
end

@cars = CsvImportCarsService.new(file, params[:season], params[:category]).call

respond_to do |format|
if @cars.empty?
format.html { redirect_to new_car_path, :notice => 'No cars were created. Maybe they already exist?' }
format.html { redirect_to new_car_path, :notice => t("rva.cars.controller.import.exists") }
format.json { render :show, :status => :ok, :layout => false }
end and return

@cars.each do |car|
if car.save!
format.html { redirect_to new_car_path, :notice => 'Cars successfully imported.' }
format.html { redirect_to new_car_path, :notice => t("rva.cars.controller.import.success") }
format.json { render :show, :status => :created, :location => car, :layout => false }

Rails.cache.delete(category_cache_key(params[:category].to_i))
Expand All @@ -197,7 +197,7 @@ def destroy
@car.destroy

respond_to do |format|
format.html { redirect_to cars_url, :notice => 'Car was successfully destroyed.' }
format.html { redirect_to cars_url, :notice => t("rva.cars.controller.destroy") }
format.json { head :no_content }
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/rankings_controller.rb
Expand Up @@ -43,7 +43,7 @@ def create

respond_to do |format|
if @ranking.save
format.html { redirect_to ranking_url(@ranking), :notice => 'Ranking was successfully created.' }
format.html { redirect_to ranking_url(@ranking), :notice => t(".controller.create") }
format.json { render :show, :status => :created, :location => @ranking, :layout => false }
else
format.html { render :new, :status => :unprocessable_entity }
Expand All @@ -56,7 +56,7 @@ def create
def update
respond_to do |format|
if @ranking.update(ranking_params)
format.html { redirect_to ranking_url(@ranking), :notice => 'Ranking was successfully updated.' }
format.html { redirect_to ranking_url(@ranking), :notice => t(".controller.update") }
format.json { render :show, :status => :ok, :location => @ranking }
else
format.html { render :edit, :status => :unprocessable_entity }
Expand All @@ -69,7 +69,7 @@ def update
def destroy
respond_to do |format|
if @ranking.destroy!
format.html { redirect_to rankings_url, :notice => 'Ranking was successfully deleted.' }
format.html { redirect_to rankings_url, :notice => t(".controller.delete") }
format.json { head :no_content }
else
format.html { render :edit, :status => :unprocessable_entity }
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/repositories_controller.rb
Expand Up @@ -45,7 +45,7 @@ def create

respond_to do |format|
if @repository.save
format.html { redirect_to repository_url(@repository), :notice => 'Repository was successfully created.' }
format.html { redirect_to repository_url(@repository), :notice => t(".controller.create") }
format.json { render :show, :status => :created, :location => @repository }
else
format.html { render :new, :status => :unprocessable_entity }
Expand All @@ -58,7 +58,7 @@ def create
def update
respond_to do |format|
if @repository.update(repository_params)
format.html { redirect_to repository_url(@repository), :notice => 'Repository was successfully updated.' }
format.html { redirect_to repository_url(@repository), :notice => t(".controller.update") }
format.json { render :show, :status => :ok, :location => @repository }
else
format.html { render :edit, :status => :unprocessable_entity }
Expand All @@ -72,7 +72,7 @@ def destroy
@repository.destroy!

respond_to do |format|
format.html { redirect_to repositories_url, :notice => 'Repository was successfully destroyed.' }
format.html { redirect_to repositories_url, :notice => t(".controller.destroy") }
format.json { head :no_content }
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/seasons_controller.rb
Expand Up @@ -45,7 +45,7 @@ def create
@season.rankings << Ranking.new({ :number => n + 1, :season => @season })
end

format.html { redirect_to season_url(@season), :notice => 'Season was successfully created.' }
format.html { redirect_to season_url(@season), :notice => t(".controller.create") }
format.json { render :show, :status => :created, :location => @season, :layout => false }

Rails.cache.delete('current_season')
Expand All @@ -60,7 +60,7 @@ def create
def update
respond_to do |format|
if @season.update(season_params)
format.html { redirect_to season_url(@season), :notice => 'Season was successfully updated.' }
format.html { redirect_to season_url(@season), :notice => t(".controller.update") }
format.json { render :show, :status => :ok, :location => @season, :layout => false }
else
format.html { render :edit, :status => :unprocessable_entity }
Expand Down Expand Up @@ -99,7 +99,7 @@ def destroy

respond_to do |format|
if @season.destroy!
format.html { redirect_to seasons_url, :notice => 'Season was successfully deleted.' }
format.html { redirect_to seasons_url, :notice => t(".controller.destroy") }
format.json { head :no_content }
else
format.html { render :edit, :status => :unprocessable_entity }
Expand Down
16 changes: 8 additions & 8 deletions app/controllers/sessions_controller.rb
Expand Up @@ -43,7 +43,7 @@ def create

respond_to do |format|
if @session.save
format.html { redirect_to session_url(@session), :notice => 'Session was successfully created.' }
format.html { redirect_to session_url(@session), :notice => t("rankings.sessions.controller.create") }
format.json { render :show, :status => :created, :location => @session, :layout => false }
else
format.html { render :new, :status => :unprocessable_entity }
Expand All @@ -56,7 +56,7 @@ def create
def update
respond_to do |format|
if @session.update(session_params)
format.html { redirect_to session_url(@session), :notice => 'Session was successfully updated.' }
format.html { redirect_to session_url(@session), :notice => t("rankings.sessions.controller.update") }
format.json { render :show, :status => :ok, :location => @session, :layout => false }
else
format.html { render :edit, :status => :unprocessable_entity }
Expand All @@ -81,7 +81,7 @@ def destroy

respond_to do |format|
if @session.destroy!
format.html { redirect_to sessions_url, :notice => 'Session was successfully deleted.' }
format.html { redirect_to sessions_url, :notice => t("rankings.sessions.controller.delete") }
format.json { head :no_content }

Rails.cache.delete("Session:#{@session.id}")
Expand Down Expand Up @@ -109,15 +109,15 @@ def import

if file.nil?
respond_to do |format|
format.html { redirect_to new_session_path, :notice => 'You must select a CSV file.' }
format.json { render :json => 'You must select a CSV file.', :status => :bad_request, :layout => false }
format.html { redirect_to new_session_path, :notice => t("misc.controller.import.select") }
format.json { render :json => t("misc.controller.import.select"), :status => :bad_request, :layout => false }
end and return
end

unless SYS::CSV_TYPES.include?(file.content_type)
respond_to do |format|
format.html { redirect_to new_session_path, :note => 'You may only upload CSV files.' }
format.json { render :json => 'You may only upload CSV files.', :status => :bad_request, :layout => false }
format.html { redirect_to new_session_path, :note => t("misc.controller.import.upload") }
format.json { render :json => t("misc.controller.import.upload"), :status => :bad_request, :layout => false }
end and return
end

Expand All @@ -126,7 +126,7 @@ def import

respond_to do |format|
if @session.save!
format.html { redirect_to session_url(@session), :notice => 'Session was successfully imported.' }
format.html { redirect_to session_url(@session), :notice => t("rankings.sessions.controller.import.success") }
format.json { render :show, :status => :created, :location => @session, :layout => false }

Rails.cache.delete('recent_sessions')
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/stats_controller.rb
Expand Up @@ -10,12 +10,12 @@ def index

@count = ((@users.current_page - 1) * @users.limit_value) + 1
@sorts = {
:race_wins => 'Wins',
:race_podiums => 'Podiums',
:race_win_rate => 'Win Ratio',
# average_position: 'Average Position',
:obtained_points => 'Obtained Points',
:official_score => 'Official Score'
:race_wins => I18n.t("rankings.stats.table.wins"),
:race_podiums => I18n.t("rankings.stats.table.podiums"),
:race_win_rate => I18n.t("rankings.stats.table.win-ratio"),
# average_position: I18n.t("rankings.stats.table.average-pos"),
:obtained_points => I18n.t("rankings.stats.table.obtained-points"),
:official_score => I18n.t("rankings.stats.table.official-score")
}
end
end
8 changes: 4 additions & 4 deletions app/controllers/teams_controller.rb
Expand Up @@ -37,7 +37,7 @@ def create

respond_to do |format|
if @team.save
format.html { redirect_to teams_path, :notice => 'Team was successfully created.' }
format.html { redirect_to teams_path, :notice => t(".controller.create") }
format.json { render :show, :status => :created, :location => @team, :layout => false }
else
format.html { render :new, :status => :unprocessable_entity }
Expand All @@ -50,7 +50,7 @@ def create
def update
respond_to do |format|
if @team.update(team_params)
format.html { redirect_to team_path(@team), :notice => 'Team was successfully updated.' }
format.html { redirect_to team_path(@team), :notice => t(".controller.update") }
format.json { render :show, :status => :ok, :location => @team, :layout => false }
else
format.html { render :edit, :status => :unprocessable_entity }
Expand All @@ -65,7 +65,7 @@ def add_member

respond_to do |format|
if @team.update!
format.html { redirect_to team_path(@team), :notice => "#{new_member.username} was successfully added to #{@team.name}" }
format.html { redirect_to team_path(@team), :notice => t(".controller.add-member", :member => new_member.username, :team => @team.name) }
else
format.html { redirect_to team_path(@team), :status => :unprocessable_entity }
end
Expand All @@ -90,7 +90,7 @@ def destroy
@team.destroy

respond_to do |format|
format.html { redirect_to teams_url, :notice => 'Team was successfully destroyed.' }
format.html { redirect_to teams_url, :notice => t(".controller.destroy") }
format.json { head :no_content }
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/tournaments_controller.rb
Expand Up @@ -35,7 +35,7 @@ def create

respond_to do |format|
if @tournament.save
format.html { redirect_to tournament_url(@tournament), :notice => 'Tournament was successfully created.' }
format.html { redirect_to tournament_url(@tournament), :notice => t(".controller.create") }
format.json { render :show, :status => :created, :location => @tournament, :layout => false }
else
format.html { render :new, :status => :unprocessable_entity }
Expand All @@ -48,7 +48,7 @@ def create
def update
respond_to do |format|
if @tournament.update(tournament_params)
format.html { redirect_to tournament_url(@tournament), :notice => 'Tournament was successfully updated.' }
format.html { redirect_to tournament_url(@tournament), :notice => t(".controller.update") }
format.json { render :show, :status => :ok, :location => @tournament, :layout => false }
else
format.html { render :edit, :status => :unprocessable_entity }
Expand All @@ -62,7 +62,7 @@ def destroy
@tournament.destroy

respond_to do |format|
format.html { redirect_to tournaments_url, :notice => 'Tournament was successfully destroyed.' }
format.html { redirect_to tournaments_url, :notice => t(".controller.destroy") }
format.json { head :no_content }
end
end
Expand Down
22 changes: 11 additions & 11 deletions app/controllers/tracks_controller.rb
Expand Up @@ -41,7 +41,7 @@ def create

respond_to do |format|
if @track.save
format.html { redirect_to track_url(@track), :notice => 'Track was successfully created.' }
format.html { redirect_to track_url(@track), :notice => t("rva.tracks.controller.create") }
format.json { render :show, :status => :created, :location => @track, :layout => false }
else
format.html { render :new, :status => :unprocessable_entity }
Expand All @@ -54,7 +54,7 @@ def create
def update
respond_to do |format|
if @track.update(track_params)
format.html { redirect_to track_url(@track), :notice => 'Track was successfully updated.' }
format.html { redirect_to track_url(@track), :notice => t("rva.tracks.controller.update") }
format.json { render :show, :status => :ok, :location => @track, :layout => false }
else
format.html { render :edit, :status => :unprocessable_entity }
Expand All @@ -69,36 +69,36 @@ def import
file = params[:file]
if file.nil?
respond_to do |format|
format.html { redirect_to new_track_path, :notice => 'You must select a CSV file.' }
format.json { render :json => 'You must select a CSV file.', :status => :bad_request, :layout => false }
format.html { redirect_to new_track_path, :notice => t("misc.controller.import.select") }
format.json { render :json => t("misc.controller.import.select"), :status => :bad_request, :layout => false }
end and return
end

unless SYS::CSV_TYPES.include?(file.content_type)
respond_to do |format|
format.html { redirect_to new_track_path, :notice => 'You may only upload CSV files.' }
format.json { render :json => 'You may only upload CSV files.', :status => :bad_request, :layout => false }
format.html { redirect_to new_track_path, :notice => t("misc.controller.import.upload") }
format.json { render :json => t("misc.controller.import.upload"), :status => :bad_request, :layout => false }
end and return
end

if params[:season].nil? || params[:season].empty?
respond_to do |format|
format.html { redirect_to new_track_path, :notice => 'You must select a Season.' }
format.json { render :json => 'You must select a Season.', :status => :bad_request, :layout => false }
format.html { redirect_to new_track_path, :notice => t("misc.controller.import.season") }
format.json { render :json => t("misc.controller.import.season"), :status => :bad_request, :layout => false }
end and return
end

@tracks = CsvImportTracksService.new(file, params[:season]).call

respond_to do |format|
if @tracks.empty?
format.html { redirect_to new_track_path, :notice => 'No tracks were created. Maybe they already exist?' }
format.html { redirect_to new_track_path, :notice => t("rva.tracks.controller.import.exists") }
format.json { render :show, :status => :ok, :layout => false }
end and return

@tracks.each do |track|
if track.save!
format.html { redirect_to new_track_path, :notice => 'Tracks successfully imported.' }
format.html { redirect_to new_track_path, :notice => t("rva.tracks.controller.import.success") }
format.json { render :show, :status => :created, :location => track, :layout => false }
else
format.html { render :new, :status => :unprocessable_entity }
Expand All @@ -113,7 +113,7 @@ def destroy
@track.destroy

respond_to do |format|
format.html { redirect_to tracks_url, :notice => 'Track was successfully destroyed.' }
format.html { redirect_to tracks_url, :notice => t("rva.tracks.controller.destroy") }
format.json { head :no_content }
end
end
Expand Down

0 comments on commit 5296c9f

Please sign in to comment.