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

[Bug]: Fix "ImpliedQuantity" lint warning in pt-rBR strings. #5231

Closed
Tracked by #5169
adhiamboperes opened this issue Nov 16, 2023 · 11 comments · Fixed by #5259
Closed
Tracked by #5169

[Bug]: Fix "ImpliedQuantity" lint warning in pt-rBR strings. #5231

adhiamboperes opened this issue Nov 16, 2023 · 11 comments · Fixed by #5259
Assignees
Labels
bug End user-perceivable behaviors which are not desirable. good first issue This item is good for new contributors to make their pull request. Impact: Low Low perceived user impact (e.g. edge cases). Work: Low Solution is clear and broken into good-first-issue-sized chunks.

Comments

@adhiamboperes
Copy link
Collaborator

adhiamboperes commented Nov 16, 2023

Steps To Reproduce

Run the following command from a terminal in a checked-out Oppia Android repo:

./gradlew :app:lint

Expected Behavior

Running the command above should not show any ImpliedQuantity. warnings.

@adhiamboperes
Copy link
Collaborator Author

@deonwaju contrary to the suggestion in #5169 (comment):

  • the "one" quantity plural should not take a variable, because it is always just one.
  • we use string templates %s, usually not %d

An approach that might be worth testing based on my examination of the ptBr strings file, is fixing the formatting in the plurals by removing the newlines(\n). Please see #5164 for expected correct string formats for quantity and plurals. Might be worth checking other langauge string files for similar formatting errors.

@adhiamboperes adhiamboperes added good first issue This item is good for new contributors to make their pull request. Impact: Low Low perceived user impact (e.g. edge cases). bug End user-perceivable behaviors which are not desirable. Work: Low Solution is clear and broken into good-first-issue-sized chunks. labels Nov 16, 2023
@deonwaju
Copy link
Collaborator

Hi @adhiamboperes, This issue seems to persist, i have tried the above methods and checked on comment #5164, also tried a few ways. The issue lies "The warning you're seeing is related to internationalization and localization (i18n/l10n) of your application, specifically dealing with pluralization in different languages.". The only solution that seemed to <item quantity="one">%d Capítulo\n</item> as earlier stated.

@adhiamboperes
Copy link
Collaborator Author

Hi @deonwaju, can you confirm that this plural is formatted in the same way in all translations?

@deonwaju
Copy link
Collaborator

deonwaju commented Nov 21, 2023

No it wasn't at first, It was like below:

Screenshot 2023-11-21 at 23 52 46

Then, I formatted it the same way like below, but still same error:

Screenshot 2023-11-21 at 23 52 28

@adhiamboperes
Copy link
Collaborator Author

Based on https://googlesamples.github.io/android-custom-lint-rules/checks/ImpliedQuantity.md.html and the lint report, it seems that adding the string template as you are suggesting should be fine. But use %s not %d, since we are passing a string value.

My concern is, how will we pass the value "1" in the code where the plural is used, if the default English translation is not in the same format? (You can change the locale on your device and test this out). Are you going to change the string in english too?

Additionally, are you going to modify the other plurals in the file too?

Lastly, I would still prefer the plurals formatting fixed in general, per my earlier comment.

@deonwaju
Copy link
Collaborator

deonwaju commented Nov 22, 2023

@adhiamboperes Your concerns are valid, But I didnt make the changes in the other languages, I cant change my the locale on my phone for some reason, Also for concerns in passing the value "1" in the code where the plural is used. I dont know if the below function does that automatically. Finally, I am leaning towards leaving this issue and picking up another issue and leaving this issue till a proper solution with fewer unknowns arrives.
Screenshot 2023-11-22 at 18 59 38

@deonwaju
Copy link
Collaborator

Hello @adhiamboperes

@adhiamboperes
Copy link
Collaborator Author

@deonwaju, feel free to work on something else

@adhiamboperes
Copy link
Collaborator Author

Hi @deonwaju, I looked into this some more, and per https://developer.android.com/guide/topics/resources/string-resource#Plurals, we can fix this by changing the plural strings for one in pt-rBR to include a %d as discussed. No aditional change would be required where the string is called. It should be easy to verify this by changing your phone language to spanish and confirming that it displays correctly in the app.
The solution will be complete if you also fix the newline formatting of the plurals in thaat file.

@adhiamboperes adhiamboperes changed the title ImpliedQuantity [Bug]: Fix "ImpliedQuantity" lint warning in pt-rBR strings. Dec 4, 2023
@deonwaju
Copy link
Collaborator

deonwaju commented Dec 4, 2023

The solution will be complete if you also fix the newline formatting of the plurals in thaat file.

Hello @adhiamboperes, I understand the rest, but could you please explain this? Do you mean removing the \n right?

@adhiamboperes
Copy link
Collaborator Author

Hello @adhiamboperes, I understand the rest, but could you please explain this? Do you mean removing the \n right?

Yes, that is correct.

adhiamboperes pushed a commit that referenced this issue Dec 5, 2023
<!-- READ ME FIRST: Please fill in the explanation section below and
check off every point from the Essential Checklist! -->
## Explanation
<!--
- Explain what your PR does. If this PR fixes an existing bug, please
include
- "Fixes #bugnum:" in the explanation so that GitHub can auto-close the
issue
  - when this PR is merged.
  -->
Fix #5231 

1. Replaced quantity "one" with %s at warnings of implied quantity in
pt-rBR strings.
2. Removed new line formats.

<img width="1085" alt="Screenshot 2023-12-04 at 21 22 46"
src="https://github.com/oppia/oppia-android/assets/54560535/852c14eb-c523-4515-b152-32ea6adc9615">

Before 
![Screenshot 2023-12-04 at 20 50
19](https://github.com/oppia/oppia-android/assets/54560535/a6118bc9-6592-49b8-a17a-e9d0995edda2)

After
![Screenshot 2023-12-04 at 20 50
29](https://github.com/oppia/oppia-android/assets/54560535/aefeba2d-9b13-4db2-9a2a-8dd665f8e476)


## Essential Checklist
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

## For UI-specific PRs only
<!-- Delete these section if this PR does not include UI-related
changes. -->
If your PR includes UI-related changes, then:
- Add screenshots for portrait/landscape for both a tablet & phone of
the before & after UI changes
- For the screenshots above, include both English and pseudo-localized
(RTL) screenshots (see [RTL
guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines))
- Add a video showing the full UX flow with a screen reader enabled (see
[accessibility
guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide))
- For PRs introducing new UI elements or color changes, both light and
dark mode screenshots must be included
- Add a screenshot demonstrating that you ran affected Espresso tests
locally & that they're passing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug End user-perceivable behaviors which are not desirable. good first issue This item is good for new contributors to make their pull request. Impact: Low Low perceived user impact (e.g. edge cases). Work: Low Solution is clear and broken into good-first-issue-sized chunks.
Development

Successfully merging a pull request may close this issue.

2 participants