Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: vallcrist on May 17, 2014, 06:47:23 AM

Title: Localized strings sometimes missing the first characters
Post by: vallcrist on May 17, 2014, 06:47:23 AM
Hello again. :)

On some localized strings like "The game can't connect to the server at this moment. Try again in a few minutes" the first 2~4 charactersdon't show up when transferred into a label, any idea why?

Update : it seems like the problem is related to multi-line texts, every line break is one less character from the beggining
Title: Re: Localized strings sometimes missing the first characters
Post by: ArenMook on May 17, 2014, 06:11:49 PM
How can I reproduce this on my end?
Title: Re: Localized strings sometimes missing the first characters
Post by: Ernest on June 12, 2014, 05:51:38 AM
This happen when you accidentally insert a \n (ctrl + enter) at the end of a cell in your csv file.
Title: Re: Localized strings sometimes missing the first characters
Post by: nbrew on August 27, 2014, 04:59:48 PM
I realize this may be thread > 60 days old but I thought I'd propose a hack for anyone else who stumbles on this issue. As both vallcrist and Ernest indicated, when an actual newline character is present in a localization value the first character of the value will not be present in the game.

Example Localization.txt:

  1. KEY,English,Spanish
  2. name,"Common Name
  3. Latin Name","ES Translation Missing
  4. Latin Name"
  5. anotherKey,"Some Value","ES Translation Missing"
  6.  

Using "name" in English yields "ommon Name
Latin Name".

To remedy this you have two choices:
The first is to use the localizations as intended by replacing the newline character with "\n", so that the name line becomes
  1. name,"Common Name\nLatin Name","ES Translation Missing\nLatin Name"

The other option is to modify NGUI/Scripts/Internal/ByteReader.cs by commenting out line 220:

  1.                 while (canRead)
  2.                 {
  3.                         if (insideQuotes)
  4.                         {
  5.                                 string s = ReadLine(false);
  6.                                 if (s == null) return null;
  7.                                 s = s.Replace("\\n", "\n");
  8.                                 line += "\n" + s;
  9. //                              ++wordStart; // comment out this line
  10.                         }

I'm not completely sure of what other solutions this might impact but it seems to work for my localizations csv so far.

Hope this helps someone in the future.
Title: Re: Localized strings sometimes missing the first characters
Post by: ArenMook on August 28, 2014, 08:44:40 PM
That line isn't there, and hasn't been there in many months. Please update. :P
Title: Re: Localized strings sometimes missing the first characters
Post by: rain on September 10, 2014, 10:34:13 AM
Sorry to revive this thread, but if I cannot update to the latest version (currently on 3.6.3), then the only thing I need to do to solve this is comment out ByteReader.cs:220?
Title: Re: Localized strings sometimes missing the first characters
Post by: ArenMook on September 11, 2014, 01:37:19 AM
No idea. I can't remember all changes from months back. I can barely remember what I had for breakfast this morning. <_<