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

Fix pluralization logic IV #6827

Closed
8 tasks
sashadev-sky opened this issue Nov 21, 2019 · 2 comments · Fixed by #6972
Closed
8 tasks

Fix pluralization logic IV #6827

sashadev-sky opened this issue Nov 21, 2019 · 2 comments · Fixed by #6972

Comments

@sashadev-sky
Copy link
Member

Please note we are preparing to participate in Google Code-in, and have reserved this issue for GCI participants - but we'd love to have your help with another one! Please check out https://code.publiclab.org to see more.

The problem

On the /notes/author/admin page, the pluralization for research notes is incorrect:

Screen Shot 2019-11-20 at 11 34 09 PM

Solution

When plugging in values that are subject to change, we need to make sure the text it'll generate is appropriate for both the singular and plural case.

-- lets find the relevant line of code first:

the text is generated here:

<h3><%= raw t('notes.index.research_by', :url1 => "/people/"+@user.name, :user_name => @user.name) %> <small><%= raw t('notes.index.research_notes_and_wiki_edits', :count1 => @user.note_count, :count2 => @user.revisions.count) %> <% if @user.notes.length > 0 %><%= raw t('notes.index.starting_time', :time => time_ago_in_words(@user.created_at)) %><% end %></small></h3>

with additional help from here:

research_notes_and_wiki_edits: "%{count1} research notes and %{count2} wiki
edits"

There are many ways to fix this

  • I like this solution - "you can make use of the pluralization features of the I18n library by defining count values to translation keys". http://stackoverflow.com/questions/25064677/ddg#25065514
  • But do it however! Just make sure your solution is DRY, as in sticks to using the locale helpers if this variable is used frequently throughout the repo, or a rails/ruby/etc. method that helps to handle this logic. No if count == 1 ... else .... here please as we have both "note(s)" and "edit(s)" to consider.

Requirements:

  • DRY
  • accounts for both "note(s)" and "edit(s)"

Thanks!!

Step by Step

  • Claim this issue with a comment here, below, and ask any clarifying questions you need
  • Fork the repository and set it up locally following the main repo README instructions https://github.com/publiclab/plots2
  • Create a new feature branch with a unique name descriptive to the issue
  • Try to fix the issue following the steps above, but even before you're done, you can:
    commit your changes to your branch and start a pull request (see contributing to Public Lab software) but mark it as "in progress" if you have questions or if you haven't finished
  • Reference this issue in your pull request body
  • Once you submit your pull request, an additional checklist will be provided for getting it merged

💬 Get help

If you need any help - here are some options:

@sashadev-sky
Copy link
Member Author

Uploaded to GCI Dashboard

@SidharthBansal
Copy link
Member

PUBLISHED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants