In Progress Français The token {.l} does not work properly

Users who are viewing this thread

Version number
No, I didn't use any mods.


Sergeant Knight at Arms
Translation Error: L'empire a assiégé l'Onica
Corrected Translation: L'empire assiégé Onica
Where did you find this error (which conversation, screen, area,...)?: Trials

Hi TaleWorlds devs!

When reading the code of the token {.l}, I understood that the goal of this token is to put an article of type "le", "la" or "l'" (in English, "the") before the name of something: a faction, a group, a castle, etc.

For example, in French we write:
- "L'empire a assiégé les Kuzaïtes"
- "L'empire a assiégé le château d'Onica"
- "L'empire a assiégé Poros" (no article before a town name)
- "L'empire a assiégé Onica" (no article before a town name)

The way to generate such a sentence in French should be by writing "L'empire a assiégé {.l}{ITEM}", but unfortunately that doesn't work if ITEM is a town or a village whose name begins with a vowel:

Your code that deal with the token {.l} is written so that the article is generated only when the ITEM has a genre. When the token is {.l}, ProcessToken calls HandleDefiniteArticle(), that calls GetDefinititeArticle() that do this:

text2 = null
if (this._isPlural)
    text2 = FrenchTextProcessor._genderToDefiniteArticle[FrenchTextProcessor.WordType.Plural];
else if (this.CheckNextCharIsVowel(text, cursorPos) && !this.CheckIfNextWordShouldBeConsideredAConsonant(text, token, cursorPos))
    text2 = FrenchTextProcessor._genderToDefiniteArticle[FrenchTextProcessor.WordType.StartingWithaVowel];
else if (this._curGender != FrenchTextProcessor.WordGenderEnum.NoDeclination)
    text2 = FrenchTextProcessor._genderToDefiniteArticle[this.GetWordTypeFromGender(this._curGender)];

In pseudo language, and due to what returns FrenchTextProcessor._genderToDefiniteArticle[] :

If ITEM is plural, text2 = "les"
else if next char (first char of ITEM) is vowel, texte2 = "l'"
else if ITEM has a genre (M or F), text2 = "le" (M) ou "la" (F)
else text2 = ""

This is why I understand that an article is send back if ITEM has a genre, and nothing if it has no genre.
But there is mistake in the code: the fact that ITEM begins by a vowel or not must not be on the same level that the fact that it has a genre or not.
The code must FIRST determine if ITEM has a genre, and if yes, only AFTER determine which article must replace the token, because even if ITEM begins by a vowel, we don't put an article before it if it has no genre in Bannerlord point of view (as a town name). The code should be like that:

If ITEM has a genre (M or F)
    If ITEM is plural, text2 = "les"
    else if next char (first char of ITEM) is vowel, texte2 = "l'"
    else text2 = "le" (M) ou "la" (F)
else text2 = ""

If you change the code as indicated, the "l'" before Onica that has no genre shall not be present anymore, which is correct.

When this code shall be modified as above, you will discover that the expression {?settlementNeedsArticle(SETTLEMENT)}{.l}{?}{\?}{SETTLEMENT} for the token {.l} becomes useless, because all the castles and the hideouts have a defined genre in Bannerlord files and the towns and villages have not. So a sentence as
id="F8g1TzoX" text="L'empire a assiégé {.l}{SETTLEMENT_NAME}"
will always produce a correct result:
- If SETTLEMENT_NAME is a castle (genre M) -> "L'empire a assiégé le château d'Onica"
- If SETTLEMENT_NAME is a town (no genre) -> "L'empire a assiégé Onica"
No need anymore to use the function settlementNeedsArticle() to know if an article must be added or not, the token {.l} already answered this question!

Thanks for reading.
Top Bottom