public static Locale getLocale() {
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader in = null;
        File options = FreeColDirectories.getClientOptionsFile();
        if (options.canRead()) {
            try {
                in = xif.createXMLStreamReader(new FileInputStream(options), "UTF-8");
                in.nextTag();
                /**
                 * The following code was contributed by armcode to fix
                 * bug #[ 2045521 ] "Exception in Freecol.log on starting
                 * game". I was never able to reproduce the bug, but the
                 * patch did no harm either.
                 */
                for(int eventid = in.getEventType();eventid != XMLEvent.END_DOCUMENT; eventid = in.getEventType()) {

                    //TODO: Is checking for XMLEvent.ATTRIBUTE needed?
                    if (eventid == XMLEvent.START_ELEMENT) {
                        if (ClientOptions.LANGUAGE.equals(in.getAttributeValue(null, "id"))) {
                            return LanguageOption.getLocale(in.getAttributeValue(null, "value"));
                        }
                    }
                    in.nextTag();
                }
                //We don't have a language option in our file, it is either not there or the file is corrupt
                logger.log(Level.WARNING, "Language setting not found in client options file.  Using default.");
            } catch (Exception e) {
                logger.log(Level.WARNING, "Exception while loading options.", e);
            } finally {
                try {
                    if (in != null) {
                        in.close();
                    }
                } catch (Exception e) {
                    logger.log(Level.WARNING, "Exception while closing stream.", e);
                }
            }
        }
        return Locale.getDefault();
    }