Revision: 8002 http://languagetool.svn.sourceforge.net/languagetool/?rev=8002&view=rev Author: dnaber Date: 2012-09-08 23:03:38 +0000 (Sat, 08 Sep 2012) Log Message: ----------- extend the HTTP XML output for the "/Languages" URL to also contain the language code with its variant
Modified Paths: -------------- trunk/JLanguageTool/CHANGES.txt trunk/JLanguageTool/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java trunk/JLanguageTool/src/test/java/org/languagetool/server/HTTPServerTest.java Modified: trunk/JLanguageTool/CHANGES.txt =================================================================== --- trunk/JLanguageTool/CHANGES.txt 2012-09-08 12:02:14 UTC (rev 8001) +++ trunk/JLanguageTool/CHANGES.txt 2012-09-08 23:03:38 UTC (rev 8002) @@ -75,6 +75,11 @@ -HTTP API: "+" was incorrectly removed from input (Sourceforge bug #3543914), patch by Sourceforge user hiddenspirit + -HTTP API: the XML returned by the "/Languages" URL (which returns a list of all supported + languages) has been extended to contain an 'abbrWithVariant' attribute which lists the + language with its variant, e.g.: + <language name="Catalan" abbr="ca" abbrWithVariant="ca-ES"/> + -HTTP API and XML output: extended XML to include the version and build date of LanguageTool and the category of each match Modified: trunk/JLanguageTool/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java =================================================================== --- trunk/JLanguageTool/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java 2012-09-08 12:02:14 UTC (rev 8001) +++ trunk/JLanguageTool/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java 2012-09-08 23:03:38 UTC (rev 8002) @@ -264,17 +264,17 @@ /** - * Construct an xml string containing all supported languages. <br/>The xml format is:<br/> + * Construct an XML string containing all supported languages. <br/>The XML format looks like this:<br/><br/> * <languages><br/> - * <language name="Catalan" abbr="ca" /><br/> - * <language name="Dutch" abbr="nl" /><br/> - * ...<br/> - * <languages><br/> - * The languages are alphabetically sorted. - * @return an xml string containing all supported languages. + * <language name="Catalan" abbr="ca" abbrWithVariant="ca-ES"/><br/> + * <language name="German" abbr="de" abbrWithVariant="de"/><br/> + * <language name="German (Germany)" abbr="de" abbrWithVariant="de-DE"/><br/> + * <languages><br/><br/> + * The languages are sorted alphabetically by their name. + * @return an XML document listing all supported languages */ public static String getSupportedLanguagesAsXML() { - Language[] languageCopy = Language.REAL_LANGUAGES.clone(); + final Language[] languageCopy = Language.REAL_LANGUAGES.clone(); final List<Language> languages = Arrays.asList(languageCopy); Collections.sort(languages, new Comparator<Language>() { @Override @@ -284,7 +284,8 @@ }); final StringBuilder xmlBuffer = new StringBuilder("<?xml version='1.0' encoding='UTF-8'?>\n<languages>\n"); for (Language lang : languages) { - xmlBuffer.append(String.format("\t<language name=\"%s\" abbr=\"%s\" /> \n", lang.getName(), lang.getShortName())); + xmlBuffer.append(String.format("\t<language name=\"%s\" abbr=\"%s\" abbrWithVariant=\"%s\"/> \n", lang.getName(), + lang.getShortName(), lang.getShortNameWithVariant())); } xmlBuffer.append("</languages>\n"); return xmlBuffer.toString(); Modified: trunk/JLanguageTool/src/test/java/org/languagetool/server/HTTPServerTest.java =================================================================== --- trunk/JLanguageTool/src/test/java/org/languagetool/server/HTTPServerTest.java 2012-09-08 12:02:14 UTC (rev 8001) +++ trunk/JLanguageTool/src/test/java/org/languagetool/server/HTTPServerTest.java 2012-09-08 23:03:38 UTC (rev 8002) @@ -93,6 +93,9 @@ if (!languagesXML.contains("Romanian") || !languagesXML.contains("English")) { fail("Error getting supported languages: " + languagesXML); } + if (!languagesXML.contains("abbr=\"de\"") || !languagesXML.contains("abbrWithVariant=\"de-DE\"")) { + fail("Error getting supported languages: " + languagesXML); + } // tests for "&" character assertTrue(check(Language.ENGLISH, "Me & you you").contains("&")); // tests for mother tongue (copy from link {@link FalseFriendRuleTest}) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Languagetool-cvs mailing list Languagetool-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/languagetool-cvs