title: Localizing strings in Korean dependent on the final consonant of an argument using MessageFormat
body: <p>We are attempting to translate our application into the Korean language using the ICU library's MessageFormat (more specifically, PHP's MessageFormatter).</p>
  
  <p>The Korean language makes extensive use of suffixes (어미), which attach onto the end of words. The form of most nominal suffixes are dependent on the final consonant (받침) of the final syllable of the preceding noun. For example, the subject marker takes the form <strong>이</strong> (-i) when it follows a final consonant and <strong>가</strong> (-ga) when there is no final consonant. So translators who are given:</p>
  
  <pre><code>{0} is good.
  John is good.
  Susie is good.
  </code></pre>
  
  <p>might translate it as:</p>
  
  <pre><code>{0}이 좋다.   ({0}-i joh-da.)
  길동이 좋다.   (gil-dong-i joh-da.)
  </code></pre>
  
  <p>if {0} ends in a consonant, and as:</p>
  
  <pre><code>{0}가 좋다.   ({0}-ga joh-da.)
  지혜가 좋다.   (ji-hye-ga joh-da.)
  </code></pre>
  
  <p>if {0} doesn't end in a consonant.</p>
  
  <p>One convention is to format strings like these as:</p>
  
  <pre><code>{0}이(가) 좋다.   ({0}-i(-ga) joh-da.)
  지혜이(가) 좋다.   (ji-hye-i(-ga) joh-da.)
  </code></pre>
  
  <p>Of course this looks clumsy and unprofessional and is precisely the sort of thing MessageFormat was designed to eliminate (at least in the case of plurals and gender-dependency, neither of which, incidentally, are relevant to the Korean language).</p>
  
  <p>Ideally, what I need is functionality similar to plural or select, but specifically for allowing translators to easily provide different translations based on the detected final consonant. Something like this would be ideal:</p>
  
  <pre><code>{0}{0, final, none {가} other {이}} 좋다.
  {0}{0, final, none {로} ㄹ {로} other {으로}} 갔다.
  </code></pre>
  
  <p>I've thought about implementing a pre-processor to parse out such deterministic, locale-dependent formats and to inject them as additional arguments before passing them into MessageFormatter, but I'd like to avoid the overhead of parsing the string twice if possible.</p>
  
  <p>What is the best practice for handling this kind of situation with MessageFormatter?</p>