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

feat: Add constants.humanName to allow countries to have custom full name format #7812

Merged
merged 8 commits into from
Nov 11, 2024

Conversation

Siyasanga
Copy link
Collaborator

@Siyasanga Siyasanga commented Oct 22, 2024

In order to allow countries to define their own full name format, we are adding a constants.humanName into the client.csv translations, which will then be used everywhere where we are displaying system users and citizen's name in the systems.

Addresses #6830

@Siyasanga Siyasanga self-assigned this Oct 22, 2024

This comment has been minimized.

@Siyasanga Siyasanga added this to the v1.7.0 milestone Oct 22, 2024
@ocrvs-bot
Copy link
Collaborator

Your environment is deployed to https://ocrvs-6830-human-name-constant.opencrvs.dev

@Siyasanga Siyasanga marked this pull request as draft October 22, 2024 08:43
Comment on lines 557 to 561
intl.formatMessage(constantsMessages.humanName, {
firstName: user.name[0].firstNames,
middleName: user.name[0].middleName,
lastName: user.name[0].familyName
})) ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to have a utility function similar to the createNamesMap, something like this:

function internationalizedName(name: HumanName[], locale: Locale): { 
  firstName: string
  middleName: string
  lastName: string
}

It would try to find the name in the given locale, falling back to 'en' in case it does not find it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is where I was getting confused. It looks like the translations are passed through from IntlProvider and also pulled from country-config, now passing the locale implies that we have access to all different translations and dynamically changes languages. Do you know where I can get this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can just pass in intl.locale to the function. As for how to resolve that, take a look at the current implementation of the createNamesMap function, it should give you an idea.

Copy link
Member

@rikukissa rikukissa Oct 23, 2024

Choose a reason for hiding this comment

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

Do we really support names in multiple languages 🤔 If not, then I'd aim to simplify as much as we can. IMO best would be a component like

<HumanName name={user.name} />

component that could use the useIntl hook. Passing the intl object as a function parameter feels like a little upside down

Copy link
Collaborator Author

@Siyasanga Siyasanga Oct 23, 2024

Choose a reason for hiding this comment

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

Hi @rikukissa on the system user we only support one language, English and on the Birth and Death forms it looks like we only ask First names and Surname. Does this confirm that we don't support name in multiple languages for Birth, Marriage and Death as well?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think that's a safe assumption

@Siyasanga
Copy link
Collaborator Author

Thank for the feedback guys @rikukissa @Zangetsu101, I ended up going with the utility function approach because I needed just the localised name in some instances instead of the React.Node component. Please let me know if you have feedback

@Siyasanga Siyasanga force-pushed the ocrvs-6830-human-name-constant branch from 46b6c1d to d1e6f6a Compare October 24, 2024 08:20
@Zangetsu101
Copy link
Collaborator

I think we can go with this approach. Removing multiple spaces using regex is better as we would have to handle quite a few edge cases otherwise

@tahmidrahman-dsi
Copy link
Collaborator

@Siyasanga is this PR still work in progress or ready for review?

@Siyasanga Siyasanga force-pushed the ocrvs-6830-human-name-constant branch from d826a03 to 5d122ce Compare November 7, 2024 12:40
@Siyasanga Siyasanga temporarily deployed to ocrvs-6830-human-name-constant November 7, 2024 12:40 — with GitHub Actions Inactive
@Siyasanga
Copy link
Collaborator Author

@Siyasanga is this PR still work in progress or ready for review?

Thanks @tahmidrahman-dsi yes it's ready for review

@Siyasanga Siyasanga marked this pull request as ready for review November 7, 2024 12:41
To allow countries to have custom ordering for full names

#6830
To ensure that we get the format from the country-config

#6830
To make the name more usable we had to extract the name formatting logic into it's own function.

#6830
Replace older logic to get the name which was based on an assumption that we support names in multiple languages

#6830
We've found cleaner way to make the rendered name customizable for each country through client copy from country-config

#6830
We need to update all the places where a citizen's name is being referenced to show it in the format that the country chooses

#6830
@Siyasanga Siyasanga force-pushed the ocrvs-6830-human-name-constant branch from 5d122ce to 1a13fc2 Compare November 11, 2024 11:29
@Siyasanga Siyasanga enabled auto-merge (squash) November 11, 2024 11:32
@Siyasanga Siyasanga merged commit 9d98010 into develop Nov 11, 2024
59 of 60 checks passed
@naftis
Copy link
Collaborator

naftis commented Nov 11, 2024

I think this PR might have broken the E2E's? @Siyasanga
image

Hyper3x pushed a commit that referenced this pull request Nov 12, 2024
…name format (#7812)

* Add humanName to constants.ts

To allow countries to have custom ordering for full names

#6830

* Use constants.humanName on the UserList.tsx comp

To ensure that we get the format from the country-config

#6830

* Create a utility function getLocalisedname()

To make the name more usable we had to extract the name formatting logic into it's own function.

#6830

* Use getLocalisedName on the UserList component

#6830

* Use getLocalisedName on the UserAudit comp

Replace older logic to get the name which was based on an assumption that we support names in multiple languages

#6830

* refactor: use getLocalisedName() @ InProgress.tsx

We've found cleaner way to make the rendered name customizable for each country through client copy from country-config

#6830

* Refactor the work queues to use getLocalisedName()

We need to update all the places where a citizen's name is being referenced to show it in the format that the country chooses

#6830

* Record changes in the CHANGELOG for this PR

#6830
Zangetsu101 added a commit that referenced this pull request Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants