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(word): add method for generating letter #2836

Closed
wants to merge 1 commit into from
Closed

Conversation

Shinigami92
Copy link
Member

@Shinigami92 Shinigami92 added c: feature Request for new feature p: 1-normal Nothing urgent c: locale Permutes locale definitions m: word Something is referring to the word module labels Apr 19, 2024
@Shinigami92 Shinigami92 added this to the vAnytime milestone Apr 19, 2024
@Shinigami92 Shinigami92 self-assigned this Apr 19, 2024
@Shinigami92 Shinigami92 requested a review from a team as a code owner April 19, 2024 09:20
Copy link

netlify bot commented Apr 19, 2024

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit 9de15c8
🔍 Latest deploy log https://app.netlify.com/sites/fakerjs/deploys/66223779f38b3f0008398837
😎 Deploy Preview https://deploy-preview-2836.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Apr 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.95%. Comparing base (48ab524) to head (9de15c8).

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #2836      +/-   ##
==========================================
- Coverage   99.95%   99.95%   -0.01%     
==========================================
  Files        2964     2968       +4     
  Lines      212544   212673     +129     
  Branches      945      945              
==========================================
+ Hits       212457   212585     +128     
- Misses         87       88       +1     
Files Coverage Δ
src/locales/de/word/index.ts 100.00% <100.00%> (ø)
src/locales/de/word/letter.ts 100.00% <100.00%> (ø)
src/locales/el/index.ts 100.00% <100.00%> (ø)
src/locales/el/word/index.ts 100.00% <100.00%> (ø)
src/locales/el/word/letter.ts 100.00% <100.00%> (ø)
src/locales/en/word/index.ts 100.00% <100.00%> (ø)
src/locales/en/word/letter.ts 100.00% <100.00%> (ø)
src/modules/word/index.ts 98.92% <100.00%> (+0.04%) ⬆️

... and 1 file with indirect coverage changes

/**
* Returns a random letter.
*
* It can also return diacritic letters in some locales, like german `ä`.
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are going to do it this way, I think we should specifically call out the ability to generate a Greek letter using fakerEL since Greek letters are often used in scientific contexts and it's not obvious that this is possible from the current docs.

@@ -2,6 +2,17 @@ import { FakerError } from '../../errors/faker-error';
import { ModuleBase } from '../../internal/module-base';
import { filterWordListByLength } from './filter-word-list-by-length';

export interface Letter {
/**
* The uppercase letter.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all alphabets have an uppercase and lowercase variant for letters for example, Thai, Arabic, Georgian etc. What would you expect to be returned for those ? Would you just return the same letter repeated for lowercase and uppercase?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I thought about this 😕
Either we could discuss together a bit about this on Discord or in a team meeting

Maybe fallback and just fill upper and lower with same value might be the easiest solution

@ST-DDT
Copy link
Member

ST-DDT commented Apr 19, 2024

The referenced issue has barely any upvotes or comments. 🤔
So I consider it low prio.
Also there is the current feature freezes to prepare for the v9 changes.

@matthewmayer
Copy link
Contributor

The other problem with putting Greek letters in fakerEL is I cannot easily use it in a helpers.fake pattern

Eg if I want
"Incredible Soft Gloves are located in Section A, subsection δ" I can't do

"{{commerce.productName}} are located in Section {{foo.romanLetter}} subsection {{foo.greekLetter}}"

@Shinigami92
Copy link
Member Author

Shinigami92 commented Apr 21, 2024

The other problem with putting Greek letters in fakerEL is I cannot easily use it in a helpers.fake pattern

Eg if I want "Incredible Soft Gloves are located in Section A, subsection δ" I can't do

"{{commerce.productName}} are located in Section {{foo.romanLetter}} subsection {{foo.greekLetter}}"

Can you elaborate what this has to be done with this PR? Why does it not count for chemicalElement or airline?
I think this might then be more a problem of fake and is out of scope for this PR and feature implementation.

Or did I get your intend wrong? You want to use greek (mixed locale) context inside fake? This is new to me 🤔 And if so, you could still generate all this just without using fake but just wrap in a function.

function x() {
  return `${faker.commerce.productName()} are located in Section ${faker.foo.romanLetter()} subsection ${fakerEL.word.letter()}`;
                                                                   ~~~~~~~~~~~~~~~~~~~~~~~ this does not even exists
}

@matthewmayer
Copy link
Contributor

Greek/roman letters are "international"

Like even if you are writing English you might use single Greek letters for some things. Even if you are writing Chinese you might use single Roman letters for some things.

You can of course use string interpolation. But fake patterns can be used by other faker definitions so it's nice if they can access useful data.

@Shinigami92
Copy link
Member Author

As I don't feel healthy (again) anymore, I will close this for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: feature Request for new feature c: locale Permutes locale definitions m: word Something is referring to the word module p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Random greek alphabet letter
3 participants