-
-
Notifications
You must be signed in to change notification settings - Fork 943
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
Conversation
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
|
/** | ||
* Returns a random letter. | ||
* | ||
* It can also return diacritic letters in some locales, like german `ä`. |
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.
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. |
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.
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?
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.
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
The referenced issue has barely any upvotes or comments. 🤔 |
The other problem with putting Greek letters in fakerEL is I cannot easily use it in a helpers.fake pattern Eg if I want "{{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 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 function x() {
return `${faker.commerce.productName()} are located in Section ${faker.foo.romanLetter()} subsection ${fakerEL.word.letter()}`;
~~~~~~~~~~~~~~~~~~~~~~~ this does not even exists
} |
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. |
As I don't feel healthy (again) anymore, I will close this for now |
closes #558