var relationMap = { '1': '父', '2': '母', '3': '祖父', '4': '祖母' }; var maritalStatusMap = { '0': '未知', '1': '未婚', '2': '已婚', '3': '离异/丧偶' }; var ancestorLabels = ['父/母', '祖父/祖母', '曾祖父', '高祖父', '天祖父', '烈祖父']; var childOrderNums = ['', '长', '次', '三', '四', '五', '六', '七', '八', '九', '十']; function getRelationText(relation) { return relationMap['' + relation] || ''; } function getSiblingType(relation) { var r = '' + relation; if (r === '11') return '兄'; if (r === '12') return '姐'; return '弟/妹'; } function getMaritalStatusText(status) { return maritalStatusMap['' + status] || '未知'; } function getAncestorLabel(depth) { var d = depth < 0 ? 0 : depth; if (d < ancestorLabels.length) return ancestorLabels[d]; return '第' + (d + 1) + '代祖先'; } function getChildOrderText(order) { if (!order || order < 1) return '子'; if (order < childOrderNums.length) return childOrderNums[order] + '子'; return order + '子'; } function shortName(name, simplified) { if (simplified && simplified !== name) { return name + '\n(' + simplified + ')'; } return name; } module.exports = { getRelationText: getRelationText, getSiblingType: getSiblingType, getMaritalStatusText: getMaritalStatusText, getAncestorLabel: getAncestorLabel, getChildOrderText: getChildOrderText, shortName: shortName };