ellykits / neat-form

Build form on Android using JSON schema; also includes view validation and skip logic.
Apache License 2.0
67 stars 28 forks source link

Implement Multi-Language support #113

Closed ndegwamartin closed 3 years ago

ndegwamartin commented 3 years ago

Closes #69

ellykits commented 3 years ago

screenshot-2021-05-17_00 38 00 645

ellykits commented 3 years ago

The form was NOT translated when I changed device language to Kiswahili (both Tanzanian and Kenyan dialect). French translation works but appears the skip logic applied via the rules is affected. My thinking is it maybe referencing actual text instead of the keys for the options. That can be corrected.

ellykits commented 3 years ago

@dubdabasoduba Can you review this? I am gonna assign you to it as well. Thanks.

codecov[bot] commented 3 years ago

Codecov Report

Merging #113 (b752355) into master (1cc1354) will decrease coverage by 0.10%. The diff coverage is 62.50%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #113      +/-   ##
============================================
- Coverage     75.01%   74.91%   -0.11%     
- Complexity      422      425       +3     
============================================
  Files            40       41       +1     
  Lines          1429     1443      +14     
  Branches        321      321              
============================================
+ Hits           1072     1081       +9     
- Misses          110      115       +5     
  Partials        247      247              
Impacted Files Coverage Δ
...mcore/utils/internationalization/LanguageHelper.kt 50.00% <50.00%> (ø)
...erdstone/neatformcore/form/json/JsonFormBuilder.kt 80.23% <70.00%> (-0.54%) :arrow_down:

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 1cc1354...b752355. Read the comment docs.

ndegwamartin commented 3 years ago

The form was NOT translated when I changed device language to Kiswahili (both Tanzanian and Kenyan dialect). French translation works but appears the skip logic applied via the rules is affected. My thinking is it maybe referencing actual text instead of the keys for the options. That can be corrected.

We had configured the translation with the incorrect locale suffix. For Swahili should be sw instead of swa. More on locales and valid language codes can be found here. I'll add this link to the README as well

ndegwamartin commented 3 years ago

General question: Can the translations work with properties provided from another source other than loading them from the resources directory? For the forms, you can build from a file in the assets or from a String source which can be stored in any place hence the reasons for having 2 constructors for the form builder. One accepts name of file in the assets directory whereas the other uses the JSON string provided.

Depends on how we'd want to implement this e.g.

ellykits commented 3 years ago

Depends on how we'd want to implement this e.g.

  • Would we want to store that json string form as already translated?
  • If not, are the translations also provided alongside it?

I assume the translations will be provided alongside the form, that way we go with second option as it is more flexible.

ellykits commented 3 years ago

@ndegwamartin Can you update spinner widget and any other widget with options that is saving the label instead of the key for the option. This is affecting rules processing in a multilanguange setup. E.g if the rule is declared to use the default language label, it will not work for other languages. This is reproducible on the Spinner. Debug this method com.nerdstone.neatformcore.rules.RulesFactory#updateFactsAndExecuteRules and see the value that is passed (should be option key instead. I have not tested for radio groups/multi choice checkboxes.

ellykits commented 3 years ago

The form was NOT translated when I changed device language to Kiswahili (both Tanzanian and Kenyan dialect). French translation works but appears the skip logic applied via the rules is affected. My thinking is it maybe referencing actual text instead of the keys for the options. That can be corrected.

We had configured the translation with the incorrect locale suffix. For Swahili should be sw instead of swa. More on locales and valid language codes can be found here. I'll add this link to the README as well

Did you push the fix for Swahili translation? I see the file extension is still the same in your last commit.

ellykits commented 3 years ago

Also remember to increment the app version in the README/build.gradle file. I will remove Bintray configs in another commit, for now we can work with GitHub Package Registry.

ndegwamartin commented 3 years ago

Depends on how we'd want to implement this e.g.

  • Would we want to store that json string form as already translated?
  • If not, are the translations also provided alongside it?

I assume the translations will be provided alongside the form, that way we go with second option as it is more flexible.

If we pick the second option I think we'd then need to modify the constructor to accept an optional language translation file (or content)

ellykits commented 3 years ago

Alright we can overload.

On Mon, May 17, 2021, 8:43 PM Martin Ndegwa @.***> wrote:

Depends on how we'd want to implement this e.g.

  • Would we want to store that json string form as already translated?
  • If not, are the translations also provided alongside it?

I assume the translations will be provided alongside the form, that way we go with second option as it is more flexible.

If we pick the second option I think we'd then need to modify the constructor to accept an optional language translation file (or content)

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/ellykits/neat-form/pull/113#issuecomment-842511765, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGM667AEUFN4GHXCPB4EW53TOFIVNANCNFSM43UQOBDQ .

ellykits commented 3 years ago

@ndegwamartin I experienced app crash in Android version 10 screenshot-2021-05-25_16 25 32 762

Error logs

2021-05-25 16:20:45.333 3412-3412/com.nerdstone.neatform W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@b5ec994
2021-05-25 16:20:45.417 3412-3412/com.nerdstone.neatform E/CustomExceptions$$special$$inlined$CoroutineExceptionHandler: CoroutineExceptionHandler got java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
ellykits commented 3 years ago

I have opened the new issue for fixing the issue with the spinner skip logic. This is good to go :+1: