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

Added german Names List #83

Merged
merged 5 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ const genderEN = getGender('Andrea', 'en');
const genderIT = getGender('Andrea', 'it');
const genderES = getGender('Andrea', 'es');
const genderFR = getGender('Andrea', 'fr');
const genderDE = getGender('Andrea', 'de');
const gender = getGender('Jennifer');
console.log(genderEN); // female
console.log(genderIT); // male
console.log(genderES); // male
console.log(genderFR); // male
console.log(genderDE); // female
console.log(gender); // female
```

### Supported languages
`en`, `it`, `es`, `fr`
`en`, `it`, `es`, `fr`, `de`

### Run tests
```npm test```
Expand Down
5 changes: 4 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
declare module "gender-detection-from-name" {
export function getGender(name: string, lang?: 'en' | 'it' | 'es'| 'fr'): string;
export function getGender(
name: string,
lang?: "en" | "it" | "es" | "fr" | "de"
): string;
}
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const enMap = require('./names/en');
const itMap = require('./names/it');
const esMap = require('./names/es');
const frMap = require('./names/fr');
const deMap = require('./names/de');

/**
* Gender detection from first name and optional language
Expand All @@ -21,7 +22,8 @@ function getGender(name, lang = 'all') {
it: itMap,
es: esMap,
fr: frMap,
all: new Map([...itMap, ...enMap, ...esMap, ...frMap]),
de: deMap,
all: new Map([...itMap, ...enMap, ...esMap, ...frMap, ...deMap]),
};
// Use the Map of input language, or use all
const mapToUse = maps[lang] || maps.all;
Expand Down
Loading
Loading