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

Verify Translation in Development #9878

Merged
merged 7 commits into from
Jul 20, 2021
Merged
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
7 changes: 7 additions & 0 deletions app/controllers/user_tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def create
else
@output[:errors] << I18n.t('user_tags_controller.value_cannot_be_empty')
end
if params[:translationswitch]
redirect_to URI.parse('/change_locale/zh-CN').path and return
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use && instead of and.

end
else
@output[:errors] << I18n.t('user_tags_controller.admin_user_manage_tags')
end
Expand Down Expand Up @@ -105,6 +108,10 @@ def delete
output[:errors] = I18n.t('user_tags_controller.tag_doesnt_exist')
end

if params[:translationswitch]
redirect_to URI.parse('/change_locale/en').path and return
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use && instead of and.

end

output[:tid] = @user_tag&.id
if request.xhr?
render json: output
Expand Down
16 changes: 16 additions & 0 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@
<a class="dropdown-item" href="/features">Features</a>
<div class="dropdown-divider"></div>
<% end %>

<% if Rails.env==="development" %>
<% if current_user %>
<% if current_user&.has_tag('translation-helper') %>
<a rel="tooltip" class="dropdown-item" data-placement="bottom" data-method="delete" href="/profile/tags/delete/<%= current_user.id %>?name=translation-helper&translationswitch=yes">
Switch off Translation
</a>
<% else %>
<a rel="tooltip" class="dropdown-item" data-placement="bottom" data-method="post" href="/profile/tags/create/<%= current_user.id %>?translationswitch=yes&name=translation-helper">
Switch on Translation
</a>
<% end %>
<div class="dropdown-divider"></div>
<% end %>
<% end %>

<% if current_user&.has_tag('translation-helper') && I18n.locale != :en %>
<div class="dropdown-item">
<%= link_to translation('layout._header.logout'), logout_path, class: "text-body" %>
Expand Down
2 changes: 1 addition & 1 deletion test/integration/routes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ def setup
test "test get request for updating a comment" do
assert_routing({ path: '/comment/update/:id', method: 'get' }, {controller: 'comment', action: 'update', id: ':id' })
end

end