How do I escape double or single quotes in my CSV file for localization?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ryanrom5

Hello Everyone,

I’m currently using LibreOffice Calc to store strings in a CSV for localization. However no matter what escape format I use, it breaks the translation. When I put single or double quotes in the file it breaks. When I escape with a backslash or another double-quote, triple quote, or quad quote, it still doesn’t work.

Any ideas? Is this a LibreOffice issue? Or a Godot issue?

Thank you

Can you show an example of the CSV?
I have been playing with CSV just recently and if iirc you don’t need quotes it if it is all strings and no strings contain the delimiter.
In any case this format works:

“string 1”, “string2”, “string3”
“string 1a”, “string2a”, “string3a”
“string 1b”, “string2b”, “string3b”

Double check you are outputting valid CSV.

LeslieS | 2022-12-27 08:38

Thank you for your response! Maybe you can figure this out if it is fresh on your mind.

I should elaborate that I would like to have the quotes appear in the actual value (the printed dialogue), and thus am trying to find a way to escape them. Usually " or “” is the standard, the latter being the standard for csv. But neither are working.

This works… DIALOGUE_1 Localization is soo easy
This breaks… DIALOGUE_1 Localization is soo “easy”.
Still breaks… DIALOGUE_1 Localization is soo "easy".
This should work, but doesn’t… DIALOGUE_1 Localization is soo ““easy””.

Someone here said that double quotes work for escaping, but they aren’t for me.
Double quotes escaped with backslash in CSV translation files seem to be ignored · Issue #34949 · godotengine/godot · GitHub

I figured out that the godot engine doesn’t like quotes inside quotes unless you escape them with slash like this ". And I’ve read that in CSV you’re supposed to use a double quote to escape chars like this “”.

So I tried this… DIALOGUE_1 Localization is soo “"“easy”"”.

But this won’t work either. The tr() function just spits out the key, DIALOGUE_1 , which is what it does by default when it can’t perform the translation.

ryanrom5 | 2022-12-27 19:45

:bust_in_silhouette: Reply From: ryanrom5

After switching over to try Google Sheets, I’ve concluded that the issue is with LibreCalc. Quotes get added to Godot text fields without the need for any escape key, surprisingly.

I think it’s because Google sheets by default doesn’t try to auto-complete or format anything, and takes it all “as is” when you type it. LibreCalc by default will change some things around. Like extending a dash line or make “…” into one character that Godot doesn’t recognize.

I think it’s better to use Google Sheets when working with localization in Godot. Unless you want to change settings around in LibreCalc.

I’ll post this here in case someone has the same problem I had today. I still ended up using LibreCalc b/c I want a local/offline editor that instantly updates in Godot when saved.

In LibreCalc there are auto-formatting settings that may break your translation. The exact setting for the quotes can be found in: Tools → AutoCorrectOptions → Localized Options

Then uncheck the boxes “Replace” for single and double quotes. There are likely more formatting things you’d want to turn off in the other 4 tabs. Now it doesn’t break as much.

The annoying part is that I opened my broken csv files in a text editor and the quotes displayed normally. It’s just doing some magic that Godot doesn’t know how to work with specifically.

ryanrom5 | 2022-12-28 04:33