From the course: Localization for Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Avoiding string concatenation and string reuse

Avoiding string concatenation and string reuse

From the course: Localization for Developers

Start my 1-month free trial

Avoiding string concatenation and string reuse

- While you're still in the process of taking all of the strings out of your code, you also need to pay attention to how those strings are being used. In particular, I'd like to warn you against treating language programmatically. Sometimes we want to create what are called Natural Language Statements by cobbling different strings and variables together, for example, what you see here. Here, we're defining the log variable as equal to a string, "You sent a message to ". Then we're going to concatenate on another variable, which is the user name. We're going to concatenate another small string, " at ", and then we're going to concatenate a time variable. Now, this generates a very nice, easy to read, log entry for our end users that says, "You sent a message to Arthur at 10:15." This becomes problematic because you can't make any assumptions about how other languages are structured or formatted. In Japanese, for example, the parts of this message are basically reversed. I've…

Contents