/// <summary> /// Code shamelessly copied from the base game and hopefully included there. /// Fixs the rules for def in GrammarUtility.RulesForDef. /// /// The main change is the use of gender.GetPossessive() instead of "Proits".Translate() /// in the last rule (This fix shoud apply to all languages). /// /// Specific to Portuguese: detect whether some def.label are in plural only /// Other language might add some specific symbols here if needed. /// </summary> /// <returns>The grammar rules for def.</returns> /// <param name="prefix">rules prefix.</param> /// <param name="def">Def.</param> public static IEnumerable <Rule> FixRulesForDef(string prefix, Def def) { if (def == null) { Log.ErrorOnce($"Tried to insert rule {prefix} for null def", 79641686); yield break; } LanguageWorker languageWorker = Find.ActiveLanguageWorker; Gender gender = LanguageDatabase.activeLanguage.ResolveGender(def.label); bool plural = DefLabel_InPlural.Contains(def.label); if (!prefix.NullOrEmpty()) { prefix += "_"; } yield return(new Rule_String(prefix + "label", def.label)); if (def is PawnKindDef) { yield return(new Rule_String(prefix + "labelPlural", ((PawnKindDef)def).GetLabelPlural())); } else { // Log to inspect the difference with the original rules yield return(new Rule_String(prefix + "labelPlural", plural ? def.label : languageWorker.Pluralize(def.label))); } yield return(new Rule_String(prefix + "description", def.description)); yield return(new Rule_String(prefix + "definite", languageWorker.WithDefiniteArticle(def.label, gender, plural))); yield return(new Rule_String(prefix + "indefinite", languageWorker.WithIndefiniteArticle(def.label, gender, plural))); // TODO: X_possessive for plural will only activate if the word is classified in WordInfo/Gender/Female.txt // RimWorld does not have keys for possessive plural so here it is : yield return(new Rule_String(prefix + "possessive", plural ? (gender == Gender.Female ? "suas" : "seus") : gender.GetPossessive())); }
/// <summary> /// Code shamelessly copied from the base game and hopefully included there. /// Fixs the rules for def in GrammarUtility.RulesForDef. /// /// The main change is the use of gender.GetPossessive() instead of "Proits".Translate() /// in the last rule (This fix shoud apply to all languages). /// /// Specific to Spanish: detect whether some def.label are in plural only /// Other language might add some specific symbols here if needed. /// </summary> /// <returns>The grammar rules for def.</returns> /// <param name="prefix">rules prefix.</param> /// <param name="def">Def.</param> public static IEnumerable <Rule> FixRulesForDef(string prefix, Def def) { if (def == null) { Log.ErrorOnce($"Tried to insert rule {prefix} for null def", 79641686); yield break; } LanguageWorker languageWorker = Find.ActiveLanguageWorker; Gender gender = LanguageDatabase.activeLanguage.ResolveGender(def.label); bool plural = DefLabel_InPlural.Contains(def.label); if (!prefix.NullOrEmpty()) { prefix += "_"; } yield return(new Rule_String(prefix + "label", def.label)); if (def is PawnKindDef) { yield return(new Rule_String(prefix + "labelPlural", ((PawnKindDef)def).GetLabelPlural())); } else { // Log to inspect the difference with the original rules yield return(new Rule_String(prefix + "labelPlural", plural ? def.label : languageWorker.Pluralize(def.label))); } yield return(new Rule_String(prefix + "description", def.description)); yield return(new Rule_String(prefix + "definite", languageWorker.WithDefiniteArticle(def.label, gender, plural))); yield return(new Rule_String(prefix + "indefinite", languageWorker.WithIndefiniteArticle(def.label, gender, plural))); // TODO: verify correctness of "sus" (de él, de ella, de ellos, de ellas) yield return(new Rule_String(prefix + "possessive", plural ? "sus" : gender.GetPossessive())); }