title: When is localization (or lack of) a bad thing?
body: <p>The following code returns a message which states whether the input value is a palindrome:</p>
  
  <p><em>(for the sake of this post, the syntax isn't important, or written in any particular language)</em></p>
  
  <pre><code>function isPalindrome(
      value: string, 
      successMessage: string = "Is palindrome", 
      failureMessage: string = "Is not palindrome"): string {
  
      return value.reverse() == value ? successMessage : failureMessage;
  }
  </code></pre>
  
  <p>Notice in the code above, the default messages are written in English, however as they are supplied as parameters, this method could easily be localized, and because the method has default values for the messages, this doesn't force the developer to provide them; for example:</p>
  
  <pre><code>isPalindrome("level") // returns "Is palindrome"
  </code></pre>
  
  <p>However we can demonstrate localization; for example, in spanish:</p>
  
  <pre><code>isPalindrome("level", "es palíndromo", "no es palíndromo") // returns "es palíndromo"
  </code></pre>
  
  <p>This got me thinking, when <em>should</em> code be designed with localization in mind?</p>
  
  <p>Another example would be with exceptions; for example:</p>
  
  <pre><code>class PalindromeException : Exception("Is not a palindrome")
  
  function validatePalindrome(value: string): void {
      if (value.reverse() != value) {
          throw PalindromeException();
      }
  }
  </code></pre>
  
  <p>Notice in this example that there is no way to localize the message in the exception. I know this could easily be fixed using the same principles in the first example, but it has been purposefully designed to demonstrate a lack of globalization.</p>
  
  <p>Therefore, when should globalization be applied to code, so that it may be localized? When does it matter, and when does it not?</p>