(Google Sheets Extension) PushCell in ColumnSheet prepending character '

I’m writing a way to indicate whether or not an entry is smart into the localization sheet for simplicity. It’s pretty simple, it’ll push TRUE or FALSE depending on if the entry is smart or not (and when pulling will do it accordingly). However when I look at the sheet after the push the character ’ is prepended to the values pushed, which is failing the default data validation at least.

8445311--1119770--upload_2022-9-16_13-22-49.png

Below is the PushCellData implementation:

        public override void PushCellData(SharedTableData.SharedTableEntry keyEntry, IList<StringTableEntry> tableEntries, out string value, out string note)
        {
            note = null;
        
            if (_pushIndex != -1 && tableEntries[_pushIndex] != null &&
                !string.IsNullOrEmpty(tableEntries[_pushIndex].Key))
            {
                StringTableEntry entry = tableEntries[_pushIndex];

                if (entry.IsSmart)
                {
                    value = "TRUE";
                }
                else
                {
                    value = "FALSE";
                }
            }
            else
            {
                value = null;
            }
        }

_pushIndex gets set on BeginPush and really just copies LocaleColumn.

If there’s an existing way to integrate the smart value into the sheets I’d love to know about it. Regardless though I’d like to know if I’m doing something wrong here or if there’s a bug.

Localization Version: 1.3.2
Unity Version: 2020.3.17f1

Thanks!
C.J.

Take a look at the smart string column example we have here
https://docs.unity3d.com/Packages/com.unity.localization@1.3/api/UnityEditor.Localization.Plugins.Google.Columns.LocaleMetadataColumn-1.html

That’s great and I’ll do it that way instead but any idea why the character is being prepended to the result of the function above?

No I can’t see why it would do that.
Can you share the full class? Maybe there’s something else going on.

Sure, here it is:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using UnityEditor.Localization;
using UnityEditor.Localization.Plugins.Google.Columns;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Tables;

namespace Raid.Editor
{
    [Serializable]
    public class SmartFormatLocaleColumn : SheetColumn
    {
        public LocaleIdentifier localeIdentifier;

        private int _pushIndex;
        private StringTable _pullTable;
       
        public override PushFields PushFields => PushFields.Value;
       
        public override void PushBegin(StringTableCollection collection)
        {
            ReadOnlyCollection<StringTable> tables = collection.StringTables;
           
            for (int i = 0; i < tables.Count; ++i)
            {
                if (tables[i].LocaleIdentifier == localeIdentifier)
                {
                    _pushIndex = i;
                    return;
                }
            }
           
            _pushIndex = -1;
        }

        public override void PushHeader(StringTableCollection collection, out string header, out string headerNote)
        {
            header = $"Smart ({localeIdentifier.Code})";
            headerNote = null;
        }

        public override void PushCellData(
            SharedTableData.SharedTableEntry keyEntry,
            IList<StringTableEntry> tableEntries,
            out string value,
            out string note)
        {
            note = null;
           
            if (_pushIndex != -1 && tableEntries[_pushIndex] != null &&
                !string.IsNullOrEmpty(tableEntries[_pushIndex].Key))
            {
                StringTableEntry entry = tableEntries[_pushIndex];

                if (entry.IsSmart)
                {
                    value = "TRUE";
                }
                else
                {
                    value = "FALSE";
                }
            }
            else
            {
                value = null;
            }
        }

        public override void PullBegin(StringTableCollection collection)
        {
            ReadOnlyCollection<StringTable> tables = collection.StringTables;
           
            for (int i = 0; i < tables.Count; ++i)
            {
                if (tables[i].LocaleIdentifier == localeIdentifier)
                {
                     _pullTable = collection.StringTables[i];
                    return;
                }
            }
           
            _pullTable = null;
        }

        public override void PullCellData(SharedTableData.SharedTableEntry keyEntry, string cellValue, string cellNote)
        {
            if (_pullTable == null)
            {
                return;
            }

            StringTableEntry entry = _pullTable.GetEntry(keyEntry.Key);

            if (cellValue == "TRUE")
            {
                entry.IsSmart = true;
            }
            else if (cellValue == "FALSE")
            {
                entry.IsSmart = false;
            }
            else
            {
                Debug.LogWarning($"Invalid cellValue for Smart Format ({cellValue})");
            }
        }
    }
}

Oh I misunderstood the issue. I can’t see what it would prepend that. I suspect it could be a Google bug. I’ll try and reproduce it next week.

1 Like

Some quick experiments (and information). Something in the pipeline is treating “true” and “false” special (case-insensitive). If I put in TRUE or true then it becomes 'TRUE or 'true in the sheets but I put in anything else, say, true1 then it’s just true1 in the sheets.

1 Like

I was not able to reproduce this. Are you able to file a bug report with a sample so we can take a look? Maybe there’s a step I missed.