Page 1 of 1

Articy Localization Importer improvements

Posted: Sun Mar 10, 2024 6:49 am
by _marc
Hi again,

Last month I tried the articy localization plugin of the Dialogue System, it works very well!
I'd like to talk about some adjustments to improve it, if you're open to it :)
In the script ArticyLocalizationImporter.cs :

1/ In the function ProcessExcelFile(string languageCode, string filename), there is this loop:

Code: Select all

            for (int i = 0; i < rows.Length; i++)
            {
                var row = rows[i];
                var locaID = row.LocaID;
                var value = row.Value;
                var contextPath = row.ContextPath;
                var dotPos = locaID.IndexOf('.');
                var technicalName = locaID.Substring(0, dotPos);
                var fieldSpec = locaID.Substring(dotPos + 1);
                if (contextPath.StartsWith("Assets")) continue;
                SetLocalizedField(languageCode, technicalName, fieldSpec, value);
            }
I replaced this part:

Code: Select all

                var dotPos = locaID.IndexOf('.');
                var technicalName = locaID.Substring(0, dotPos);
                var fieldSpec = locaID.Substring(dotPos + 1);
...by this:

Code: Select all

                string[] split = locaID.Split('.');
                string technicalName = split[0];
                string fieldSpec = split[split.Length - 1];
The reason: maybe I missed something but in my localization excel file the locaID looks like this:
TechnicalName.TemplateName.Property
As an example, for a character's name:
PoliceNetworkManager.Character_Base_Properties.CharacterName

Without the code change, the importer is looking for a field called "Character_Base_Properties.CharacterName", when it should, in my opinion, search for a field called "CharacterName". I think it's the way it works in the main xml import.

2/ In the same function, I had to add this check:

Code: Select all

if (locaID == null) continue; 
Can't understand why, but after some modifications in the localized file (like suppressing some useless lines to make the document more readable by the translator), I always have a null ref exception on import for the last line of my document: row.Value and locaID are null.
If you have no idea why it does that, I'll try to find out exactly when the error starts to appear.

3/ Finally, in the function "SetFieldInFieldsList(List<Field> fields, string title, string value)", I added this line:

Code: Select all

if (value.Contains(@"\n")) value = value.Replace(@"\n", "\n");
With the regular main xml import, in the ArticyConverter script, dialogue lines are always parsed this way to preserve line breaks. Without this, formatting is different between localized and original texts. I guess it's just a mere oversight...

That's all :)

Marc

Re: Articy Localization Importer improvements

Posted: Sun Mar 10, 2024 7:52 am
by Tony Li
Hi Marc,

Thanks! I'll look over both of these changes in detail and incorporate them into DS version 2.2.44.

Re: Articy Localization Importer improvements

Posted: Sun Mar 10, 2024 9:12 am
by _marc
Ok, thank you!

For the point n°2 (the null ref exception on localization import), I confirm it happens after removing at least 1 row in the .xlxs file. I usually delete all stage directions rows, as they are not needed and I didn't found the way to bypass them on export with articy.

Hope this helps!

Marc