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

I18nize articles & social_previews #15097

Merged
merged 15 commits into from Oct 27, 2021

Conversation

yheuhtozr
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Extracts strings for i18n from the most of remaining app/views/articles and related templates. Attached fr locales for testing purposes. Existing translations up to #15055 reflected (hopefully).

Related Tickets & Documents

#14888

QA Instructions, Screenshots, Recordings

Please replace this line with instructions on how to test your changes, a note
on the devices and browsers this has been tested on, as well as any relevant
images for UI changes.

UI accessibility concerns?

If your PR includes UI changes, please replace this line with details on how
accessibility is impacted and tested. For more info, check out the
Forem Accessibility Docs.

Added/updated tests?

  • Yes
  • No, and this is why: please replace this line with details on why tests
    have not been included
  • I need help with writing tests

[Forem core team only] How will this change be communicated?

Will this PR introduce a change that impacts Forem members or creators, the
development process, or any of our internal teams? If so, please note how you
will share this change with the people who need to know about it.

  • I've updated the Developer Docs or
    Storybook (for Crayons components)
  • This PR changes the Forem platform and our documentation needs to be
    updated. I have filled out the
    Changes Requested
    issue template so Community Success can help update the Admin Docs
    appropriately.
  • I've updated the README or added inline documentation
  • I've added an entry to
    CHANGELOG.md
  • I will share this change in a Changelog
    or in a forem.dev post
  • I will share this change internally with the appropriate teams
  • I'm not sure how best to communicate this change and need help
  • This change does not need to be communicated, and this is why not: please
    replace this line with details on why this change doesn't need to be
    shared

[optional] Are there any post deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

alt_text

@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Oct 18, 2021
@github-actions
Copy link
Contributor

Thank you for opening this PR! We appreciate you!

For all pull requests coming from third-party forks we will need to
review the PR before we can process it through our CI pipelines.

A Forem Team member will review this contribution and get back to
you as soon as possible!

<span class="series-switcher__num">...</span>
<span class="series-switcher__title"><%= collection_size - 4 %> more <%= "part".pluralize(count: collection_size - 4) %>...</span>
title="<%= t("views.articles.series.inbetween.title") %>">
<span class="series-switcher__num"><%= t("views.articles.series.inbetween.num") %></span>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this key name is intent-revealing but I also can't come up with a better one 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Me neither which is why I took it directly from the style class name above. Any suggestions are welcome.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we can just leave it as is for now.

</a>
<% end %>

<a
href="<%= article.path %>"
class="crayons-link crayons-link--contentful series-switcher__link <%= "series-switcher__link--active" if rendered_article.id == article.id %> <%= "series-switcher__link--hidden" if collection_size > 5 && (i > 1 && i < collection_size - 2) %>"
data-preload-image="<%= cloud_cover_url(article.main_image) %>"
title="Published <%= article.readable_publish_date %>">
title="<%= t("views.articles.series.published", date: article.readable_publish_date) %>">
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should probably change the method in Article:

  def readable_publish_date
    relevant_date = displayable_published_at

    if relevant_date && relevant_date.year == Time.current.year
      I18n.l(relevant_date, :short)
    else
      I18n.l(relevant_date, :short_with_year)
    end
  end

If you don't feel comfortable making this change let me know and I make it myself later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The function as such is independent from views translation used in a lot of places, so I think I'd better defer the implementation details to you.

Copy link
Contributor

Choose a reason for hiding this comment

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

The function as such is independent from views translation

The function does always return the date as a string though. But anyway, this is something I'll look into later.

<span class="series-switcher__num">...</span>
<span class="series-switcher__title"><%= collection_size - 4 %> more <%= "part".pluralize(count: collection_size - 4) %>...</span>
title="<%= t("views.articles.series.inbetween.title") %>">
<span class="series-switcher__num"><%= t("views.articles.series.inbetween.num") %></span>
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we can just leave it as is for now.

</a>
<% end %>

<a
href="<%= article.path %>"
class="crayons-link crayons-link--contentful series-switcher__link <%= "series-switcher__link--active" if rendered_article.id == article.id %> <%= "series-switcher__link--hidden" if collection_size > 5 && (i > 1 && i < collection_size - 2) %>"
data-preload-image="<%= cloud_cover_url(article.main_image) %>"
title="Published <%= article.readable_publish_date %>">
title="<%= t("views.articles.series.published", date: article.readable_publish_date) %>">
Copy link
Contributor

Choose a reason for hiding this comment

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

The function as such is independent from views translation

The function does always return the date as a string though. But anyway, this is something I'll look into later.

@pr-triage pr-triage bot added PR: partially-approved bot applied label for PR's where a single reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Oct 27, 2021
@yheuhtozr yheuhtozr mentioned this pull request Oct 27, 2021
16 tasks
@pr-triage pr-triage bot added PR: unreviewed bot applied label for PR's with no review and removed PR: partially-approved bot applied label for PR's where a single reviewer approves changes labels Oct 27, 2021
@@ -117,32 +119,32 @@
<div class="crayons-story__bottom">
<div class="crayons-story__details">
<% if story.public_reactions_count > 0 %>
<a href="<%= story.path %>" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left" data-reaction-count data-reactable-id="<%= story.id %>" aria-label="Comments for post <%= story.title %> (<%= story.public_reactions_count %>)">
<a href="<%= story.path %>" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left" data-reaction-count data-reactable-id="<%= story.id %>" aria-label="<%= t("views.articles.comments.aria_label", title: story.title, num: story.public_reactions_count) %>">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

From #15059 (comment). BTW I find it a bit weird that the three aria labels here and below share the same message, but I just convert them as they are.

@maestromac maestromac changed the title views/articles (main part) etc i18n I18nize articles & social_previews Oct 27, 2021
Copy link
Member

@maestromac maestromac left a comment

Choose a reason for hiding this comment

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

LGTM despite the tiny thing I pointed out. I'll go ahead and merge it and we can make additional changes in another PR.

<button type="button" id="article-save-button-<%= story.id %>" class="crayons-btn crayons-btn--secondary crayons-btn--s bookmark-button" data-reactable-id="<%= story.id %>" aria-label="Save to reading list" title="Save to reading list">
<span class="bm-initial">Save</span>
<span class="bm-success">Saved</span>
<button type="button" id="article-save-button-<%= story.id %>" class="crayons-btn crayons-btn--secondary crayons-btn--s w-max bookmark-button" data-reactable-id="<%= story.id %>" aria-label="<%= t("views.articles.save.aria_label") %>" title="<%= t("views.articles.save.title") %>">
Copy link
Member

Choose a reason for hiding this comment

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

was the w-max added by accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIRC that class would save the localized string from unexpected line break. Of course there should be other ways though.

@pr-triage pr-triage bot added PR: partially-approved bot applied label for PR's where a single reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Oct 27, 2021
@maestromac maestromac merged commit 7613b6c into forem:main Oct 27, 2021
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: partially-approved bot applied label for PR's where a single reviewer approves changes labels Oct 27, 2021
@pr-triage pr-triage bot added PR: partially-approved bot applied label for PR's where a single reviewer approves changes and removed PR: merged bot applied label for PR's that are merged labels Oct 28, 2021
citizen428 pushed a commit that referenced this pull request Oct 29, 2021
* views/articles (main part) etc i18n

* remove ja.yml

* delete a replaced core entry

* Update en.yml

* Update fr.yml

* Update _liquid.html.erb

* Update _single_story.html.erb

* Update en.yml

* Update fr.yml

* Update _liquid.html.erb

* Update discussion_lock_confirm.html.erb

* Update _widget_list_item.html.erb

* Update _single_story.html.erb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: partially-approved bot applied label for PR's where a single reviewer approves changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants