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

🔖 [PR] New default label options and translations #1065

Conversation

sebastianbarry
Copy link
Contributor

This PR is associated with e-mission/e-mission-docs#1007

This PR is replacing #1055, as that branch was having issues loading the app that I wasn't sure how to troubleshoot (likely something new changed since oct5 - oct9 commits from @JGreenlee and @shankari):
image

This new branch works, and includes everything from the old PR but adds the function of falling back to checking i18next translations in a new field named "multilabel" for label-options if the translations are not defined in the provided dynamic (or default, technically) label-options file.

confirmHelper.ts
- Removed archaic behavior or using old Angular i18nUtils module to get the filename of the translations' trip_confirm_options.json file
- The "else" default "no label_options found in config" behavior is almost identical to the if(appConfig.label_options), but it just uses the default label options URL at label-options.json.sample
- Pulled the language-specific text handling behavior out of the if statement, because either way (label_options or no label_options) the JSON data model will look the same
- The for loop for filling in the translatied text for label-options checks 1. The label-options file first, then 2. The i18next file for the translation

label-options.json.sample
- Created new file
- Replaces trip_confirm_options.json.sample (this location in confirmHelper.ts was the only place in the codebase using this file)
- Modeled after https://github.com/e-mission/nrel-openpath-deploy-configs/blob/main/label_options/example-program-label-options.json
- Only has translations for EN and ES

trip_confirm_options.json.sample
- Removed this file
en.json
- Added multilabel filed filled with a few multilabel translations in EN
@sebastianbarry
Copy link
Contributor Author

sebastianbarry commented Oct 12, 2023

Testing:

Scenario App Screenshot Code screenshot
I added a new "example" MODE which gathers its translation from label-options.json.sample by default Simulator Screenshot - iPhone 13 - 2023-10-12 at 13 40 18 image image
I removed the translation from label-options.json.sample and it fell-back onto the translation I added to en.json Simulator Screenshot - iPhone 13 - 2023-10-12 at 13 41 38 image

@sebastianbarry
Copy link
Contributor Author

Ready for review

@sebastianbarry sebastianbarry changed the title New default label options and translations 🔖 [PR] New default label options and translations Oct 12, 2023
@JGreenlee
Copy link
Collaborator

JGreenlee commented Oct 13, 2023

This PR cannot be merged until service_rewrite_2023 is in sync with onboarding_routing_sept_2023.
Once synced, we'll see if any of these merge conflicts are still there - if so we'll have to resolve them

Copy link
Collaborator

@JGreenlee JGreenlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic looks good. I am requesting a few textual changes.

We are going to need a PR to e-mission-translate adding the new keys to es.json and lo.json. Feel free to either do that yourself or coordinate with @Abby-Wheelis since she's been handling translations recently.

www/js/survey/multilabel/confirmHelper.ts Outdated Show resolved Hide resolved
www/i18n/en.json Outdated Show resolved Hide resolved
@JGreenlee
Copy link
Collaborator

JGreenlee commented Oct 16, 2023

Can you change the target of this PR to some other branch, then change it back to service_rewrite_2023?

(My PRs are merged but my commits are still showing up in this PR. I've discovered that toggling the branch forces Github to update the diff)

@sebastianbarry sebastianbarry changed the base branch from service_rewrite_2023 to master October 17, 2023 17:03
@sebastianbarry sebastianbarry changed the base branch from master to service_rewrite_2023 October 17, 2023 17:03
sebastianbarry and others added 3 commits October 17, 2023 11:07
> JGreenlee 
> It's the other way around. labelOptions first, then i18next.
> The code is correct but the comment is not
> JGreenlee
> While we are rewriting and have this opportunity, can we make all the text with slashes look "like / this" instead of "like/ this"?
> I believe they were made like that a while ago to force a line break. But we don't do that anymore in the UI so the slashes end up looking weird.
@sebastianbarry
Copy link
Contributor Author

sebastianbarry commented Oct 17, 2023

Last thing left to do is:

  • PR to e-mission-translate adding the new keys to es.json and lo.json

Copy link
Collaborator

@JGreenlee JGreenlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sebastianbarry
Copy link
Contributor Author

Created PR to e-mission-translate e-mission/e-mission-translate#47

Copy link
Contributor

@shankari shankari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastianbarry this is a cool idea, but I don't understand why you need to have two copies of the translations in this case. If the whole point was to have one "source of truth" and not copy the information around, then there's no reason to have two copies...

Also, where is the testing for default versus dynamic config, which was the original issue?
This only tests for default translations from label-options and from en.json...

www/js/survey/multilabel/confirmHelper.ts Outdated Show resolved Hide resolved
www/json/label-options.json.sample Outdated Show resolved Hide resolved
www/i18n/en.json Show resolved Hide resolved
@sebastianbarry
Copy link
Contributor Author

this is a cool idea, but I don't understand why you need to have two copies of the translations in this case. If the whole point was to have one "source of truth" and not copy the information around, then there's no reason to have two copies...

The design principle for having 2 copies of the translations is as follows: There is an underlying layer of multilabel translations, found in the i18next files en.json, es.json, etc. These translations are the fallback in case any label-options file does not contain the translations portion for a given language. Then above that layer, are the translations from the label-options file. These translations will be the default. Having this default/backup translations is helpful for multiple reasons: 1. If there is a Spanish speaking user who is part of the Lao program that only has translations in Lao and English, they prefer Spanish on their device which does not have translations in the Lao label-options file. In this case, it would fall back onto the es.json file and get the translations from there. 2. In USA English we might call a mode of transportation a "Rickshaw", but in Lao English they might call a mode of transportation "Tuk tuk", so we have the ability to have area-specific translations of modes.

This method of implementation does have some (but minimal) copied translations, but it offers a higher level of flexibility because the label-options file only needs to have special translations, and any other way of doing it would not offer this level of flexibility with this level of customization.

That being said @shankari, I see what you're saying about this PR still having translations in the default sample label-options file, so I will remove those.

Also, where is the testing for default versus dynamic config, which was the original issue? This only tests for default translations from label-options and from en.json...

The testing for default vs. dynamic config was in the old PR that I closed:

Testing:

iPhone 13 iOS 15.4
Labels being loaded locally Screenshot 2023-10-05 at 10 48 04 AM
Labels working Simulator Screenshot - iPhone 13 - 2023-10-05 at 10 45 20
Labels working Simulator Screenshot - iPhone 13 - 2023-10-05 at 10 45 23

Since the default translations are in 18next files, we don't need a duplicate of the default label options translations in this file

Also changed the logic because I didn't have it right when labelOptions.translations is undefined
@sebastianbarry
Copy link
Contributor Author

I removed the translations from label-options.json.sample and confirmed that it is still working - it required a change to the logic as well to get the translation, but it works for various purposes now

  • label-options has NO translations (gets every translation from i18next)
  • label-options has only some translations (first checks label-options, then checks i18next)
  • label-options has all the translations (only checks label-options, but still has the backup of i18next in case one is missing or something)

@shankari Moving this back to ready for review

@shankari
Copy link
Contributor

This method of implementation does have some (but minimal) copied translations, but it offers a higher level of flexibility because the label-options file only needs to have special translations, and any other way of doing it would not offer this level of flexibility with this level of customization.

Correct, but before your most recent change, the label-options file had all translations, not just special ones.

@shankari shankari merged commit 2e19760 into e-mission:service_rewrite_2023 Oct 20, 2023
@sebastianbarry
Copy link
Contributor Author

This method of implementation does have some (but minimal) copied translations, but it offers a higher level of flexibility because the label-options file only needs to have special translations, and any other way of doing it would not offer this level of flexibility with this level of customization.

Correct, but before your most recent change, the label-options file had all translations, not just special ones.

I added some of my thoughts to this in e-mission/e-mission-translate#47 (comment), adding it here for traction

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.

3 participants