Fix wrong language codes displaying to user (#2880) #2930
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.