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

The format of the email address output in Japanese is not correct. #1437

Closed
9 of 10 tasks
shu-pf opened this issue Oct 13, 2022 · 8 comments
Closed
9 of 10 tasks

The format of the email address output in Japanese is not correct. #1437

shu-pf opened this issue Oct 13, 2022 · 8 comments
Assignees
Labels
c: bug Something isn't working m: internet Something is referring to the internet module

Comments

@shu-pf
Copy link

shu-pf commented Oct 13, 2022

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

import { faker } from '@faker-js/faker/locale/ja';

const email = faker.internet.email();
console.log(email); // 樹_林@hotmail.com

Expected behavior

import { faker } from '@faker-js/faker/locale/ja';

const email = faker.internet.email();
console.log(email); // itsuki_hayashi@hotmail.com

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

System:
    OS: macOS 11.6
    CPU: (8) arm64 Apple M1
    Memory: 133.45 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.2 - ~/.volta/tools/image/node/16.13.2/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 8.1.2 - ~/.volta/tools/image/node/16.13.2/bin/npm
  Browsers:
    Chrome: 106.0.5249.103
    Firefox: 96.0.1
    Safari: 15.3
  npmPackages:
    @faker-js/faker: ^7.5.0 => 7.5.0

Which module system do you use?

  • CJS
  • ESM

Used Package Manager

yarn

@shu-pf shu-pf added c: bug Something isn't working s: pending triage Pending Triage labels Oct 13, 2022
@Shinigami92
Copy link
Member

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.

@shu-pf
Copy link
Author

shu-pf commented Oct 13, 2022

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.

@Shinigami92
Copy link
Member

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

@shu-pf
Copy link
Author

shu-pf commented Oct 13, 2022

@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.

@Shinigami92
Copy link
Member

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?

@ST-DDT
Copy link
Member

ST-DDT commented Oct 13, 2022

I think we could base32(?) encode the incompatible characters. That wont yield nice email addresses, but usable and reproducible ones.

@shu-pf
Copy link
Author

shu-pf commented Oct 13, 2022

@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.

@xDivisionByZerox
Copy link
Member

xDivisionByZerox commented Apr 25, 2023

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.

@xDivisionByZerox xDivisionByZerox added the m: internet Something is referring to the internet module label Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working m: internet Something is referring to the internet module
Projects
None yet
Development

No branches or pull requests

5 participants