c# How to deal with Newline character, when moving

2019-02-17 09:41发布

问题:

I am writing a application in c#.For the localization purpose, I am moving all of my strings to resources.

Some example of strings:

  1. "First sentence.\n Second sentence."
  2. "wait..."

In first string there is newline character "\n".Should I move the newline character to resources too.

In second string, should I move the three dots to resources or should I split string in to two parts like "wait" + "..." and move only "wait" to resources.

I am using Google-translate to translate strings to other languages and i am afraid that newline character "\n" will not be translate well to other language by Google-translate, hence my hesitation to move newline character to resources.

This is my first take at localization.So suggest if you any further ideas or point me out in right direction.

Thanks.

回答1:

I believe \n will not be treated as an escape character in the rendered text.

if the number of resource entries is small, you can use shift + enter to add a new line.

Another option is to replace \n by {0} and then use String.Format() to insert a new line where needed.



回答2:

I believe that the best approach is to avoid splitting up localisable strings wherever possible - splitting up a string only increases the chance that it won't be possible to correctly localise the string.