Revision: 7884
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=7884&view=rev
Author:   dnaber
Date:     2012-08-19 15:17:12 +0000 (Sun, 19 Aug 2012)
Log Message:
-----------
support spell checking in online app - works only when the users selects a 
language plus its variant

Modified Paths:
--------------
    
trunk/ltcommunity/grails-app/controllers/org/languagetool/HomepageController.groovy
    trunk/ltcommunity/grails-app/views/homepage/checkText.gsp

Modified: 
trunk/ltcommunity/grails-app/controllers/org/languagetool/HomepageController.groovy
===================================================================
--- 
trunk/ltcommunity/grails-app/controllers/org/languagetool/HomepageController.groovy
 2012-08-19 15:05:36 UTC (rev 7883)
+++ 
trunk/ltcommunity/grails-app/controllers/org/languagetool/HomepageController.groovy
 2012-08-19 15:17:12 UTC (rev 7884)
@@ -20,7 +20,6 @@
 package org.languagetool
 
 import org.hibernate.*
-import org.languagetool.*
 import org.languagetool.rules.*
 import org.apache.tika.language.LanguageIdentifier
 
@@ -89,7 +88,7 @@
      * Run the grammar checker on the given text.
      */
     def checkText = {
-        String lang = "en"
+        String langStr = "en"
         boolean autoLangDetectionWarning = false
         List languages = Language.REAL_LANGUAGES
         languages.sort{it.getName()}
@@ -106,14 +105,15 @@
                         textToCheck: params.text])
                 return
             }
-            lang = detectedLang.getShortName()
-            params.lang = lang
+            langStr = detectedLang.getShortName()
+            params.lang = langStr
             // TODO: use identifier.isReasonablyCertain() - but make sure it 
works!
             autoLangDetectionWarning = params.text?.length() < 60
         } else if (params.lang) {
-            lang = params.lang
+            langStr = params.lang
         }
-        JLanguageTool lt = new 
JLanguageTool(Language.getLanguageForShortName(lang))
+        Language lang = Language.getLanguageForShortName(langStr)
+        JLanguageTool lt = new JLanguageTool(lang)
         lt.activateDefaultPatternRules()
         List userRules = getUserRules()
         for (rule in userRules) {
@@ -122,7 +122,7 @@
         // load user configuration and disable deactivated rules:
         LanguageConfiguration langConfig = null
         if (session.user) {
-            langConfig = RuleController.getLangConfigforUser(lang, session)
+            langConfig = RuleController.getLangConfigforUser(langStr, session)
             if (langConfig) {
                 for (disRule in langConfig.disabledRules) {
                     lt.disableRule(disRule.ruleID)
@@ -137,7 +137,7 @@
         }
         List ruleMatches = lt.check(text)
         // TODO: count only disabledRules for the current language
-        [matches: ruleMatches, lang: lang, languages: languages,
+        [matches: ruleMatches, lang: langStr, language: lang, languages: 
languages,
                 disabledRules: langConfig?.disabledRules, textToCheck: 
params.text,
                 autoLangDetectionWarning: autoLangDetectionWarning, 
detectedLang: detectedLang]
     }

Modified: trunk/ltcommunity/grails-app/views/homepage/checkText.gsp
===================================================================
--- trunk/ltcommunity/grails-app/views/homepage/checkText.gsp   2012-08-19 
15:05:36 UTC (rev 7883)
+++ trunk/ltcommunity/grails-app/views/homepage/checkText.gsp   2012-08-19 
15:17:12 UTC (rev 7884)
@@ -12,6 +12,11 @@
         <div class="body">
           
             <h1><g:message code="ltc.home.check.title"/></h1>
+
+            <g:if test="${language.hasVariant()}">
+                <p class="warn"><b>Hint:</b> Note that spell checking will 
only work when you select a language
+                    plus its variant,<br/>e.g. "English (US)" instead of just 
"English".</p>
+            </g:if>
         
             <g:if test="${session.user}">
                    <g:if test="${disabledRules && disabledRules.size() > 0}">
@@ -41,7 +46,14 @@
                 <g:textArea name="text" value="${params.text}" rows="5" 
cols="80" />
                 <br />
                 <g:actionSubmit action="checkText" 
value="${message(code:'ltc.home.check.text')}"/>
-                &nbsp;&nbsp;&nbsp;Language: <g:select name="lang" 
from="${languages}" optionKey="shortName" 
noSelection="${['auto':'auto-detect']}" value="${params.lang}"></g:select>
+                &nbsp;&nbsp;&nbsp;Language:
+                <select name="lang">
+                    <g:each in="${languages}" var="lang">
+                        <g:set var="codeWithCountry" 
value="${lang.countryVariants?.size() == 1 && lang.countryVariants[0] != 'ANY' 
? lang.shortName + '-' +lang.countryVariants[0] : lang.shortName}"/>
+                        <g:set var="selected" value="${params.lang == 
codeWithCountry ? 'selected' : ''}"/>
+                        <option ${selected} 
value="${codeWithCountry}">${lang.name}</option>
+                    </g:each>
+                </select>
             </g:form>
         
         </div>

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

Reply via email to