Hi
Should strings inside scriptable objects be gathered properly for translations?
Test case:
When gathering text the string isnt listed after Gathering text (reset didnt help) with Custom filter (or any filter for that matter).
[SerializeField]
private string parameterText = "My Test String";
private int parameterLineID = -1;
public string GetTranslatableString(int index)
{
return parameterText;
}
public int GetTranslationID(int index)
{
return parameterLineID;
}
#if UNITY_EDITOR
public void UpdateTranslatableString(int index, string updatedText)
{
parameterText = updatedText;
}
public int GetNumTranslatables()
{
return 1;
}
public bool CanTranslate(int index)
{
return !string.IsNullOrEmpty(parameterText);
}
public bool HasExistingTranslation(int index)
{
return (parameterLineID >= 0);
}
public void SetTranslationID(int index, int lineID)
{
parameterLineID = lineID;
}
public string GetOwner(int index)
{
return string.Empty;
}
public bool OwnerIsPlayer(int index)
{
return false;
}
public AC_TextType GetTranslationType(int index)
{
return AC_TextType.Custom;
}
#endif
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
How are the Player and the SO linked?
Custom ITranslatable implementations currently need to be a MonoBehaviour inside a scene, or an Action, for them to be automatically detected.
What you could do is have a separate ITranslatable script in the scene that passes its implmemtation values to the SO's, i.e:
I will, however, see if an ITranslatableReferencer or some such is possible, to allow for ITranslatables to be detected elsewhere.
It's marked with the Serialize field attribute.
I can easily look to see how the speech manager gathers references, I just didn't go down that rabbit hole.
Tbh - while I love AC as a whole - I do find code/script localization to be cumbersome at first glance (granted I haven't looked tonight into it). Implementing an interface with multiple methods to essentially do a lookup for one string is alot.
I'm nearly all games I've worked on strings come from a CSV that has KVPs of string Id and value. There is a csv per language.vslues can contain escape sequences for substitution. Ie
$HumanRaceID, Human
Lookups are done at runtime to convert string Id to localized value, ie
cout << Localization.Translate("$HumanRaceID);// Human if English language
I understand you need to make AC non programmer friendly, though.
I think I might just have a second CSV lookup for script strings that aren't directly used by AC and hoo into its language changed evens as needed.
Noted, thank you.
I will introduce ITranslatableReferencer in the next update. It'll be a simple one-function interface that you can implement in your Player script to inform AC of the link to the ITranslatable field:
Nice!