Closed shu-pf closed 1 year ago
It may also be possible to solve this problem by creating a function that converts Japanese names to romaji.
We do not provide utility functions that are not based on the underlying seed, but you might have luck with e.g. https://www.npmjs.com/package/hepburn and pass the values to the internet.email
function.
Please use that for a workaround for now as we are now in a maintenance state with faker to move forward to v8. So unless something it really critical we wont have the time and resources to fix and release this proposal.
Thanks for the reply.
I checked Hepburn. This library can convert Hiragana and Katakana, but not Kanji. The names provided by Faker are in Kanji. It seems difficult to solve the problem here.
Thanks for the reply.
I checked Hepburn. This library can convert Hiragana and Katakana, but not Kanji. The names provided by Faker are in Kanji. It seems difficult to solve the problem here.
@shu-pf The linked package was just a quick search with a search engine. I assume you are smart enough to find a suitable npm package for your need very quickly 😉 The process would still be the same: transform and use that as input
@Shinigami92 I have not checked all packages, but I don't think there is a package that converts Kanji to Romaji. Conversion between kanji and romaji cannot be done mechanically, becose there are multiple patterns and some conversions that are not listed in the dictionary. Hiragana has a one-to-one relationship with romaji, so it is assumed that a package exists.
So it would be necessary to manually set up the relationship between the Kanji name and the Romaji name to fix this feature.
Conversion between kanji and romaji cannot be done mechanically, because there are multiple patterns and some conversions that are not listed in the dictionary.
So how in the world should Faker then provide a functionality for that 👀 I don't see the responsibility on our side for doing that 🤔 Currently emails will be generated just by first and last name. Do you have any proposal how to handle that for japanese instead of converting kanji and romaji?
I think we could base32(?) encode the incompatible characters. That wont yield nice email addresses, but usable and reproducible ones.
@Shinigami92
I think the only way is to make a table of correspondence between kanji and romaji and use it.
I don't have a deep understanding of the current code, but if I were to write the code. First prepare two tables.
last_name.ts
export default [
'佐藤',
'鈴木',
...
];
last_name_romaji.ts
export default [
'Satou',
'Suzuki',
...
];
And for names, use the 'last_name.ts'. For e-mail, use the 'last_name_romaji.ts'.
It takes a lot of effort to have this done by someone other than a native Japanese speaker, so of course I am willing to help.
@ST-DDT Thank you for sharing your solution! I hadn't thought of that. But I think base32 is too long for email. I use nanoid package for this.
It seems to be a realistic solution at this time.
This has likely been fixed by #1554 and is part of https://github.com/faker-js/faker/releases/tag/v8.0.0-alpha.0. If this is not the case please reopen this issue.
Pre-Checks
Describe the bug
Clear and concise description of the problem
Japanese people do not use multibyte characters in their e-mail addresses because using multibyte characters in some e-mail addresses can cause erroneous transmissions. Therefore, we generally convert the name to romaji first and use that for the e-mail address.
Suggested solution
Current Behavior
Expected behavior
Minimal reproduction code
No response
Additional Context
It may also be possible to solve this problem by creating a function that converts Japanese names to romaji.
Environment Info
Which module system do you use?
Used Package Manager
yarn