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

AO3-6058 Add 'translation into' to download preface #4652

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 10 additions & 1 deletion app/views/downloads/_download_preface.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,24 @@
<% end %>
<% end %>

<%# i18n-tasks-use t("downloads.download_preface.translated_to.restricted_html") %>
<%# i18n-tasks-use t("downloads.download_preface.translated_to.revealed_html") %>
<%# i18n-tasks-use t("downloads.download_preface.translated_to.unrevealed_html") %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason these hints are within the template instead of in the helper where they're used?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had to think about it, but I think the reasoning is that the calls here "cause" the translation key to be used (i.e. without calling the helper here, the translation keys would be unused), and in contrast, the helper just "facilitates" the use

<%# i18n-tasks-use t("downloads.download_preface.inspired_by.restricted_html") %>
<%# i18n-tasks-use t("downloads.download_preface.inspired_by.revealed_html") %>
<%# i18n-tasks-use t("downloads.download_preface.inspired_by.unrevealed") %>
<%# i18n-tasks-use t("downloads.download_preface.translation_of.restricted_html") %>
<%# i18n-tasks-use t("downloads.download_preface.translation_of.revealed_html") %>
<%# i18n-tasks-use t("downloads.download_preface.translation_of.unrevealed") %>
<% translations = @work.approved_related_works.where(translation: true) %>
<% related_works = @work.parent_work_relationships.reject { |wr| !wr.parent } %>
<% if related_works.length > 0 %>
<% if translations.any? || related_works.any? %>
<ul>
<% translations.each do |related_work| %>
<li>
<%= related_work_note(related_work.work, "translated_to", download: true) %>
</li>
<% end %>
<% related_works.each do |work| %>
<li>
<% relation = work.translation ? "translation_of" : "inspired_by" %>
Expand Down
4 changes: 4 additions & 0 deletions config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ en:
restricted_html: Inspired by [Restricted Work] by %{creator_link}
revealed_html: Inspired by %{work_link} by %{creator_link}
unrevealed: Inspired by a work in an unrevealed collection
translated_to:
restricted_html: 'Translation into %{language} available: [Restricted Work] by %{creator_link}'
revealed_html: 'Translation into %{language} available: %{work_link} by %{creator_link}'
unrevealed_html: 'Translation into %{language} available: A work in an unrevealed collection.'
brianjaustin marked this conversation as resolved.
Show resolved Hide resolved
translation_of:
restricted_html: A translation of [Restricted Work] by %{creator_link}
revealed_html: A translation of %{work_link} by %{creator_link}
Expand Down
35 changes: 35 additions & 0 deletions features/works/work_download.feature
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,38 @@ Feature: Download a work
And I view the work "Followup"
And I follow "HTML"
Then I should see "Inspired by [Restricted Work] by inspiration"

Scenario: Downloads of translated work update when translation's revealed status changes.

Given a hidden collection "Hidden"
And I have related works setup
And a translation has been posted and approved
And I log out
When I view the work "Worldbuilding"
And I follow "HTML"
Then I should see "Worldbuilding Translated by translator"
# Going from revealed to unrevealed
When I am logged in as "translator"
And I edit the work "Worldbuilding Translated" to be in the collection "Hidden"
And I log out
And I view the work "Worldbuilding"
And I follow "HTML"
Then I should not see "Worldbuilding Translated by translator"
And I should see "A work in an unrevealed collection"
# Going from unrevealed to revealed
When I reveal works for "Hidden"
And I log out
And I view the work "Worldbuilding"
And I follow "HTML"
Then I should see "Worldbuilding Translated by translator"

Scenario: Downloads hide titles of restricted work translations

Given I have related works setup
And a translation has been posted and approved
And I am logged in as "translator"
And I lock the work "Worldbuilding Translated"
When I am logged out
And I view the work "Worldbuilding"
And I follow "HTML"
Then I should see "[Restricted Work] by translator"
Loading