public static string LivingPeople(string articleText, string articleTitle)
{
if (Variables.LangCode.Equals("sco") || Variables.IsWikimediaMonolingualProject)
return articleText;
Match m = WikiRegexes.BirthsCategory.Match(GetCats(articleText));
// do not add living people category unless 'XXXX births' category is present
if (!m.Success)
return articleText;
// do not add living people category if already dead, or thought to be dead
if (WikiRegexes.DeathsOrLivingCategory.IsMatch(articleText) || WikiRegexes.LivingPeopleRegex2.IsMatch(articleText) ||
Regex.IsMatch(articleText, BornDeathRegex.ToString().Replace("^", @"('''(?:[^']+|.*?[^'])'''\s*\()"))
|| Regex.IsMatch(articleText, DiedDateRegex.ToString().Replace("^", @"('''(?:[^']+|.*?[^'])'''\s*\()")))
return articleText;
string birthCat = m.Value;
int birthYear = 0;
string byear = m.Groups[1].Value;
if (ThreeOrMoreDigits.IsMatch(byear))
birthYear = int.Parse(byear);
// per [[:Category:Living people]] and [[WP:BDP]], do not apply if born > 115 years ago
if (birthYear < (DateTime.Now.Year - 115))
return articleText;
// use any sortkey from 'XXXX births' category
string catKey = birthCat.Contains("|") ? BirthsSortKey.Match(birthCat).Value : "]]";
return articleText + "[[" + (Namespace.IsMainSpace(articleTitle) ? "" : ":") + "Category:Living people" + catKey;
}