-
Notifications
You must be signed in to change notification settings - Fork 73
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
Conversation
This comment has been minimized.
This comment has been minimized.
Your environment is deployed to https://ocrvs-6830-human-name-constant.opencrvs.dev |
intl.formatMessage(constantsMessages.humanName, { | ||
firstName: user.name[0].firstNames, | ||
middleName: user.name[0].middleName, | ||
lastName: user.name[0].familyName | ||
})) || |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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 |
46b6c1d
to
d1e6f6a
Compare
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 |
c23ce35
to
41e9d75
Compare
720bc5f
to
d826a03
Compare
@Siyasanga is this PR still work in progress or ready for review? |
d826a03
to
5d122ce
Compare
Thanks @tahmidrahman-dsi yes it's ready for review |
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
5d122ce
to
1a13fc2
Compare
I think this PR might have broken the E2E's? @Siyasanga |
…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
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