Author Topic: Localized strings sometimes missing the first characters  (Read 3068 times)

vallcrist

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 49
    • View Profile
Localized strings sometimes missing the first characters
« 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
« Last Edit: May 17, 2014, 07:18:33 AM by vallcrist »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Localized strings sometimes missing the first characters
« Reply #1 on: May 17, 2014, 06:11:49 PM »
How can I reproduce this on my end?

Ernest

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 40
    • View Profile
Re: Localized strings sometimes missing the first characters
« Reply #2 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.

nbrew

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Localized strings sometimes missing the first characters
« Reply #3 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Localized strings sometimes missing the first characters
« Reply #4 on: August 28, 2014, 08:44:40 PM »
That line isn't there, and hasn't been there in many months. Please update. :P

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Re: Localized strings sometimes missing the first characters
« Reply #5 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Localized strings sometimes missing the first characters
« Reply #6 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. <_<