6

When defining localization text, I often worried about whether I should translate the whole string including punctuation, or just translate the text part, for example:

Translate whole text:

"ARE_YOU_SURE_UNDONE_en":"Are you sure (It cannot be undone)?",
String message=map.get("ARE_YOU_SURE_UNDONE_en")

Translate text only:

"ARE_YOU_SURE_en":"Are you sure",
"UNDONE_en":"It cannot be undone"

String message=map.get("ARE_YOU_SURE_en")+"("+map.get("UNDONE_en")+")"+?

Which one should I use?

2
  • 2
    Not all languages use the same punctuations.
    – tkausl
    Commented Jul 12, 2018 at 2:07
  • 1
    My wife translates such texts in Italian. She says she often sees several partial translations strung together, and she has difficulty at times making it make sense in Italian. Reuse as much as possible, but also don't break it into pieces unless they're genuinely two separate messages. Maybe use two separate sentences (leave punctuation as part of the message itself).
    – Neil
    Commented Jul 12, 2018 at 7:13

1 Answer 1

12

Definitely the complete text.

  1. Different languages use different punctuations, for example, english "Where?" Would be "¿Dónde?" In spanish (note the inverted question mark in the beginning).
  2. Different languages will need punctuation (or variable pieces) in different places of the string
  3. It's a lot more coding effort to concatenate the pieces together

The usual solution is to have a string per language, with placeholder for variables, like %1 %2 or whatever you like, and each language can place them where it needs them in the sentence structure.
Example: "Do you to want to continue with %1 as the chosen %2", and fill it dynamically. Another language might use "Möchten Sie mit der %2 %1 fortfahren?"

2
  • On top of some languages using different punctuation, even languages using the same punctuation can have different spacing rules (the first example would be "Où ?" in French, with a non-breaking space before the question mark).
    – KevinLH
    Commented Jul 12, 2018 at 7:55
  • good answer - pls add that in some rare cases one may want to have nested and separate translations due to plurality, eg `"Are you sure you want to perform %X actions (%Y actions cannot be undone)?". (NB - s's may be there or not, in some languages there are multiple plurals also) Using localization framework may help to properly concatenate the final sentence though, with a string for this case: "%S (%T)?"
    – Roman Susi
    Commented Jul 12, 2018 at 9:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.