Language support for mobs, npc templates, ...

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

Re: Language support for mobs, npc templates, ...

Postby Graveen » Wed Oct 27, 2010 11:21 am

Let's stick to my last post, refering to design.

One table per object type. You organise them in the following manner:

0 ) the server, via a serverproperty, tell the available additional languages. You choose your language with /language command
1 ) One row per translation. The mandatory field: KEY, LANGUAGE, TRANSLATION. The couple (KEY, LANGUAGE) lead you to the translation.
2 ) KEY is object dependant. Item is name, Mob is either mob name or npctemplate name. Server is the old KEY (GamePlayer.CantUseMount in example)
3 ) you can add the field you think necessary. For items, i suggest USE, USE2 and DESCRIPTION. For mobs, you can add GUILD *if* you find it suitable
4 ) the /gmtranslate command should allows you to translate from ingame a given target
5 ) a converter 'll be interesting to stick to this language
6 ) in game code search the tables for the (KEY, LANG) couple. I suggest you to use a ToString() override. So a mob / item name will be changed before the packet is send, depending of the client.
7 ) you 'll be forced to cache the result, but this is done in DOLDatabase without having to change a single codeline
8 ) interesting if /language refresh reload the cache

i'll try to catch you on chat !
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Language support for mobs, npc templates, ...

Postby Apo » Thu Oct 28, 2010 8:14 am

irc?
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany

Re: Language support for mobs, npc templates, ...

Postby Graveen » Thu Oct 28, 2010 8:16 am

irc, msn, i guess the point is to meet :)
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Language support for mobs, npc templates, ...

Postby Apo » Thu Oct 28, 2010 8:19 am

i am connected to the #dolserver irc channel
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany

Re: Language support for mobs, npc templates, ...

Postby Apo » Thu Oct 28, 2010 3:23 pm

Ok, after speaking with graveen, we agreed that the language manager will no longer use dictionarys to pre cache data and will use database querys Instead (thats the best way an language system can have, because it gets his data from database).

The next thing is that the language manager will return translated strings only. that means, that each method can replace paramaters for it's self:

string somewhat = LanguageMgr.GetTranslation(client, eTranslationKey.SystemText, "You have entered {sourcezone}");
somewhat.replace("{sourcezone}", LanguageMgr.GetTranslation(client, eTranslationKey.ZoneName, plr.currentZone.description);

and send it to the player.

I think you already see it: the english language will return to his methods. In that way (if no translation was found) we ALWAYS have an english text, because the english text (for npcs and objects the name/guild name) will be the translation id. The code for the language manager is almost done and after this I will adjust all methods.

The eTranslationKey enumerator currently contains:
AreaName, AreaScreen, ItemName, NPCName, NPCGuild, ObjectName, SystemText, ZoneName, ZoneScreen

If you have an idea what is missing, tell it me (quests members missing, I know). All of this members will point to an specific database.

Shall the language file support be removed from DOL, or still an part of it?
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany

Re: Language support for mobs, npc templates, ...

Postby Graveen » Thu Oct 28, 2010 3:38 pm

Well, for legacy issue, it 'll live with DOL, then being removed.
I think i'll keep the file, then force use db language support; in this way, every new text file sentence will be converted to db language table.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Language support for mobs, npc templates, ...

Postby Apo » Thu Oct 28, 2010 4:28 pm

Here is a little example how it looks like for areas:

Code: Select all
string translation = LanguageMgr.GetTranslation(player.Client, eTranslationKey.SystemText, "(Region) You have entered {sourcearea}");
translation = translation.Replace("{sourcearea}", LanguageMgr.GetTranslation(player.Client, eTranslationKey.AreaName, Description));

player.Out.SendMessage(translation, eChatType.CT_System, eChatLoc.CL_SystemWindow);

//Changed by Apo 9. August 2010: Areas never send an screen description, but we will support it with an server property
if (ServerProperties.Properties.DISPLAY_AREA_ENTER_SCREEN_DESC)
{
   translation = LanguageMgr.GetTranslation(player.Client, eTranslationKey.AreaScreen, Description);
   player.Out.SendMessage(translation, eChatType.CT_ScreenCenterSmaller, eChatLoc.CL_SystemWindow);
}


The table for quest translation will look like: TranslationId, Text, Language - so we can store all questtexts in this table without sort it by title or something else.
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany

Re: Language support for mobs, npc templates, ...

Postby Apo » Thu Oct 28, 2010 5:22 pm

For system texts:

Code: Select all
        /// <summary>
        /// The special column text. This column is used to differentiate between two or more objects.
        /// For players we have 2 titles: Male and Female. For this, the special column is used to select the correct gender.
        /// </summary>
        [DataElement(AllowDbNull = false)]
        public string SpecialColumn
        {
            get { return m_specialColumnText; }
            set
            {
                Dirty = true;
                m_specialColumnText = value;
            }
        }


Ok? Bad? What the f*** are you doing?
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany

Re: Language support for mobs, npc templates, ...

Postby Graveen » Fri Oct 29, 2010 1:08 pm

Apo, for quests, i suggest you rely on DataQuest table - Language_x_Quest KEY will reference the DataQuest_Id, and do not care of scripted ones.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Language support for mobs, npc templates, ...

Postby Apo » Fri Oct 29, 2010 2:18 pm

Can you tell me what the difference between this both methods is?

GamePlayer.cs
Code: Select all
      /// <summary>
      /// Pronoun of this player in case you need to refer it in 3rd person
      /// http://webster.commnet.edu/grammar/cases.htm
      /// </summary>
      /// <param name="firstLetterUppercase"></param>
      /// <param name="form">0=Subjective, 1=Possessive, 2=Objective</param>
      /// <returns>pronoun of this object</returns>
      public override string GetPronoun(int form, bool firstLetterUppercase)
      {
         if (DBCharacter.Gender == 0) // male
            switch (form)
         {
            default:
               // Subjective
               if (firstLetterUppercase)
                  return "He";
               else
                  return "he";
            case 1:
               // Possessive
               if (firstLetterUppercase)
                  return "His";
               else
                  return "his";
            case 2:
               // Objective
               if (firstLetterUppercase)
                  return "Him";
               else
                  return "him";
         }
         else
            // female
            switch (form)
         {
            default:
               // Subjective
               if (firstLetterUppercase)
                  return "She";
               else
                  return "she";
            case 1:
               // Possessive
               if (firstLetterUppercase)
                  return "Her";
               else
                  return "her";
            case 2:
               // Objective
               if (firstLetterUppercase)
                  return "Her";
               else
                  return "her";
         }
      }

      public string GetPronoun(GameClient Client, int form, bool capitalize)
      {
         if (DBCharacter.Gender == 0)
            switch (form)
         {
            default:
                    return Capitalize(capitalize, LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "he", "PronounMaleSubjective" /*Hold it unique in database*/));
            case 1:
                    return Capitalize(capitalize, LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "his", "PronounMalePossessive" /*Hold it unique in database*/));
            case 2:
                    return Capitalize(capitalize, LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "him", "PronounMaleObjective" /*Hold it unique in database*/));
         }
         else
            switch (form)
         {
            default:
                    return Capitalize(capitalize, LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "she", "PronounFemaleSubjective" /*Hold it unique in database*/));
            case 1:
                    return Capitalize(capitalize, LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "her", "PronounFemalePossessive" /*Hold it unique in database*/));
            case 2:
                    return Capitalize(capitalize, LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "her", "PronounFemaleObjective" /*Hold it unique in database*/));
         }
      }


Both methods return the first letter as lower / upper.
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany

Re: Language support for mobs, npc templates, ...

Postby Graveen » Fri Oct 29, 2010 2:33 pm

Second seems nice !
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Language support for mobs, npc templates, ...

Postby Apo » Fri Oct 29, 2010 3:09 pm

An so it can look like if you want to translate a "big" text

Code: Select all
               string modmessage = "";
               if (ad.Modifier > 0) modmessage = " (+" + ad.Modifier + ")";
               if (ad.Modifier < 0) modmessage = " (" + ad.Modifier + ")";

                    string hitWeapon = LanguageMgr.GetTranslation(Client, eTranslationKey.ItemName, weapon.Name, "");

                    if (hitWeapon.Length > 0)
                        hitWeapon = LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "with your", "AttackTypeWithYour" /*Hold it unique in database*/) + " " + hitWeapon;

                    string attackTypeMsg = LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "You attack", "AttackTypeYouAttack"); //Hold it unique in database
               if (ActiveWeaponSlot == eActiveWeaponSlot.Distance)
                        attackTypeMsg = LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "You shot", "AttackTypeYouShot"); //Hold it unique in database

               // intercept messages
                    if (target != null && target != ad.Target)
                    {
                        translation = LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "{sourcename} steps in front of {sourcetarget} and takes the blow!", "");
                        if (ad.Target is GamePlayer)
                            translation = translation.Replace("{sourcename}", ad.Target.Name);
                        else
                            translation = translation.Replace("{sourcename}", ad.Target.GetName(0, true));
                        if (target is GamePlayer)
                            translation = translation.Replace("{sourcetarget}", ad.Target.Name);
                        else
                            translation = translation.Replace("{sourcetarget}", target.GetName(0, false));
                        Out.SendMessage(translation, eChatType.CT_YouHit, eChatLoc.CL_SystemWindow);

                        translation = LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "{sourcetype} {sourcename} {sourceitem} but hit {sourcetarget} for {damagetaken}{extradamage} damage!", "");
                        translation = translation.Replace("{sourcetype}", attackTypeMsg);
                        if (target is GamePlayer)
                            translation = translation.Replace("{sourcename}", target.Name);
                        else
                            translation = translation.Replace("{sourcename}", target.GetName(0, false));
                        translation = translation.Replace("{sourceitem}", hitWeapon);
                        if(ad.Target is GamePlayer)
                            translation = translation.Replace("{sourcename}", ad.Target.Name);
                        else
                            translation = translation.Replace("{sourcename}", ad.Target.GetName(0, false));
                        translation = translation.Replace("{damagetaken}", ad.Damage.ToString()).Replace("{extradamage}", modmessage);
                        Out.SendMessage(translation, eChatType.CT_YouHit, eChatLoc.CL_SystemWindow);
                    }
                    else
                    {
                        translation = LanguageMgr.GetTranslation(Client, eTranslationKey.SystemText, "{sourcetype} {sourcetarget} {sourceitem} and hit for {damagetaken}{extradamage} damage!", "");
                        translation = translation.Replace("{sourcetype}", attackTypeMsg);
                        if (ad.Target is GamePlayer)
                            translation = translation.Replace("{sourcetarget}", ad.Target.Name);
                        else
                            translation = translation.Replace("{sourcetarget}", ad.Target.GetName(0, false));
                        translation = translation.Replace("{sourceitem}", hitWeapon).Replace("{damagetaken}", ad.Damage.ToString()).Replace("{extradamage}", modmessage);
                        Out.SendMessage(translation, eChatType.CT_YouHit, eChatLoc.CL_SystemWindow);
                    }


And with pronoun
Code: Select all
foreach(GamePlayer plr in this.GetPlayersInRadius(WorldMgr.INFO_DISTANCE))
            {
                translation = LanguageMgr.GetTranslation(plr.Client, eTranslationKey.SystemText, "{sourcename} just died. {sourcepronoun} corpse lies on the ground.", "");
                translation = translation.Replace("{sourcename}", Name);

                string tmp = translation;
                if(tmp.Trim().IndexOf("{sourcepronoun}") == 0 || tmp.Trim().IndexOf('.') == tmp.Trim().IndexOf("{sourcepronoun") - 1)
                    translation = translation.Replace("{sourcepronoun}", GetPronoun(plr.Client, 1, true));
                else
                    translation = translation.Replace("{sourcepronoun}", GetPronoun(plr.Client, 1, false));

                plr.Out.SendMessage(translation, eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany

Re: Language support for mobs, npc templates, ...

Postby Apo » Sun Oct 31, 2010 3:37 pm

Here are the current database tables. Please take a look at it and give me some feedback if you want.

I think the ability, spell, spellline and style tables can be merged into an single table - the same for the area and zone table. Master level steps maybe can be a part of the language quest text table.
Attachments
Tables.rar
(10.2 KiB) Downloaded 12 times
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany

Re: Language support for mobs, npc templates, ...

Postby Urza » Mon Nov 01, 2010 7:47 am

Hi,
I have a question:

Table DBLanguageNPC
1. Table Line
id: english name in "mob"-Table ??
examineArticle: ??
messageArticleMale: a
messageArticleFemale: a
name: stagant swarm
guildName: ""
language: EN

2. Table Line
id: english name in "mob"-Table ??
examineArticle: ??
messageArticleMale: ein
messageArticleFemale: ""
name: träger Schwarm
guildName: ""
language: DE

3. Table Line
id: english name in "mob"-Table ??
examineArticle: ??
messageArticleMale: ...
messageArticleFemale: ""
name: ...
guildName: ""
language: FR

4. Table Line
id: english name in "mob"-Table ??
examineArticle: ??
messageArticleMale: ...
messageArticleFemale: ""
name: ...
guildName: ""
language: IT

5. Table Line
id: english name in "mob"-Table ??
examineArticle: ??
messageArticleMale: ...
messageArticleFemale: ""
name: ...
guildName: ""
language: CU

Is this correct so?

greetings
Urza
User avatar
Urza
Developer
 
Posts: 671
Joined: Sun Jan 23, 2005 11:15 am
Website: http://www.juwesch.eu
Location: Germany/Delitzsch

Re: Language support for mobs, npc templates, ...

Postby Apo » Mon Nov 01, 2010 11:42 am

The translation id always is the english name of the mob. The article colums can be empty if you want (for named mobs like dragons).

Cuuldurach:

ID: Cuuldurach
examineArticle: ""
messageArticleMale: ""
messageArticleFemale: ""
guildName: ""
language: FR

You examine Cuuldurach:
He is aggressive towards you. (pronouns are hardcoded).
Cuuldurach yells: Who are you? What are you doing here?

"Trash mob" bandit (male):

ID: Bandit
examineArticle: The
messageArticleMale: An
messageArticleFemale: ""
guildName: ""
language: FR

You examine the bandit.
An bandit yells: Who are you?

Keep guard armsmen:

ID: Armsmen
examineArticle: The
messageArticleMale: "An"
messageArticleFemale: ""
guildName: ""
language: FR

You examine the armsmen. He is friendly towards you and is a realm guard.
XYZ has just killed by an Armsmen.

Keep guard armswoman:

ID: Armsmen
examineArticle: The
messageArticleMale: ""
messageArticleFemale: An
guildName: ""
language: FR

You examine the armswoman. She is friendly towards you and is a realm guard.
XYZ has just killed by an Armswoman.

All articles will be converted into ToLower/ToUpper code side. When the examineArticle is the first word, then the first letter will be an upper. It's your choice to save it as lower or upper in the database, it will make no difference.

You can also use 'An' for the examine article if you want, it's just an cosmetically value for languages. There is no need to add the english translation into the language tables, because the mob table should always be the english translation (if you support english). The mobs name in the mobs table is 1) used by quests (if a player shall kill some bandits, then a quests can point to an bandit name) 2) To return the english name if there has no translation found.

But I see that I need to add an TranslationUnique to the tables (includes mob table and npc template) to make sure that we get the correct translation:

As example:

We have 3 bandits. One without a guild name an two with a different guild name. If we point to an translation, then it can be happen that we get the wrong translation - so we need to make it unique:

Bandit 1: Unique: Bandit, name Bandit: Guild name: ""
Bandit 2: Unique: BanditDragon, Name: Bandit, Guild name: The dragons.
Bandit 3: Unique: BanditKillers, Name, Bandit, Guild name: The killers.
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest