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

[i18n] Internationalization for ruby site #1361

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gem 'google_drive'
gem 'groupdate'
gem 'honeybadger', '~> 5.2.0'
gem 'html-pipeline', '~> 2.14.3'
gem 'i18n'
gem 'commonmarker', '~> 0.23.10'
gem 'net-sftp', '~> 4.0'
gem 'octicons_helper'
Expand All @@ -19,6 +20,7 @@ gem 'pdf-reader', '~> 2.11.0'
gem 'pg', '~> 1.4.6'
gem 'pagy'
gem 'rails', '7.1.3.4'
gem 'rails-i18n'
gem "importmap-rails"
gem "turbo-rails"
gem "stimulus-rails"
Expand Down Expand Up @@ -64,4 +66,5 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-commands-rspec', group: :development
gem 'i18n-tasks', '~> 1.0', require: false
end
25 changes: 25 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ GEM
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
afm (0.2.2)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.8)
bindex (0.8.1)
Expand Down Expand Up @@ -186,13 +187,24 @@ GEM
hashdiff (1.1.0)
hashery (2.1.2)
hashie (5.0.0)
highline (3.0.1)
honeybadger (5.2.1)
html-pipeline (2.14.3)
activesupport (>= 2)
nokogiri (>= 1.4)
httpclient (2.8.3)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
i18n-tasks (1.0.14)
activesupport (>= 4.0.2)
ast (>= 2.1.0)
erubi
highline (>= 2.0.0)
i18n
parser (>= 3.2.2.1)
rails-i18n
rainbow (>= 2.2.2, < 4.0)
terminal-table (>= 1.5.1)
importmap-rails (2.0.1)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
Expand Down Expand Up @@ -287,6 +299,9 @@ GEM
openssl (3.2.0)
os (1.1.4)
pagy (9.0.2)
parser (3.3.4.0)
ast (~> 2.4.1)
racc
pdf-reader (2.11.0)
Ascii85 (~> 1.0)
afm (~> 0.2.1)
Expand Down Expand Up @@ -338,6 +353,9 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails-i18n (7.0.9)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)
railties (7.1.3.4)
actionpack (= 7.1.3.4)
activesupport (= 7.1.3.4)
Expand All @@ -346,6 +364,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rdoc (6.7.0)
psych (>= 4.0.0)
Expand Down Expand Up @@ -432,6 +451,8 @@ GEM
railties (>= 6.0.0)
stringio (3.1.1)
strscan (3.1.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.3.1)
tilt (2.4.0)
timeout (0.4.1)
Expand All @@ -447,6 +468,7 @@ GEM
uber (0.1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.5.0)
vcr (6.2.0)
version_gem (1.1.4)
web-console (4.2.1)
Expand Down Expand Up @@ -486,6 +508,8 @@ DEPENDENCIES
groupdate
honeybadger (~> 5.2.0)
html-pipeline (~> 2.14.3)
i18n
i18n-tasks (~> 1.0)
importmap-rails
issue
jbuilder (~> 2.11)
Expand All @@ -501,6 +525,7 @@ DEPENDENCIES
pry-byebug
puma
rails (= 7.1.3.4)
rails-i18n
redis (~> 5.0)
responders
rspec-rails (~> 6.1.0)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/papers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def show
flash[:notice] = "You need to log in before viewing this paper."
redirect_to root_path and return
end

# Redirect to root if not an admin or the submitting author
# With notice that the paper is not visible
unless can_see_hidden_paper?(@paper)
Expand Down Expand Up @@ -315,7 +315,7 @@ def status
if @paper
svg = @paper.status_badge
else
prefix = setting(:abbreviation)
prefix = I18n.t('journal.abbreviation')

svg = "<svg xmlns='http://www.w3.org/2000/svg' width='102' height='20'><linearGradient id='b' x2='0' y2='100%'><stop offset='0' stop-color='#bbb' stop-opacity='.1'/><stop offset='1' stop-opacity='.1'/></linearGradient><mask id='a'><rect width='102' height='20' rx='3' fill='#fff'/></mask><g mask='url(#a)'><path fill='#555' d='M0 0h40v20H0z'/><path fill='#9f9f9f' d='M40 0h62v20H40z'/><path fill='url(#b)' d='M0 0h102v20H0z'/></g><g fill='#fff' text-anchor='middle' font-family='DejaVu Sans,Verdana,Geneva,sans-serif' font-size='11'><text x='20' y='15' fill='#010101' fill-opacity='.3'>#{prefix}</text><text x='20' y='14'>#{prefix}</text><text x='70' y='15' fill='#010101' fill-opacity='.3'>Unknown</text><text x='70' y='14'>Unknown</text></g></svg>"
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def link_to_query(body, url, query)
end

def name_and_tagline
"#{setting(:name)} (#{setting(:abbreviation)}) is #{setting(:tagline)}".html_safe
"#{I18n.t :'journal.name'} (#{I18n.t :'journal.abbreviation'}) #{I18n.t :'journal.tagline'}".html_safe
end

def avatar(username)
Expand All @@ -57,7 +57,7 @@ def paper_track_label(github_issue)
def scope_link_for_issue(github_issue)
id = github_issue.number
paper = Paper.where('review_issue_id = ? OR meta_review_issue_id = ?', id, id).first

return "" unless paper
return url_for(paper)
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/paper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def journal_id
return retracted_paper.journal_id + "R"
else
id = "%05d" % review_issue_id
return "#{setting(:abbreviation).downcase}.#{id}"
return "#{I18n.t('journal.abbreviation').downcase}.#{id}"
end
end

Expand Down Expand Up @@ -481,7 +481,7 @@ def cross_ref_doi_url
end

def status_badge
prefix = setting(:abbreviation)
prefix = I18n.t('journal.abbreviation')

case self.state.to_s
when "submitted"
Expand Down
10 changes: 5 additions & 5 deletions app/views/home/_menu.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<div class="container">
<div class="btn-group" role="group" aria-label="Paper Status">
<%= link_to "/dashboard/#{current_user.editor.login}", class: current_class?("/dashboard/#{current_user.editor.login}") do %>
Your papers
<%= t('menu.your_papers') %>
<div class="count-badge"><%= raw current_user.editor.papers.in_progress.count %></div>
<% end %>
<%= link_to dashboard_incoming_path(track_id: @track), class: current_class?(dashboard_incoming_path) do %>
Papers with no editor
<%= t('menu.papers_with_no_editor') %>
<div class="count-badge"><%= raw Paper.unscoped.in_progress.where(editor: nil).count %></div>
<% end %>
<%= link_to dashboard_in_progress_path(track_id: @track), class: current_class?(dashboard_in_progress_path) do %>
In progress papers
<%= t('menu.in_progress_papers') %>
<div class="count-badge"><%= raw Paper.unscoped.in_progress.count %></div>
<% end %>
<%= link_to dashboard_query_scoped_path(track_id: @track), class: current_class?(dashboard_query_scoped_path) do %>
👍👎
<% end %>
<%= link_to dashboard_all_path(track_id: @track), class: current_class?(dashboard_all_path) do %>
All papers
<%= t('menu.all_papers') %>
<div class="count-badge"><%= raw Paper.unscoped.all.count %></div>
<% end %>
<%= link_to "/dashboard", class: current_class?("/dashboard") do %>
<%= Rails.application.settings['abbreviation'] %> Statistics
<%= t('journal.abbreviation') %> <%= t('base.statistics') %>
<% end %>
</div>

Expand Down
Loading
Loading