@treeviz/gedcom-parser 2.1.7 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/index.js +463 -4
- package/dist/classes/indi.d.ts +11 -1
- package/dist/classes/indi.d.ts.map +1 -1
- package/dist/cli/index.js +463 -4
- package/dist/constants/index.js +462 -3
- package/dist/factories/index.js +462 -3
- package/dist/index.js +464 -5
- package/dist/kinship-translator/index.d.ts +2 -0
- package/dist/kinship-translator/index.d.ts.map +1 -1
- package/dist/kinship-translator/index.js +463 -4
- package/dist/kinship-translator/kinship-translator.ja.d.ts +18 -0
- package/dist/kinship-translator/kinship-translator.ja.d.ts.map +1 -0
- package/dist/kinship-translator/kinship-translator.zh.d.ts +18 -0
- package/dist/kinship-translator/kinship-translator.zh.d.ts.map +1 -0
- package/dist/kinship-translator/patterns.ja.d.ts +2 -0
- package/dist/kinship-translator/patterns.ja.d.ts.map +1 -0
- package/dist/kinship-translator/patterns.zh.d.ts +2 -0
- package/dist/kinship-translator/patterns.zh.d.ts.map +1 -0
- package/dist/kinship-translator/translators.d.ts +2 -0
- package/dist/kinship-translator/translators.d.ts.map +1 -1
- package/dist/kinship-translator/types.d.ts +1 -1
- package/dist/kinship-translator/types.d.ts.map +1 -1
- package/dist/utils/index.js +463 -4
- package/package.json +1 -1
package/dist/factories/index.js
CHANGED
|
@@ -64,7 +64,9 @@ __export(translators_exports, {
|
|
|
64
64
|
es: () => KinshipTranslatorEs,
|
|
65
65
|
fr: () => KinshipTranslatorFr,
|
|
66
66
|
hu: () => KinshipTranslatorHU,
|
|
67
|
-
|
|
67
|
+
ja: () => KinshipTranslatorJa,
|
|
68
|
+
ru: () => KinshipTranslatorRu,
|
|
69
|
+
zh: () => KinshipTranslatorZh
|
|
68
70
|
});
|
|
69
71
|
|
|
70
72
|
// src/constants/filters.ts
|
|
@@ -4803,14 +4805,29 @@ var Indi = class extends Common {
|
|
|
4803
4805
|
getAkas(limit) {
|
|
4804
4806
|
return this.getFacts(limit, "AKA");
|
|
4805
4807
|
}
|
|
4808
|
+
/**
|
|
4809
|
+
* Collect event/attribute facts.
|
|
4810
|
+
* @param limit Max records per tag
|
|
4811
|
+
* @param filter Whitelist tags, or `{ include?, exclude? }`.
|
|
4812
|
+
* - string/array: include only these tags (and custom EVEN/FACT TYPE values)
|
|
4813
|
+
* - `{ exclude: ["BIRT","DEAT"] }`: all facts except those tags
|
|
4814
|
+
*/
|
|
4806
4815
|
getFacts(limit, filter) {
|
|
4807
|
-
const
|
|
4808
|
-
|
|
4816
|
+
const asList = (value) => (Array.isArray(value) ? value : [value]).filter(Boolean);
|
|
4817
|
+
const isFilterObject = !!filter && typeof filter === "object" && !Array.isArray(filter) && ("include" in filter || "exclude" in filter);
|
|
4818
|
+
const filters = asList(
|
|
4819
|
+
isFilterObject ? filter.include : filter
|
|
4820
|
+
);
|
|
4821
|
+
const excludes = asList(
|
|
4822
|
+
isFilterObject ? filter.exclude : void 0
|
|
4809
4823
|
);
|
|
4810
4824
|
const facts = new List();
|
|
4811
4825
|
let id = 0;
|
|
4812
4826
|
ALLOWED_FACTS.forEach((fact) => {
|
|
4813
4827
|
const isCustom = ["EVEN", "FACT"].includes(fact);
|
|
4828
|
+
if (excludes.length && excludes.includes(fact) && !isCustom) {
|
|
4829
|
+
return;
|
|
4830
|
+
}
|
|
4814
4831
|
if (filters.length && !filters.includes(fact) && !isCustom) {
|
|
4815
4832
|
return;
|
|
4816
4833
|
}
|
|
@@ -4833,6 +4850,9 @@ var Indi = class extends Common {
|
|
|
4833
4850
|
if (!type || DISALLOWED_CUSTOM_FACTS.includes(type)) {
|
|
4834
4851
|
return;
|
|
4835
4852
|
}
|
|
4853
|
+
if (excludes.length && excludes.includes(type)) {
|
|
4854
|
+
return;
|
|
4855
|
+
}
|
|
4836
4856
|
if (filters.length && !filters.includes(type) && isCustom) {
|
|
4837
4857
|
return;
|
|
4838
4858
|
}
|
|
@@ -7482,6 +7502,445 @@ var KinshipTranslatorRu = class extends KinshipTranslatorBasic {
|
|
|
7482
7502
|
}
|
|
7483
7503
|
};
|
|
7484
7504
|
|
|
7505
|
+
// src/kinship-translator/patterns.ja.ts
|
|
7506
|
+
var InLawsJa = {
|
|
7507
|
+
"(\u5B50|\u5A18|\u606F\u5B50)\u306E\u914D\u5076\u8005": "\u7FA9\u7406\u306E\u5B50",
|
|
7508
|
+
"(\u5B50|\u5A18|\u606F\u5B50)\u306E\u59BB": "\u5AC1",
|
|
7509
|
+
"(\u5B50|\u5A18|\u606F\u5B50)\u306E\u592B": "\u5A7F",
|
|
7510
|
+
"(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u6BCD": "\u7FA9\u6BCD",
|
|
7511
|
+
"(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u7236": "\u7FA9\u7236",
|
|
7512
|
+
"(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u89AA": "\u7FA9\u7406\u306E\u89AA",
|
|
7513
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u5144\u5F1F|\u59C9\u59B9|\u5144\u5F1F\u59C9\u59B9)\u306E\u59BB": "\u7FA9\u7406\u306E\u59C9\u59B9",
|
|
7514
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u5144\u5F1F|\u59C9\u59B9|\u5144\u5F1F\u59C9\u59B9)\u306E\u592B": "\u7FA9\u7406\u306E\u5144\u5F1F",
|
|
7515
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u5144\u5F1F|\u59C9\u59B9|\u5144\u5F1F\u59C9\u59B9)\u306E\u914D\u5076\u8005": "\u7FA9\u7406\u306E\u5144\u5F1F\u59C9\u59B9",
|
|
7516
|
+
"(\u7570\u7236\u6BCD\u306E)?\u59C9\u59B9\u306E(\u914D\u5076\u8005|\u59BB|\u592B)": "\u7FA9\u7406\u306E\u59C9\u59B9",
|
|
7517
|
+
"(\u7570\u7236\u6BCD\u306E)?\u5144\u5F1F\u306E(\u914D\u5076\u8005|\u59BB|\u592B)": "\u7FA9\u7406\u306E\u5144\u5F1F",
|
|
7518
|
+
"(\u7570\u7236\u6BCD\u306E)?\u5144\u5F1F\u59C9\u59B9\u306E(\u914D\u5076\u8005|\u59BB|\u592B)": "\u7FA9\u7406\u306E\u5144\u5F1F\u59C9\u59B9",
|
|
7519
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u59C9\u59B9": "\u7FA9\u7406\u306E\u59C9\u59B9",
|
|
7520
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u5144\u5F1F": "\u7FA9\u7406\u306E\u5144\u5F1F",
|
|
7521
|
+
"(\u7570\u7236\u6BCD\u306E)?(\u914D\u5076\u8005|\u59BB|\u592B)\u306E\u5144\u5F1F\u59C9\u59B9": "\u7FA9\u7406\u306E\u5144\u5F1F\u59C9\u59B9"
|
|
7522
|
+
};
|
|
7523
|
+
|
|
7524
|
+
// src/kinship-translator/kinship-translator.ja.ts
|
|
7525
|
+
var sexOf2 = (person) => {
|
|
7526
|
+
if (person?.isMale?.()) {
|
|
7527
|
+
return "m";
|
|
7528
|
+
}
|
|
7529
|
+
if (person?.isFemale?.()) {
|
|
7530
|
+
return "f";
|
|
7531
|
+
}
|
|
7532
|
+
return "n";
|
|
7533
|
+
};
|
|
7534
|
+
var pick = (sex, male, female, neutral) => {
|
|
7535
|
+
if (sex === "m") {
|
|
7536
|
+
return male;
|
|
7537
|
+
}
|
|
7538
|
+
if (sex === "f") {
|
|
7539
|
+
return female;
|
|
7540
|
+
}
|
|
7541
|
+
return neutral;
|
|
7542
|
+
};
|
|
7543
|
+
var lineal = (level, sex, kind) => {
|
|
7544
|
+
const L = Math.max(1, level);
|
|
7545
|
+
if (kind === "asc") {
|
|
7546
|
+
if (L <= 1) {
|
|
7547
|
+
return pick(sex, "\u7236", "\u6BCD", "\u89AA");
|
|
7548
|
+
}
|
|
7549
|
+
if (L === 2) {
|
|
7550
|
+
return pick(sex, "\u7956\u7236", "\u7956\u6BCD", "\u7956\u7236\u6BCD");
|
|
7551
|
+
}
|
|
7552
|
+
if (L === 3) {
|
|
7553
|
+
return pick(sex, "\u66FE\u7956\u7236", "\u66FE\u7956\u6BCD", "\u66FE\u7956\u7236\u6BCD");
|
|
7554
|
+
}
|
|
7555
|
+
if (L === 4) {
|
|
7556
|
+
return pick(sex, "\u9AD8\u7956\u7236", "\u9AD8\u7956\u6BCD", "\u9AD8\u7956\u7236\u6BCD");
|
|
7557
|
+
}
|
|
7558
|
+
return pick(
|
|
7559
|
+
sex,
|
|
7560
|
+
`${L - 1}\u4E16\u306E\u7956\u7236`,
|
|
7561
|
+
`${L - 1}\u4E16\u306E\u7956\u6BCD`,
|
|
7562
|
+
`${L - 1}\u4E16\u306E\u7956\u7236\u6BCD`
|
|
7563
|
+
);
|
|
7564
|
+
}
|
|
7565
|
+
if (L <= 1) {
|
|
7566
|
+
return pick(sex, "\u606F\u5B50", "\u5A18", "\u5B50");
|
|
7567
|
+
}
|
|
7568
|
+
if (L === 2) {
|
|
7569
|
+
return "\u5B6B";
|
|
7570
|
+
}
|
|
7571
|
+
if (L === 3) {
|
|
7572
|
+
return "\u66FE\u5B6B";
|
|
7573
|
+
}
|
|
7574
|
+
if (L === 4) {
|
|
7575
|
+
return "\u7384\u5B6B";
|
|
7576
|
+
}
|
|
7577
|
+
return `${L - 1}\u4E16\u306E\u5B6B`;
|
|
7578
|
+
};
|
|
7579
|
+
var cousinPlain = (degree) => {
|
|
7580
|
+
if (degree <= 1) {
|
|
7581
|
+
return "\u3044\u3068\u3053";
|
|
7582
|
+
}
|
|
7583
|
+
if (degree === 2) {
|
|
7584
|
+
return "\u307E\u305F\u3044\u3068\u3053";
|
|
7585
|
+
}
|
|
7586
|
+
if (degree === 3) {
|
|
7587
|
+
return "\u306F\u3068\u3053";
|
|
7588
|
+
}
|
|
7589
|
+
return `${degree}\u89AA\u7B49\u306E\u3044\u3068\u3053`;
|
|
7590
|
+
};
|
|
7591
|
+
var KinshipTranslatorJa = class extends KinshipTranslatorBasic {
|
|
7592
|
+
indirect() {
|
|
7593
|
+
let degree = Math.abs(this.pathN?.degree ?? 0);
|
|
7594
|
+
if (degree > 0) {
|
|
7595
|
+
degree = degree - 1;
|
|
7596
|
+
}
|
|
7597
|
+
return cousinPlain(degree);
|
|
7598
|
+
}
|
|
7599
|
+
removal() {
|
|
7600
|
+
const level = this.pathN?.level ?? 0;
|
|
7601
|
+
let degree = Math.abs(this.pathN?.degree ?? 0);
|
|
7602
|
+
if (degree > 0) {
|
|
7603
|
+
degree = degree - 1;
|
|
7604
|
+
}
|
|
7605
|
+
if (!degree) {
|
|
7606
|
+
return level < 0 ? this.nibling() : this.auncle();
|
|
7607
|
+
}
|
|
7608
|
+
const removed = Math.abs(level);
|
|
7609
|
+
return `${cousinPlain(degree)}\uFF08${removed}\u4E16\u4EE3\u9055\u3044\uFF09`;
|
|
7610
|
+
}
|
|
7611
|
+
auncle() {
|
|
7612
|
+
const level = Math.abs(this.pathN?.level ?? 0);
|
|
7613
|
+
const sex = sexOf2(this.personN);
|
|
7614
|
+
if (level <= 2) {
|
|
7615
|
+
return pick(sex, "\u304A\u3058", "\u304A\u3070", "\u304A\u3058/\u304A\u3070");
|
|
7616
|
+
}
|
|
7617
|
+
if (level === 3) {
|
|
7618
|
+
return pick(sex, "\u5927\u304A\u3058", "\u5927\u304A\u3070", "\u5927\u304A\u3058/\u5927\u304A\u3070");
|
|
7619
|
+
}
|
|
7620
|
+
return pick(
|
|
7621
|
+
sex,
|
|
7622
|
+
`${level - 2}\u4EE3\u524D\u306E\u304A\u3058`,
|
|
7623
|
+
`${level - 2}\u4EE3\u524D\u306E\u304A\u3070`,
|
|
7624
|
+
`${level - 2}\u4EE3\u524D\u306E\u304A\u3058/\u304A\u3070`
|
|
7625
|
+
);
|
|
7626
|
+
}
|
|
7627
|
+
nibling() {
|
|
7628
|
+
const level = Math.abs(this.pathN?.level ?? 0);
|
|
7629
|
+
const sex = sexOf2(this.personN);
|
|
7630
|
+
if (level <= 2) {
|
|
7631
|
+
return pick(sex, "\u7525", "\u59EA", "\u7525/\u59EA");
|
|
7632
|
+
}
|
|
7633
|
+
if (level === 3) {
|
|
7634
|
+
return pick(sex, "\u5927\u7525", "\u5927\u59EA", "\u5927\u7525/\u5927\u59EA");
|
|
7635
|
+
}
|
|
7636
|
+
return pick(
|
|
7637
|
+
sex,
|
|
7638
|
+
`${level - 2}\u4EE3\u4E0B\u306E\u7525`,
|
|
7639
|
+
`${level - 2}\u4EE3\u4E0B\u306E\u59EA`,
|
|
7640
|
+
`${level - 2}\u4EE3\u4E0B\u306E\u7525/\u59EA`
|
|
7641
|
+
);
|
|
7642
|
+
}
|
|
7643
|
+
parent() {
|
|
7644
|
+
return lineal(
|
|
7645
|
+
Math.abs(this.pathN?.level ?? 0),
|
|
7646
|
+
sexOf2(this.personN),
|
|
7647
|
+
"asc"
|
|
7648
|
+
);
|
|
7649
|
+
}
|
|
7650
|
+
child() {
|
|
7651
|
+
return lineal(
|
|
7652
|
+
Math.abs(this.pathN?.level ?? 0),
|
|
7653
|
+
sexOf2(this.personN),
|
|
7654
|
+
"desc"
|
|
7655
|
+
);
|
|
7656
|
+
}
|
|
7657
|
+
sibling() {
|
|
7658
|
+
return pick(sexOf2(this.personN), "\u5144\u5F1F", "\u59C9\u59B9", "\u5144\u5F1F\u59C9\u59B9");
|
|
7659
|
+
}
|
|
7660
|
+
halfBlood(relation) {
|
|
7661
|
+
if (!relation || !this.isHalfBlood) {
|
|
7662
|
+
return relation ?? "";
|
|
7663
|
+
}
|
|
7664
|
+
return `\u7570\u7236\u6BCD\u306E${relation}`;
|
|
7665
|
+
}
|
|
7666
|
+
spouse() {
|
|
7667
|
+
return pick(sexOf2(this.personN), "\u592B", "\u59BB", "\u914D\u5076\u8005");
|
|
7668
|
+
}
|
|
7669
|
+
ofSpouse(relation) {
|
|
7670
|
+
if (!relation) {
|
|
7671
|
+
return "";
|
|
7672
|
+
}
|
|
7673
|
+
const spouseType = pick(
|
|
7674
|
+
sexOf2(this.path?.[1].indi),
|
|
7675
|
+
"\u592B",
|
|
7676
|
+
"\u59BB",
|
|
7677
|
+
"\u914D\u5076\u8005"
|
|
7678
|
+
);
|
|
7679
|
+
return `${spouseType}\u306E${relation}`;
|
|
7680
|
+
}
|
|
7681
|
+
spouseOf(relation) {
|
|
7682
|
+
if (!relation) {
|
|
7683
|
+
return "";
|
|
7684
|
+
}
|
|
7685
|
+
const spouse = this.path?.[this.path.length - 1].indi;
|
|
7686
|
+
const spouseType = pick(sexOf2(spouse), "\u592B", "\u59BB", "\u914D\u5076\u8005");
|
|
7687
|
+
return `${relation}\u306E${spouseType}`;
|
|
7688
|
+
}
|
|
7689
|
+
of(relation) {
|
|
7690
|
+
const formattedName = nameFormatter(this.path?.[0]?.indi, {
|
|
7691
|
+
nameOrder: "last-first"
|
|
7692
|
+
});
|
|
7693
|
+
let name = formattedName.inOrder.filter(Boolean).join(" ");
|
|
7694
|
+
if (this.displayName === "none") {
|
|
7695
|
+
name = "";
|
|
7696
|
+
} else if (this.displayName === "givenname") {
|
|
7697
|
+
name = formattedName.givenname;
|
|
7698
|
+
} else if (this.displayName === "surname") {
|
|
7699
|
+
name = `${formattedName.surname}`;
|
|
7700
|
+
}
|
|
7701
|
+
if (!name || !relation) {
|
|
7702
|
+
return relation ?? "";
|
|
7703
|
+
}
|
|
7704
|
+
return `${name}\u306E${relation}`;
|
|
7705
|
+
}
|
|
7706
|
+
inLaw(relation) {
|
|
7707
|
+
let inLawRelation = relation;
|
|
7708
|
+
Object.keys(InLawsJa).find((pattern) => {
|
|
7709
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
7710
|
+
if (relation?.match(regex)) {
|
|
7711
|
+
inLawRelation = InLawsJa[pattern];
|
|
7712
|
+
return true;
|
|
7713
|
+
}
|
|
7714
|
+
return false;
|
|
7715
|
+
});
|
|
7716
|
+
return inLawRelation ?? "";
|
|
7717
|
+
}
|
|
7718
|
+
relationType(relation) {
|
|
7719
|
+
if (!relation || !this.pathN?.relation) {
|
|
7720
|
+
return relation ?? "";
|
|
7721
|
+
}
|
|
7722
|
+
return `${this.pathN.relation}\u306E${relation}`;
|
|
7723
|
+
}
|
|
7724
|
+
};
|
|
7725
|
+
|
|
7726
|
+
// src/kinship-translator/patterns.zh.ts
|
|
7727
|
+
var InLawsZh = {
|
|
7728
|
+
"(\u5B50\u5973|\u5973\u513F|\u513F\u5B50)\u7684\u914D\u5076": "\u513F\u5AB3/\u5973\u5A7F",
|
|
7729
|
+
"(\u5B50\u5973|\u5973\u513F|\u513F\u5B50)\u7684\u59BB\u5B50": "\u513F\u5AB3",
|
|
7730
|
+
"(\u5B50\u5973|\u5973\u513F|\u513F\u5B50)\u7684\u4E08\u592B": "\u5973\u5A7F",
|
|
7731
|
+
"(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u6BCD\u4EB2": "\u5CB3\u6BCD/\u5A46\u5A46",
|
|
7732
|
+
"(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u7236\u4EB2": "\u5CB3\u7236/\u516C\u516C",
|
|
7733
|
+
"(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u7236\u6BCD": "\u5CB3\u7236\u5CB3\u6BCD/\u516C\u516C\u5A46\u5A46",
|
|
7734
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u5144\u5F1F\u59D0\u59B9|\u59D0\u59B9|\u5144\u5F1F)\u7684\u59BB\u5B50": "\u5AC2\u5B50/\u5F1F\u59B9",
|
|
7735
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u5144\u5F1F\u59D0\u59B9|\u59D0\u59B9|\u5144\u5F1F)\u7684\u4E08\u592B": "\u59D0\u592B/\u59B9\u592B",
|
|
7736
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u5144\u5F1F\u59D0\u59B9|\u59D0\u59B9|\u5144\u5F1F)\u7684\u914D\u5076": "\u59FB\u4EB2\u5144\u5F1F\u59D0\u59B9",
|
|
7737
|
+
"(\u5F02\u7236\u6BCD\u7684)?\u59D0\u59B9\u7684(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)": "\u59D0\u592B/\u59B9\u592B",
|
|
7738
|
+
"(\u5F02\u7236\u6BCD\u7684)?\u5144\u5F1F\u7684(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)": "\u5AC2\u5B50/\u5F1F\u59B9",
|
|
7739
|
+
"(\u5F02\u7236\u6BCD\u7684)?\u5144\u5F1F\u59D0\u59B9\u7684(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)": "\u59FB\u4EB2\u5144\u5F1F\u59D0\u59B9",
|
|
7740
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u59D0\u59B9": "\u59D1\u5B50/\u59E8\u5B50",
|
|
7741
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u5144\u5F1F": "\u5927\u4F2F/\u5C0F\u53D4/\u5185\u5144/\u5185\u5F1F",
|
|
7742
|
+
"(\u5F02\u7236\u6BCD\u7684)?(\u914D\u5076|\u59BB\u5B50|\u4E08\u592B)\u7684\u5144\u5F1F\u59D0\u59B9": "\u59FB\u4EB2\u5144\u5F1F\u59D0\u59B9"
|
|
7743
|
+
};
|
|
7744
|
+
|
|
7745
|
+
// src/kinship-translator/kinship-translator.zh.ts
|
|
7746
|
+
var sexOf3 = (person) => {
|
|
7747
|
+
if (person?.isMale?.()) {
|
|
7748
|
+
return "m";
|
|
7749
|
+
}
|
|
7750
|
+
if (person?.isFemale?.()) {
|
|
7751
|
+
return "f";
|
|
7752
|
+
}
|
|
7753
|
+
return "n";
|
|
7754
|
+
};
|
|
7755
|
+
var pick2 = (sex, male, female, neutral) => {
|
|
7756
|
+
if (sex === "m") {
|
|
7757
|
+
return male;
|
|
7758
|
+
}
|
|
7759
|
+
if (sex === "f") {
|
|
7760
|
+
return female;
|
|
7761
|
+
}
|
|
7762
|
+
return neutral;
|
|
7763
|
+
};
|
|
7764
|
+
var lineal2 = (level, sex, kind) => {
|
|
7765
|
+
const L = Math.max(1, level);
|
|
7766
|
+
if (kind === "asc") {
|
|
7767
|
+
if (L <= 1) {
|
|
7768
|
+
return pick2(sex, "\u7236\u4EB2", "\u6BCD\u4EB2", "\u7236\u6BCD");
|
|
7769
|
+
}
|
|
7770
|
+
if (L === 2) {
|
|
7771
|
+
return pick2(sex, "\u7956\u7236", "\u7956\u6BCD", "\u7956\u7236\u6BCD");
|
|
7772
|
+
}
|
|
7773
|
+
if (L === 3) {
|
|
7774
|
+
return pick2(sex, "\u66FE\u7956\u7236", "\u66FE\u7956\u6BCD", "\u66FE\u7956\u7236\u6BCD");
|
|
7775
|
+
}
|
|
7776
|
+
if (L === 4) {
|
|
7777
|
+
return pick2(sex, "\u9AD8\u7956\u7236", "\u9AD8\u7956\u6BCD", "\u9AD8\u7956\u7236\u6BCD");
|
|
7778
|
+
}
|
|
7779
|
+
return pick2(sex, `${L}\u4E16\u7956`, `${L}\u4E16\u7956\u6BCD`, `${L}\u4E16\u7956\u7236\u6BCD`);
|
|
7780
|
+
}
|
|
7781
|
+
if (L <= 1) {
|
|
7782
|
+
return pick2(sex, "\u513F\u5B50", "\u5973\u513F", "\u5B50\u5973");
|
|
7783
|
+
}
|
|
7784
|
+
if (L === 2) {
|
|
7785
|
+
return pick2(sex, "\u5B59\u5B50", "\u5B59\u5973", "\u5B59\u5B50\u5973");
|
|
7786
|
+
}
|
|
7787
|
+
if (L === 3) {
|
|
7788
|
+
return pick2(sex, "\u66FE\u5B59", "\u66FE\u5B59\u5973", "\u66FE\u5B59\u5B50\u5973");
|
|
7789
|
+
}
|
|
7790
|
+
if (L === 4) {
|
|
7791
|
+
return pick2(sex, "\u7384\u5B59", "\u7384\u5B59\u5973", "\u7384\u5B59\u5B50\u5973");
|
|
7792
|
+
}
|
|
7793
|
+
return pick2(sex, `${L}\u4E16\u5B59`, `${L}\u4E16\u5B59\u5973`, `${L}\u4E16\u5B59\u5B50\u5973`);
|
|
7794
|
+
};
|
|
7795
|
+
var cousinPlain2 = (degree, sex) => {
|
|
7796
|
+
if (degree <= 1) {
|
|
7797
|
+
return pick2(sex, "\u5802\u8868\u5144\u5F1F", "\u5802\u8868\u59D0\u59B9", "\u5802\u8868\u4EB2");
|
|
7798
|
+
}
|
|
7799
|
+
if (degree === 2) {
|
|
7800
|
+
return pick2(sex, "\u4ECE\u5802\u8868\u5144\u5F1F", "\u4ECE\u5802\u8868\u59D0\u59B9", "\u4ECE\u5802\u8868\u4EB2");
|
|
7801
|
+
}
|
|
7802
|
+
return pick2(
|
|
7803
|
+
sex,
|
|
7804
|
+
`${degree}\u4EE3\u5802\u8868\u5144\u5F1F`,
|
|
7805
|
+
`${degree}\u4EE3\u5802\u8868\u59D0\u59B9`,
|
|
7806
|
+
`${degree}\u4EE3\u5802\u8868\u4EB2`
|
|
7807
|
+
);
|
|
7808
|
+
};
|
|
7809
|
+
var KinshipTranslatorZh = class extends KinshipTranslatorBasic {
|
|
7810
|
+
indirect() {
|
|
7811
|
+
let degree = Math.abs(this.pathN?.degree ?? 0);
|
|
7812
|
+
if (degree > 0) {
|
|
7813
|
+
degree = degree - 1;
|
|
7814
|
+
}
|
|
7815
|
+
return cousinPlain2(degree, sexOf3(this.personN));
|
|
7816
|
+
}
|
|
7817
|
+
removal() {
|
|
7818
|
+
const level = this.pathN?.level ?? 0;
|
|
7819
|
+
let degree = Math.abs(this.pathN?.degree ?? 0);
|
|
7820
|
+
if (degree > 0) {
|
|
7821
|
+
degree = degree - 1;
|
|
7822
|
+
}
|
|
7823
|
+
if (!degree) {
|
|
7824
|
+
return level < 0 ? this.nibling() : this.auncle();
|
|
7825
|
+
}
|
|
7826
|
+
const removed = Math.abs(level);
|
|
7827
|
+
return `${cousinPlain2(degree, sexOf3(this.personN))}\uFF08\u9694${removed}\u4EE3\uFF09`;
|
|
7828
|
+
}
|
|
7829
|
+
auncle() {
|
|
7830
|
+
const level = Math.abs(this.pathN?.level ?? 0);
|
|
7831
|
+
const sex = sexOf3(this.personN);
|
|
7832
|
+
if (level <= 2) {
|
|
7833
|
+
return pick2(sex, "\u53D4\u53D4", "\u963F\u59E8", "\u53D4\u4F2F/\u59D1\u59E8");
|
|
7834
|
+
}
|
|
7835
|
+
if (level === 3) {
|
|
7836
|
+
return pick2(sex, "\u4F2F\u53D4\u7956\u7236", "\u59D1\u7956\u6BCD", "\u4F2F\u53D4\u7956\u7236\u6BCD");
|
|
7837
|
+
}
|
|
7838
|
+
return pick2(
|
|
7839
|
+
sex,
|
|
7840
|
+
`${level - 2}\u4EE3\u524D\u7684\u53D4\u53D4`,
|
|
7841
|
+
`${level - 2}\u4EE3\u524D\u7684\u963F\u59E8`,
|
|
7842
|
+
`${level - 2}\u4EE3\u524D\u7684\u53D4\u4F2F/\u59D1\u59E8`
|
|
7843
|
+
);
|
|
7844
|
+
}
|
|
7845
|
+
nibling() {
|
|
7846
|
+
const level = Math.abs(this.pathN?.level ?? 0);
|
|
7847
|
+
const sex = sexOf3(this.personN);
|
|
7848
|
+
if (level <= 2) {
|
|
7849
|
+
return pick2(sex, "\u4F84\u5B50", "\u4F84\u5973", "\u4F84\u5B50\u5973");
|
|
7850
|
+
}
|
|
7851
|
+
if (level === 3) {
|
|
7852
|
+
return pick2(sex, "\u4F84\u5B59", "\u4F84\u5B59\u5973", "\u4F84\u5B59\u5B50\u5973");
|
|
7853
|
+
}
|
|
7854
|
+
return pick2(
|
|
7855
|
+
sex,
|
|
7856
|
+
`${level - 2}\u4EE3\u4E0B\u7684\u4F84\u5B50`,
|
|
7857
|
+
`${level - 2}\u4EE3\u4E0B\u7684\u4F84\u5973`,
|
|
7858
|
+
`${level - 2}\u4EE3\u4E0B\u7684\u4F84\u5B50\u5973`
|
|
7859
|
+
);
|
|
7860
|
+
}
|
|
7861
|
+
parent() {
|
|
7862
|
+
return lineal2(
|
|
7863
|
+
Math.abs(this.pathN?.level ?? 0),
|
|
7864
|
+
sexOf3(this.personN),
|
|
7865
|
+
"asc"
|
|
7866
|
+
);
|
|
7867
|
+
}
|
|
7868
|
+
child() {
|
|
7869
|
+
return lineal2(
|
|
7870
|
+
Math.abs(this.pathN?.level ?? 0),
|
|
7871
|
+
sexOf3(this.personN),
|
|
7872
|
+
"desc"
|
|
7873
|
+
);
|
|
7874
|
+
}
|
|
7875
|
+
sibling() {
|
|
7876
|
+
return pick2(sexOf3(this.personN), "\u5144\u5F1F", "\u59D0\u59B9", "\u5144\u5F1F\u59D0\u59B9");
|
|
7877
|
+
}
|
|
7878
|
+
halfBlood(relation) {
|
|
7879
|
+
if (!relation || !this.isHalfBlood) {
|
|
7880
|
+
return relation ?? "";
|
|
7881
|
+
}
|
|
7882
|
+
return `\u5F02\u7236\u6BCD\u7684${relation}`;
|
|
7883
|
+
}
|
|
7884
|
+
spouse() {
|
|
7885
|
+
return pick2(sexOf3(this.personN), "\u4E08\u592B", "\u59BB\u5B50", "\u914D\u5076");
|
|
7886
|
+
}
|
|
7887
|
+
ofSpouse(relation) {
|
|
7888
|
+
if (!relation) {
|
|
7889
|
+
return "";
|
|
7890
|
+
}
|
|
7891
|
+
const spouseType = pick2(
|
|
7892
|
+
sexOf3(this.path?.[1].indi),
|
|
7893
|
+
"\u4E08\u592B",
|
|
7894
|
+
"\u59BB\u5B50",
|
|
7895
|
+
"\u914D\u5076"
|
|
7896
|
+
);
|
|
7897
|
+
return `${spouseType}\u7684${relation}`;
|
|
7898
|
+
}
|
|
7899
|
+
spouseOf(relation) {
|
|
7900
|
+
if (!relation) {
|
|
7901
|
+
return "";
|
|
7902
|
+
}
|
|
7903
|
+
const spouse = this.path?.[this.path.length - 1].indi;
|
|
7904
|
+
const spouseType = pick2(sexOf3(spouse), "\u4E08\u592B", "\u59BB\u5B50", "\u914D\u5076");
|
|
7905
|
+
return `${relation}\u7684${spouseType}`;
|
|
7906
|
+
}
|
|
7907
|
+
of(relation) {
|
|
7908
|
+
const formattedName = nameFormatter(this.path?.[0]?.indi, {
|
|
7909
|
+
nameOrder: "last-first"
|
|
7910
|
+
});
|
|
7911
|
+
let name = formattedName.inOrder.filter(Boolean).join(" ");
|
|
7912
|
+
if (this.displayName === "none") {
|
|
7913
|
+
name = "";
|
|
7914
|
+
} else if (this.displayName === "givenname") {
|
|
7915
|
+
name = formattedName.givenname;
|
|
7916
|
+
} else if (this.displayName === "surname") {
|
|
7917
|
+
name = `${formattedName.surname}`;
|
|
7918
|
+
}
|
|
7919
|
+
if (!name || !relation) {
|
|
7920
|
+
return relation ?? "";
|
|
7921
|
+
}
|
|
7922
|
+
return `${name}\u7684${relation}`;
|
|
7923
|
+
}
|
|
7924
|
+
inLaw(relation) {
|
|
7925
|
+
let inLawRelation = relation;
|
|
7926
|
+
Object.keys(InLawsZh).find((pattern) => {
|
|
7927
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
7928
|
+
if (relation?.match(regex)) {
|
|
7929
|
+
inLawRelation = InLawsZh[pattern];
|
|
7930
|
+
return true;
|
|
7931
|
+
}
|
|
7932
|
+
return false;
|
|
7933
|
+
});
|
|
7934
|
+
return inLawRelation ?? "";
|
|
7935
|
+
}
|
|
7936
|
+
relationType(relation) {
|
|
7937
|
+
if (!relation || !this.pathN?.relation) {
|
|
7938
|
+
return relation ?? "";
|
|
7939
|
+
}
|
|
7940
|
+
return `${this.pathN.relation}${relation}`;
|
|
7941
|
+
}
|
|
7942
|
+
};
|
|
7943
|
+
|
|
7485
7944
|
// src/kinship-translator/kinship-translator.ts
|
|
7486
7945
|
var KinshipTranslator = class {
|
|
7487
7946
|
constructor(person1, person2, lang = "en", entirePath, displayName = "givenname") {
|