globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

Add support for internationalized name formatting and sorting #901

Open fantapop opened 4 years ago

fantapop commented 4 years ago

The globalize library seems like the best place to have resources for international name formatting.

Some background on our use case:

In our application we have users from all over the world. We need to display the names of these users both back to them and in a dashboard that can also be accessed by users who speak different languages and are of different nationalities. One of the problems we're having to solve is how to display a users name (family and given) in the format correct for their locale.

When we display names for easy sorting, we're usually using last name first no matter if the person utilizes western or eastern naming. However if a name is in Chinese we'll leave out the comma:

for example:

Edison, Thomas 戚秋银

When we need to display names in the "standard" method for the particular name we need to know which names follow eastern vs western naming standards. There are many more nuanced rules such as Japanese and Korean names should be separated by a space and Chinese names not.

In some cases its impossible to tell if a name is japanese, korean, or chinese based on just the character set, so I'd expect some of these methods to take in a locale or something similar to help determine how they should be formatted.

Another related item that would be helpful to have in the globalize library is a sort comparator for japanese names that takes into account all of the character sets. Here is a resource which gets into some of the nuances there. https://www.rws.com/insights/rws-moravia-blog/5-things-you-should-know-to-sort-japanese-the-right-way/