Skip to content

Conversation

@CAVillalobos
Copy link
Contributor

The language codes for Hebrew, Indonesian and Yiddish were being displayed as the deprecated ISO-639. This issue is being fixed here.

Fix #2880 Description field uses outdated code iw for Hebrew

The description field now shows the updates ISO-639-1 language codes for the three languages mentioned before.

To achieve this a new class StringUtils was created inside utils directory with a method named fixLanguageCode.
This method receives a String and compares it with the three deprecated ISO-639 codes. If there is a match returns the updated code for the one that was received. If not returns the same code.
This class and method include their respective JavaDoc.

In the method init in the file SpinnerLanguagesAdapter was created a new String object called languageCode was created to hold the language code. The fixLanguageCode is called with the language code that was originally intended to be used being sent as parameter and the response is assigned to languageCode and this variable was used instead to display the language code.

As something additional to the original issue, the language names were also being displayed only in lowercase in other languages different to English (noticed with Spanish). This was fixed too by creating a String object called languageName that receives the capitalized name of the language and using this variable for the display similar to languageCode.

Tests performed

Tested betaDebug and betRelease on Moto G6 with API level 26.

4 unit test were made to test each one of the three deprecated language codes and one more to test other cases that don't fall for this condition.
These tests were made in a file named StringUtilsTest was created inside utils test directory.

Screenshot
The description field now shows the correct ISO-639-1 language codes.
image

@codecov-io
Copy link

codecov-io commented Apr 25, 2019

Codecov Report

Merging #2930 into master will increase coverage by 0.05%.
The diff coverage is 43.75%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2930      +/-   ##
=========================================
+ Coverage    3.64%   3.69%   +0.05%     
=========================================
  Files         245     246       +1     
  Lines       12194   12215      +21     
  Branches     1078    1083       +5     
=========================================
+ Hits          444     451       +7     
- Misses      11716   11730      +14     
  Partials       34      34
Impacted Files Coverage Δ
...ee/nrw/commons/upload/SpinnerLanguagesAdapter.java 0% <0%> (ø) ⬆️
.../java/fr/free/nrw/commons/utils/LangCodeUtils.java 87.5% <87.5%> (ø)
...n/java/fr/free/nrw/commons/auth/LoginActivity.java 0% <0%> (ø) ⬆️
...ava/fr/free/nrw/commons/nearby/NearbyFragment.java 0% <0%> (ø) ⬆️
...ava/fr/free/nrw/commons/review/ReviewActivity.java 0% <0%> (ø) ⬆️
.../fr/free/nrw/commons/nearby/NearbyMapFragment.java 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c127bcf...5211f21. Read the comment docs.

…atting improvement in "SpinnerLanguagesAdapter"
@neslihanturan
Copy link
Collaborator

Thanks @CAVillalobos , congratz for your first contribution 🎉

@neslihanturan neslihanturan merged commit ee3f4d4 into commons-app:master Apr 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Description field uses outdated code iw for Hebrew

3 participants