LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File languagetool-2.0-package-dicts-separately.patch of Package libreoffice-languagetool (Project LibreOffice:Stable)

Index: languagetool-2.0/build.xml
===================================================================
--- languagetool-2.0.orig/build.xml
+++ languagetool-2.0/build.xml
@@ -518,8 +518,6 @@
 
         <copy file="${lang.resource.dir}/ast/ast.ngp" todir="${lang.dist.dir}/ast" />
 
-        <copy file="${lang.resource.dir}/be/be.ngp" todir="${lang.dist.dir}/be" />
-
         <copy file="${lang.resource.dir}/en/tagset.txt" todir="${lang.dist.dir}/en" />
         <copy file="${lang.resource.dir}/en/english.dict" todir="${lang.dist.dir}/en" />
         <copy file="${lang.resource.dir}/en/english.info" todir="${lang.dist.dir}/en" />
@@ -535,11 +533,6 @@
         <copy file="${lang.resource.dir}/tl/README.txt" todir="${lang.dist.dir}/tl" />
         <copy file="${lang.resource.dir}/tl/tl.ngp" todir="${lang.dist.dir}/tl" />
 
-        <copy file="${lang.resource.dir}/eo/etikedoj.txt" todir="${lang.dist.dir}/eo" />
-        <copy file="${lang.resource.dir}/eo/manual-tagger.txt" todir="${lang.dist.dir}/eo" />
-        <copy file="${lang.resource.dir}/eo/disambiguation.xml" todir="${lang.dist.dir}/eo" />
-        <copy file="${lang.resource.dir}/eo/eo.ngp" todir="${lang.dist.dir}/eo" />
-
         <copy file="${lang.resource.dir}/it/italian.dict" todir="${lang.dist.dir}/it" />
         <copy file="${lang.resource.dir}/it/italian.info" todir="${lang.dist.dir}/it" />
         <copy file="${lang.resource.dir}/it/readme-morph-it.txt" todir="${lang.dist.dir}/it" />
@@ -594,8 +587,6 @@
         <copy file="${lang.resource.dir}/pl/multiwords.txt" todir="${lang.dist.dir}/pl" />
         <copy file="${lang.resource.dir}/pl/disambiguation.xml" todir="${lang.dist.dir}/pl" />
 
-        <copy file="${lang.resource.dir}/pt/compounds.txt" todir="${lang.dist.dir}/pt" />
-
         <copy file="${lang.resource.dir}/nl/dutch.dict" todir="${lang.dist.dir}/nl" />
         <copy file="${lang.resource.dir}/nl/dutch.info" todir="${lang.dist.dir}/nl" />
         <copy file="${lang.resource.dir}/nl/dutch_synth.dict" todir="${lang.dist.dir}/nl" />
@@ -608,10 +599,6 @@
         <copy file="${lang.resource.dir}/sv/swedish.dict" todir="${lang.dist.dir}/sv" />
         <copy file="${lang.resource.dir}/sv/compounds.txt" todir="${lang.dist.dir}/sv" />
 
-        <copy file="${lang.resource.dir}/uk/ukrainian.dict" todir="${lang.dist.dir}/uk" />
-        <copy file="${lang.resource.dir}/uk/ukrainian.info" todir="${lang.dist.dir}/uk" />
-        <copy file="${lang.resource.dir}/uk/uk.ngp" todir="${lang.dist.dir}/uk" />
-
         <copy file="${lang.resource.dir}/ru/russian.dict" todir="${lang.dist.dir}/ru" />
         <copy file="${lang.resource.dir}/ru/russian.info" todir="${lang.dist.dir}/ru" />
         <copy file="${lang.resource.dir}/ru/russian_tags.txt" todir="${lang.dist.dir}/ru" />
@@ -632,8 +619,6 @@
         <copy file="${lang.resource.dir}/ro/ro.ngp" todir="${lang.dist.dir}/ro" />
         <copy file="${lang.resource.dir}/ro/added.txt" todir="${lang.dist.dir}/ro" />
 
-        <copy file="${lang.resource.dir}/sl/sl.ngp" todir="${lang.dist.dir}/sl" />
-
         <copy file="${lang.resource.dir}/sk/slovak.dict" todir="${lang.dist.dir}/sk" />
         <copy file="${lang.resource.dir}/sk/slovak.info" todir="${lang.dist.dir}/sk" />
         <copy file="${lang.resource.dir}/sk/compounds.txt" todir="${lang.dist.dir}/sk" />
@@ -643,9 +628,6 @@
         <copy file="${lang.resource.dir}/sk/slovak_tags.txt" todir="${lang.dist.dir}/sk" />
         <copy file="${lang.resource.dir}/sk/sk.ngp" todir="${lang.dist.dir}/sk" />
 
-        <copy file="${lang.resource.dir}/ml/malayalam.dict" todir="${lang.dist.dir}/ml" />
-        <copy file="${lang.resource.dir}/ml/malayalam.info" todir="${lang.dist.dir}/ml" />
-
         <copy file="${lang.resource.dir}/km/khmer.dict" todir="${lang.dist.dir}/km" />
         <copy file="${lang.resource.dir}/km/khmer.info" todir="${lang.dist.dir}/km" />
         <copy file="${lang.resource.dir}/km/khmertags.txt" todir="${lang.dist.dir}/km" />
@@ -677,14 +659,6 @@
         <copy file="${lang.resource.dir}/ast/asturian.dict" todir="${lang.dist.dir}/ast" />
         <copy file="${lang.resource.dir}/ast/asturian.info" todir="${lang.dist.dir}/ast" />
 
-        <copy file="${lang.resource.dir}/el/el.dict" todir="${lang.dist.dir}/el" />
-        <copy file="${lang.resource.dir}/el/el.info" todir="${lang.dist.dir}/el" />
-        <copy file="${lang.resource.dir}/el/el_tags.txt" todir="${lang.dist.dir}/el" />
-        <copy file="${lang.resource.dir}/el/el_synth.dict" todir="${lang.dist.dir}/el" />
-        <copy file="${lang.resource.dir}/el/el_synth.info" todir="${lang.dist.dir}/el" />
-        <copy file="${lang.resource.dir}/el/disambiguation.xml" todir="${lang.dist.dir}/el" />
-
-        <copy file="${lang.resource.dir}/xx/dummy.dict" tofile="${lang.dist.dir}/cs/czech.dict" />
         <copy todir="${dist.dir}/org/languagetool/rules">
             <fileset dir="${rules.dir}" />
         </copy>
@@ -694,9 +668,6 @@
             <fileset dir="${lang.resource.dir}" includes="**/hunspell/*.*"/>
         </copy>
         <copy file="${ext.jna.lib}" todir="${dist.dir}" />
-        <copy todir="${dist.dir}">
-            <fileset dir="${ext.dir}/native-lib" />
-        </copy>
 
     </target>
 
Index: languagetool-2.0/src/main/java/org/languagetool/openoffice/Main.java
===================================================================
--- languagetool-2.0.orig/src/main/java/org/languagetool/openoffice/Main.java
+++ languagetool-2.0/src/main/java/org/languagetool/openoffice/Main.java
@@ -523,15 +523,25 @@ public class Main extends WeakBase imple
   public final Locale[] getLocales() {
     try {
       int dims = 0;
-      for (final Language element : Language.LANGUAGES) {
-        dims += element.getCountryVariants().length;
+      boolean installed[] = new boolean[Language.LANGUAGES.length];
+      for (int i = 0; i < Language.LANGUAGES.length ; i++) {
+        final Language element = Language.LANGUAGES[i];
+        if (element.isDictionaryInstalled()) {
+          dims += element.getCountryVariants().length;
+          installed[i] = true;
+        } else {
+          installed[i] = false;
+        }
       }
       final Locale[] aLocales = new Locale[dims];
       int cnt = 0;
-      for (final Language element : Language.LANGUAGES) {
-        for (final String variant : element.getCountryVariants()) {
-          aLocales[cnt] = new Locale(element.getShortName(), variant, "");
-          cnt++;
+      for (int i = 0; i < Language.LANGUAGES.length; i++) {
+        if (installed[i]) {
+          final Language element = Language.LANGUAGES[i];
+          for (final String variant : element.getCountryVariants()) {
+            aLocales[cnt] = new Locale(element.getShortName(), variant, "");
+            cnt++;
+          }
         }
       }
       return aLocales;
Index: languagetool-2.0/src/main/java/org/languagetool/language/Japanese.java
===================================================================
--- languagetool-2.0.orig/src/main/java/org/languagetool/language/Japanese.java
+++ languagetool-2.0/src/main/java/org/languagetool/language/Japanese.java
@@ -64,6 +64,11 @@ public class Japanese extends Language {
 		return new Contributor[] { new Contributor("Takahiro Shinkai")};
 	}
 				
+	@Override
+	public boolean isDictionaryInstalled() {
+		// Japanase does not have extra dictionary => always installed
+		return true;
+	}
 		
  	
 	
Index: languagetool-2.0/src/main/java/org/languagetool/language/Chinese.java
===================================================================
--- languagetool-2.0.orig/src/main/java/org/languagetool/language/Chinese.java
+++ languagetool-2.0/src/main/java/org/languagetool/language/Chinese.java
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Locale;
 
 import org.languagetool.Language;
+import org.languagetool.JLanguageTool;
 import org.languagetool.rules.DoublePunctuationRule;
 import org.languagetool.rules.Rule;
 import org.languagetool.rules.WhitespaceRule;
@@ -71,6 +72,17 @@ public class Chinese extends Language {
 	}
 
 	@Override
+	public boolean isDictionaryInstalled() {
+		// System.err.print("Chinese -> ");
+		if (JLanguageTool.getDataBroker().resourceExists("/zh/coreDict.dct")) {
+			// System.err.println("yes");
+			return true;
+		}
+		// System.err.println("no");
+		return false;
+	}
+
+	@Override
 	public List<Class<? extends Rule>> getRelevantRules() {
 		return Arrays.asList(DoublePunctuationRule.class, WhitespaceRule.class);
 	}
Index: languagetool-2.0/src/main/java/org/languagetool/Language.java
===================================================================
--- languagetool-2.0.orig/src/main/java/org/languagetool/Language.java
+++ languagetool-2.0/src/main/java/org/languagetool/Language.java
@@ -141,11 +141,11 @@ public abstract class Language {
    * All languages supported by LanguageTool.
    */
   public static Language[] LANGUAGES = {
-    ENGLISH, GERMAN, POLISH, FRENCH, SPANISH, ITALIAN, KHMER, DUTCH, LITHUANIAN, UKRAINIAN, RUSSIAN,
-    SLOVAK, SLOVENIAN, SWEDISH, ROMANIAN, ICELANDIC, GALICIAN, CATALAN, DANISH,
-    MALAYALAM, BELARUSIAN, ESPERANTO, CHINESE, ASTURIAN, TAGALOG, BRETON, GREEK,
+    ENGLISH, GERMAN, POLISH, FRENCH, SPANISH, ITALIAN, KHMER, DUTCH, RUSSIAN,
+    SLOVAK, SWEDISH, ROMANIAN, GALICIAN, CATALAN, DANISH,
+    CHINESE, ASTURIAN, TAGALOG, BRETON,
     AMERICAN_ENGLISH, BRITISH_ENGLISH, CANADIAN_ENGLISH, SOUTH_AFRICAN_ENGLISH, NEW_ZEALAND_ENGLISH, AUSTRALIAN_ENGLISH,
-    GERMANY_GERMAN, AUSTRIAN_GERMAN, SWISS_GERMAN, PORTUGUESE, PORTUGUESE_PORTUGAL, PORTUGUESE_BRAZIL, JAPANESE,
+    GERMANY_GERMAN, AUSTRIAN_GERMAN, SWISS_GERMAN, JAPANESE,
     DEMO
   };
 
@@ -213,6 +213,22 @@ public abstract class Language {
   // -------------------------------------------------------------------------
 
   /**
+   * Check if the dictionary for the given language is installed
+   */
+  public boolean isDictionaryInstalled() {
+    // System.err.print(getName() + " -> ");
+    // guess the dictionary name from the Language name
+    // lower case and omit the variant part of the name if any
+    if (JLanguageTool.getDataBroker().resourceExists("/" + getShortName() + 
+                                                     "/" + getName().toLowerCase().replaceFirst(" .*", "") + ".dict")) {
+        // System.err.println("yes");
+        return true;
+    }
+    // System.err.println("no");
+    return false;
+  }
+
+  /**
    * Get the location of the rule file(s).
    */
   public List<String> getRuleFileName() {