Author Topic: Quotes in Localization.csv  (Read 6892 times)

bsowers

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Quotes in Localization.csv
« on: April 29, 2014, 05:59:03 PM »
Using the newer localization system, I'm trying to embed quotes in my strings. Using an escaped quote (\") doesn't seem to work. It looks like NGUIs csv parser is just doing a naive break on quotes and doesn't provide a way to embed them.

Is there a workaround for this?

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Re: Quotes in Localization.csv
« Reply #1 on: April 29, 2014, 07:19:09 PM »
You might want to try other types of escape sequences.

E.G.
"
"
\034
\x22

I'd be surprised if there isn't one such escape sequence that doesn't work.

bsowers

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Quotes in Localization.csv
« Reply #2 on: April 30, 2014, 07:04:55 AM »
None of those do it.

It looks like there's an attempt in ByteReader.cs to support it by using two double quotes (""), but the code isn't applied everywhere it needs to be. I was able to work around this issue by modifying everything added to mTemp to first go through this: .Replace("\"\"", "\"")

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Quotes in Localization.csv
« Reply #3 on: April 30, 2014, 05:32:31 PM »
Hmm? Double quotes is how it gets saved in CSV, and exactly how NGUI parses it, at least with the up-to-date version of NGUI.

I do my localization in Google docs, export it as CSV, and it "just works".

DevMan5000

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Quotes in Localization.csv
« Reply #4 on: June 23, 2014, 02:15:49 PM »
Hi, I am having a ton of trouble with this double quotes stuff. Whenever I put quotation marks (double) in my spreadsheet then they show up twice in the text windows.

Here is what I did:
- Using NGUI 3.6
- Opened MS Excel 2010
- Opened Localization.txt and saved it as Localization.csv (modifying and saving in .txt meant that Unity wouldn't be able to use the file anymore for some reason, but it worked when saved as .csv).
- Deleted Localization.txt so only Localization.csv would be read by Unity.
- In the Paragragh row I changed the English entry from This example shows how to This "example" shows how with quotes around the word example.
- When I booted it up in game, the text showed up as This ""example"" shows how with two sets of double quotes.
- When I open up the file in notepad I see "This ""example"" shows how...
- So then you think, ok excel is just adding dupe quotations when it saves. I tried removing one set of quotations through notepad "This "example" shows how... and saving, but then in Unity it shows up as This.
- Clearly the quotation marks serve some operational purpose in Unity and when I tried to manually insist on a single set of double quotes in notepad, Unity only parsed part of the string.

I think bsowers had a legitimate issue and I am running into the same thing. I also figured we would have to use \" or something, but that doesn't work. I messed around with GoogleDocs and that was not a help either (maybe my process was flawed).

Can you please look into what's going on and offer up a solution? Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Quotes in Localization.csv
« Reply #5 on: June 24, 2014, 04:31:53 AM »
Yup, seems there is a missing replace in ByteReader.cs. Line 254 reads:
  1. mTemp.Add(line.Substring(wordStart, i - wordStart));
It should be:
  1. mTemp.Add(line.Substring(wordStart, i - wordStart).Replace("\"\"", "\""));

DevMan5000

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Quotes in Localization.csv
« Reply #6 on: June 24, 2014, 09:18:03 PM »
Boom! Thanks much!