Allow 3 letter language codes in InputMethodUtils.

Replace locale.substring(0, 2) with a function that always
returns the first component of the locale (assumed to be the
language).

bug: 10090157

(cherry picked from commit cefc79c6b18bb2e824c299e7b9e212071e5ebc43)

Change-Id: I56b02dd0c6dc222daa3ceade841a30879449bb4a