Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix TextManager.GetLocalizedTextList returning spurious ^M characters #2514

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Assets/Scripts/Game/TextManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class TextManager : MonoBehaviour
const string textFolderName = "Text";
const string textColumn = "text";

readonly char[] trimAtEnd = { '\n', '\r' };
readonly string[] newlineSequences = { "\r\n", "\r", "\n" };

public string runtimeInternalStrings = defaultInternalStringsCollectionName;
public string runtimeRSCStrings = defaultInternalRSCCollectionName;
public string runtimeFlatStrings = defaultInternalFlatsCollectionName;
Expand Down Expand Up @@ -380,7 +383,7 @@ public string[] GetLocalizedTextListFromKeyArray(string[] keyArray, TextCollecti

/// <summary>
/// Gets an array of text where each line is considered an item in array.
/// Entry will be read from table and split by newline '\n' character into array.
/// Entry will be read from table and split by newline characters into array.
/// </summary>
/// <param name="key">Key of text in table.</param>
/// <param name="collection">Enum value to lookup collection name in TextManager.</param>
Expand Down Expand Up @@ -575,7 +578,7 @@ private bool TryGetLocalizedText(string collectionName, string key, out string l

/// <summary>
/// Gets an array of text where each line is considered an item in array.
/// Entry will be read from table and split by newline '\n' character into array.
/// Entry will be read from table and split by newline characters into array.
/// </summary>
/// <param name="collectionName">Name of table collection.</param>
/// <param name="key">Key of text in table.</param>
Expand All @@ -597,7 +600,7 @@ private string[] GetLocalizedTextList(string collectionName, string key, bool ex
return null;
}

cachedList = localizedString.Split('\n');
cachedList = localizedString.TrimEnd(trimAtEnd).Split(newlineSequences, StringSplitOptions.None);
cachedLocalizedTextLists.Add(cacheKey, cachedList);

return cachedList;
Expand Down