randName
Generates person names and returns count of them as strings, written in the script you asked for. With output: 'detail' it returns the native and romanized form of each name instead, together with the language and gender behind it.
import { randName } from 'randino';
randName();
// ['Emma Clover']import 'package:randino/randino.dart';
randName();
// ['Emma Clover']from randino import rand_name
rand_name()
# ['Emma Clover']Options
Every option is optional, and the defaults are what the empty call above uses.
| Option | Type | Default | Description |
|---|---|---|---|
language | NameLanguageOptionNameLanguage?NameLanguageOption | 'all'null"all" | Language of the generated names. 'all'null"all" mixes every supported language, picking one per name. |
gender | NameGenderOptionNameGender?NameGenderOption | 'all'null"all" | Which pools the given name is drawn from. Left out, a gender is picked per name. |
count | numberintint | 1 | How many names to return. Clamped to 0 … 10000. |
realism | RandRealism | <Lang js="'real'" dart="RandRealism.real" py="\"real\"" /> | real draws names people actually carry, invented builds new ones, and mixed decides per part. |
minLengthminLengthmin_length | numberint?int | None | language | Minimum length of the native form, in characters. |
maxLengthmaxLengthmax_length | numberint?int | None | language | Maximum length of the native form, in characters. |
includeSurnameincludeSurnameinclude_surname | booleanboolbool | truetrueTrue | Include the family name. |
includeMiddleNameincludeMiddleNameinclude_middle_name | booleanboolbool | falsefalseFalse | Include a middle name. Ignored for languages that have none. |
script | NameScript | 'native'NameScript.native"native" | The script the returned strings are written in. |
startsWithstartsWithstarts_with | stringString?str | —null"" | Keep only names whose native form starts with this character. Only the first character is used, and the match is case-insensitive. |
unique | booleanboolbool | falsefalseFalse | Never return the same name twice. May return fewer than count once the pools run out of combinations. |
output | RandOutputRandOutput | 'value'"value" | Strings, or a NameDetail per name. Dart has no such parameter — see the detail output. |
random | () => numberRandom?Callable[[], float] | None | —nullNone | Where the randomness comes from — see Choosing the source. Defaults to the platform's ordinary generator. |
minLengthminLengthmin_length and maxLengthmaxLengthmax_length default to the language's own range, which nameLengthRange reports. That fallback is resolved per language, so a mixed draw does not stretch a Korean name to fill a Spanish name's range.The detail output
output: 'detail' returns each name in both scripts at once, with the language and gender behind it, instead of a string. Useful for showing a name next to its English pronunciation, and necessary when the draw is mixed and you need to know what each name is. script has nothing left to choose there, so it is ignored.
Dart spells this as a second function, randNameDetails, because it has no way to make one function's return type depend on an argument. It takes the same parameters as randName except script.
import { randName } from 'randino';
randName({ language: 'ko', output: 'detail' });
// [{ native: '여미주', roman: 'Yeo Miju', language: 'ko', gender: 'female' }]import 'package:randino/randino.dart';
randNameDetails(language: NameLanguage.ko);
// [NameDetail(여미주, Yeo Miju, ko, female)]from randino import rand_name
rand_name(language="ko", output="detail")
# [NameDetail(native='여미주', roman='Yeo Miju', language='ko', gender='female')]Each entry is a NameDetail:
Each entry is a NameDetail:
Each entry is a NameDetail, a frozen dataclass:
| Field | Type | Description |
|---|---|---|
native | stringStringstr | The name in its own script. |
roman | stringStringstr | The English pronunciation of native. Identical to it for English. |
language | NameLanguage | The language this name was generated in — the reason to reach for this function when the draw is mixed. |
gender | NameGender | The pools the given name was drawn from. |
Examples
One language at a time
randName({ language: 'ko', count: 3 });
// ['김태윤', '원동혁', '조진우']
randName({ language: 'ja', count: 3 });
// ['山崎愛菜', '加藤楓乃', '吉田直人']
randName({ language: 'ru', count: 2 });
// ['Дмитрий Соколов', 'Полина Морозова']randName(language: NameLanguage.ko, count: 3);
// ['김태윤', '원동혁', '조진우']
randName(language: NameLanguage.ja, count: 3);
// ['山崎愛菜', '加藤楓乃', '吉田直人']
randName(language: NameLanguage.ru, count: 2);
// ['Дмитрий Соколов', 'Полина Морозова']rand_name(language="ko", count=3)
# ['김태윤', '원동혁', '조진우']
rand_name(language="ja", count=3)
# ['山崎愛菜', '加藤楓乃', '吉田直人']
rand_name(language="ru", count=2)
# ['Дмитрий Соколов', 'Полина Морозова']Leave the language out and every name comes from one of the nine, picked per name:
randName({ count: 5 });
// ['Nuria Ramírez', '조동민', 'Stella Reeves', 'Anna Mariani', 'Lê Phương']randName(count: 5);
// ['Nuria Ramírez', '조동민', 'Stella Reeves', 'Anna Mariani', 'Lê Phương']rand_name(count=5)
# ['Nuria Ramírez', '조동민', 'Stella Reeves', 'Anna Mariani', 'Lê Phương']The parts of a name
randName({ language: 'en', count: 3, includeSurname: false });
// ['Rachel', 'Eliza', 'Tessa']
randName({ language: 'en', count: 3, includeMiddleName: true });
// ['Danielle Sylvia Owens', 'Gloria Harriet Norton', 'Peyton Beatrix Owens']randName(language: NameLanguage.en, count: 3, includeSurname: false);
// ['Rachel', 'Eliza', 'Tessa']
randName(language: NameLanguage.en, count: 3, includeMiddleName: true);
// ['Danielle Sylvia Owens', 'Gloria Harriet Norton', 'Peyton Beatrix Owens']rand_name(language="en", count=3, include_surname=False)
# ['Rachel', 'Eliza', 'Tessa']
rand_name(language="en", count=3, include_middle_name=True)
# ['Danielle Sylvia Owens', 'Gloria Harriet Norton', 'Peyton Beatrix Owens']Korean, Japanese and Chinese have no middle part, so includeMiddleNameincludeMiddleNameinclude_middle_name is ignored for them rather than inventing one. nameSupportsMiddleName answers that directly.
Romanized output
randName({ language: 'ko', count: 3, script: 'roman' });
// ['Kim Minjun', 'Won Donghyeok', 'Jo Jinu']
randName({ language: 'ja', count: 3, script: 'roman' });
// ['Yamazaki Aina', 'Kato Kaeno', 'Yoshida Naoyato']randName(language: NameLanguage.ko, count: 3, script: NameScript.roman);
// ['Kim Minjun', 'Won Donghyeok', 'Jo Jinu']
randName(language: NameLanguage.ja, count: 3, script: NameScript.roman);
// ['Yamazaki Aina', 'Kato Kaeno', 'Yoshida Naoyato']rand_name(language="ko", count=3, script="roman")
# ['Kim Minjun', 'Won Donghyeok', 'Jo Jinu']
rand_name(language="ja", count=3, script="roman")
# ['Yamazaki Aina', 'Kato Kaeno', 'Yoshida Naoyato']English is the one language where this changes nothing, because the names are already in the Latin alphabet. nameSupportsRoman reports that.
A starting character
randName({ language: 'en', count: 3, startsWith: 'k' });
// ['Kayla Morgan', 'Keith Doyle', 'Kimberly Vaughn']randName(language: NameLanguage.en, count: 3, startsWith: 'k');
// ['Kayla Morgan', 'Keith Doyle', 'Kimberly Vaughn']rand_name(language="en", count=3, starts_with="k")
# ['Kayla Morgan', 'Keith Doyle', 'Kimberly Vaughn']A character no real name starts with still returns names rather than nothing: Latin and Cyrillic scripts invent one (Q → Qivu Railooth), and CJK scripts use the character as a name part of its own.
Length
randName({ language: 'en', count: 2, minLength: 20, maxLength: 25 });
// ['Josephine Adelaide Sinclair', 'Christina Genevieve Whitaker']randName(language: NameLanguage.en, count: 2, minLength: 20, maxLength: 25);
// ['Josephine Adelaide Sinclair', 'Christina Genevieve Whitaker']rand_name(language="en", count=2, min_length=20, max_length=25)
# ['Josephine Adelaide Sinclair', 'Christina Genevieve Whitaker']The structure you asked for always wins. A range too narrow for the requested parts is answered with the closest name the generator can build, never by dropping the surname or middle name. See how the options behave.
A name next to its pronunciation
for (const { native, roman } of randName({ language: 'ja', count: 3, output: 'detail' })) {
console.log(`${native} (${roman})`);
}
// 山崎愛菜 (Yamazaki Aina)
// 加藤楓乃 (Kato Kaeno)
// 吉田直人 (Yoshida Naoto)for (final detail in randNameDetails(language: NameLanguage.ja, count: 3)) {
print('${detail.native} (${detail.roman})');
}
// 山崎愛菜 (Yamazaki Aina)
// 加藤楓乃 (Kato Kaeno)
// 吉田直人 (Yoshida Naoto)for detail in rand_name(language="ja", count=3, output="detail"):
print(f"{detail.native} ({detail.roman})")
# 山崎愛菜 (Yamazaki Aina)
# 加藤楓乃 (Kato Kaeno)
# 吉田直人 (Yoshida Naoto)Knowing what a mixed draw produced
randName({ count: 3, output: 'detail' });
// [
// { native: '조동민', roman: 'Jo Dongmin', language: 'ko', gender: 'male' },
// { native: 'Anna Mariani', roman: 'Anna Mariani', language: 'it', gender: 'female' },
// { native: 'Иванов Иван', roman: 'Ivanov Ivan', language: 'ru', gender: 'male' }
// ]randNameDetails(count: 3);
// [
// NameDetail(조동민, Jo Dongmin, ko, male),
// NameDetail(Anna Mariani, Anna Mariani, it, female),
// NameDetail(Иванов Иван, Ivanov Ivan, ru, male),
// ]rand_name(count=3, output="detail")
# [
# NameDetail(native='조동민', roman='Jo Dongmin', language='ko', gender='male'),
# NameDetail(native='Anna Mariani', roman='Anna Mariani', language='it', gender='female'),
# NameDetail(native='Иванов Иван', roman='Ivanov Ivan', language='ru', gender='male'),
# ]Gender, where it is observable
Most languages do not show which pool a given name came from. Russian does, because its patronymic and its surname both inflect, which makes the choice verifiable there:
randName({ language: 'ru', gender: 'female', includeMiddleName: true, count: 2, output: 'detail' });
// [
// { native: 'Людмила Николаевна Богданова', roman: 'Lyudmila Nikolaevna Bogdanova', … },
// { native: 'Марина Максимовна Богданова', roman: 'Marina Maksimovna Bogdanova', … }
// ]randNameDetails(
language: NameLanguage.ru,
gender: NameGender.female,
includeMiddleName: true,
count: 2,
);
// [
// NameDetail(Людмила Николаевна Богданова, Lyudmila Nikolaevna Bogdanova, ru, female),
// NameDetail(Марина Максимовна Богданова, Marina Maksimovna Bogdanova, ru, female),
// ]rand_name(language="ru", gender="female", include_middle_name=True, count=2, output="detail")
# [
# NameDetail(native='Людмила Николаевна Богданова', roman='Lyudmila Nikolaevna Bogdanova', …),
# NameDetail(native='Марина Максимовна Богданова', roman='Marina Maksimovna Bogdanova', …),
# ]See also
- Supported languages — how each script becomes an English pronunciation.
nameLengthRange— the range a name falls back to.nameSupportsMiddleNameandnameSupportsRoman— the two questions about a language.