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

Make language slug available via session metadata (formplayer branch) #1441

Merged
merged 4 commits into from
Oct 16, 2024

Conversation

minhaminha
Copy link
Contributor

Product Description

Users will now be able to reference the current language slug (i.e. 'en', 'es', etc.) on the screen by referencing instance('commcaresession')/session/context/applanguage

Technical Summary

Associated formplayer PR

This is the commcare-core side of the changes which:

  • Modifies the EntityScreenContext class to be able to carry and get the stored locale value (first initialized from within navigateSessionWithAuth), which allows it to be accessed during different parts of the response creation process.
  • Modifies the generateRoot path such that locale is eventually added to the session root under metadata.
    • More specifically passes in the locale value to setupSessionData, which eventually leads to calling addMetadata, now also with a required 'locale' arguement.
  • Modified various context getters/creators to accept an optional locale argument (and updates use cases that doesn't directly relate to the workflow followed by making a navigateSessionWithAuth request to use null values instead).

Safety Assurance

Safety story

This shouldn't impact existing data since the objects surrounding session context is constantly being recreated with updated information from formplayer and most of the time the locale value will be set to null.

QA Plan

No plans for QA but will have delivery (who request this feature) do some testing to ensure it's doing what they want.

Special deploy instructions

  • This PR can be deployed after merge with no further considerations. (I guess implied that it should be rolled back with the associated formplayer PR?)

Rollback instructions

  • This PR can be reverted after deploy with no further considerations.

Review

  • The set of people pinged as reviewers is appropriate for the level of risk of the change.

Duplicate PR

Automatically duplicate this PR as defined in contributing.md.
(Doing this after this PR gets approved)

@@ -279,7 +279,7 @@ public void setID(int recordid) {
this.recordid = recordid;
}

public abstract DataInstance initialize(InstanceInitializationFactory initializer, String instanceId);
public abstract DataInstance initialize(InstanceInitializationFactory initializer, String instanceId, String locale);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you not create a concrete method with the original signature which calls the abstract one with the locale being null? Then you would not have to pass the null everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very true! This did indeed get rid of some unnecessary null usage 🎉

…es) to avoid putting so many null values into argument lists
@minhaminha
Copy link
Contributor Author

duplicate this PR

@minhaminha minhaminha merged commit ed40617 into formplayer Oct 16, 2024
2 checks passed
@minhaminha minhaminha deleted the ml/lang-slug-metadata-formplayer-branch branch October 16, 2024 20:33
@Jtang-1 Jtang-1 restored the ml/lang-slug-metadata-formplayer-branch branch October 16, 2024 21:22
@Jtang-1
Copy link
Contributor

Jtang-1 commented Oct 16, 2024

duplicate this PR 464b36e f336ec3

@Jtang-1 Jtang-1 deleted the ml/lang-slug-metadata-formplayer-branch branch October 16, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants