private int chooseDefaultLanguage ()
    {
        if (languages.length == 1)
            return languages [0];

        Locale   dflt = Locale.getDefault ();
        int   retval = languages [0];

        for (int i = 0; i < languages.length; i++) {
            Locale  current = LangCode.getLocale (languages [i]);

            // return exact matches if possible
            if (current == dflt)
                return languages [i];

            // insist on shared language
            if (current == null)
                continue;
            if (!current.getLanguage ().equals (dflt.getLanguage ()))
                continue;

            // could also check country (return now if same)

            // it's OK, and maybe better than our last guess
            retval = languages [i];
        }
        return retval;
    }