Skip to content
This repository has been archived by the owner on Oct 15, 2021. It is now read-only.

[Android strings.xml] Problem with apostrophe handling #235

Closed
rhdunn opened this issue May 7, 2013 · 5 comments
Closed

[Android strings.xml] Problem with apostrophe handling #235

rhdunn opened this issue May 7, 2013 · 5 comments

Comments

@rhdunn
Copy link

rhdunn commented May 7, 2013

Hi,

If a string contains an escaped apostrophe (\'), it gets modified to \\' (e.g. after running tx pull) which causes build errors when building the Android application in Eclipse. For example:

<string name="engine_settings" msgid="15960710549009350">"Configuració d\'eSpeak TTS"</string>

gets converted to:

<string name="engine_settings">Configuració d\\'eSpeak TTS</string>

Thanks,
Reece

@rhdunn
Copy link
Author

rhdunn commented May 7, 2013

When editing the string in the translation web UI, I see:

Configuració d\'eSpeak TTS

I populated the data from already translated strings (see the bug description for an example), so the problem appears to be:

  1. The tx push command does not unescape escaped strings (e.g. \' to ').
  2. The tx pull command escapes \ to \\.

Item (2) is correct, but is causing round-tripping issues due to item (1).

@nsallembien
Copy link

Hi Reece,

I believe this is the correct behavior. The Android .strings format is pretty peculiar with quotes:

http://developer.android.com/guide/topics/resources/string-resource.html

Search for this phrase:

If you have an apostrophe or a quote in your string, you must either escape it or enclose the whole string in the other type of enclosing quotes. For example, here are some stings that do and don't work

And you will find some useful examples that show what works and what doesn't.

Thanks
Nico

@rhdunn
Copy link
Author

rhdunn commented May 7, 2013

The examples in the Escaping apostrophes and quotes section do not show escaped apostrophes with enclosing quotes -- e.g. "they\'re".

These strings originated from the Google eyes-free project which uses both forms of escaping together. This was developed by Google engineers.

@nsallembien
Copy link

Exactly. Either your string should say:

<string name="engine_settings" msgid="15960710549009350">"Configuració d'eSpeak TTS"</string>

Or it should say:

<string name="engine_settings" msgid="15960710549009350">Configuració d\'eSpeak TTS</string>

Believe me, Google engineers make mistakes too :-)

Thanks
Nico

@murraycu
Copy link

Likewise, a properly escaped string in strings.xml such as:

<string name="engine_settings" msgid="15960710549009350">Configuració d\'eSpeak TTS</string>

gets changed into this after I do a tx push -t and a tx pull:

<string name="engine_settings" msgid="15960710549009350">Configuració d'eSpeak TTS</string>

which the android build then fails on.

I also notice that my < and > get changed into &lt and &rt; which also shouldn't happen and which will just silently (with no build error) result in < and > appearing in the UI.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants