private static String prepare(LocalizationInfo info, Locale lang, boolean isDefaultLang) {
        StringBuilder result = new StringBuilder();
        result.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n");
        result.append("<!-- " + GENERATOR_COMMENT + " -->\n\n");
        result.append("<resources>\n");

        String key, value, description;

        for (LocalizationStructure.Record record : info.structure.getRecords()) {
            switch (record.type) {
                case SECTION:
                    result.append("\n\t<!-- ").append(record.value).append(" -->");
                    break;
                case KEY:
                    key = record.value;
                    value = escapeValue(info.localization.getValue(key, lang));
                    description = record.description;

                    if (value == null || value.length() == 0) {
                        if (isDefaultLang) throw new LocalizationException("Missing value for default language (" +
                                lang + ") for key: " + key);
                        continue;
                    }

                    result.append("\t<string name=\"").append(key).append("\">").append(value).append("</string>");

                    if (description != null && description.length() > 0) {
                        result.append("  <!-- ").append(description).append(" -->");
                    }
                    break;
            }

            result.append('\n');
        }

        result.append("\n</resources>\n");

        return result.toString();
    }