diff --git a/build.gradle b/build.gradle index 441e2976a0..36ea078383 100644 --- a/build.gradle +++ b/build.gradle @@ -359,7 +359,7 @@ dependencies { // Temporary exclusion; see https://sourceforge.net/p/omegat/bugs/814/ exclude module: 'lucene-gosen' } - testImplementation "org.omegat.lucene:lucene-gosen:5.5.1:ipadic" + testImplementation("org.omegat.lucene:lucene-gosen:5.5.1:ipadic") testRuntimeOnly(libs.slf4j.jdk14) // JAXB codegen only @@ -714,11 +714,9 @@ distributions { into 'lib' } // system core plugins into modules - from('releases/modules-specific') { - into 'modules' - } - from(subprojects.collect {it.tasks.withType(Jar)}) { - into 'modules' + into('modules') { + from(subprojects.collect {it.tasks.withType(Jar)}) + from('releases/modules-specific') } eachFile { // Move main JAR up one level from lib. diff --git a/languagetools/build.gradle b/languagetools/build.gradle index 5302ced7ce..902b8bd480 100644 --- a/languagetools/build.gradle +++ b/languagetools/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' } repositories { + mavenLocal() mavenCentral() } @@ -40,11 +41,14 @@ def plugins = [ def pluginPackage = 'org.omegat.languagetool.language' def languageToolVersion = libs.versions.languagetool.get() +def languageToolGroup = libs.languagetool.core.get().group plugins.forEach { args -> def name = args.get('code') def pluginClass = "${pluginPackage}." + args.get('className') def lang = args.get('lang') sourceSets.create(name) + dependencies.add("${name}CompileOnly", project.rootProject) + dependencies.add("${name}CompileOnly", libs.languagetool.core) if (name.equals("ja")) { dependencies.add("jaImplementation", libs.languagetool.ja.get()) { // Temporary exclusion; see https://sourceforge.net/p/omegat/bugs/814/ @@ -53,11 +57,11 @@ plugins.forEach { args -> } dependencies.add("jaImplementation", 'org.omegat.lucene:lucene-gosen:5.5.1:ipadic') } else { - dependencies.add("${name}Implementation", "org.languagetool:language-${name}:${languageToolVersion}") { + dependencies.add("${name}Implementation", "${languageToolGroup}:language-${name}:${languageToolVersion}") { exclude module: 'languagetool-core' } } - configurations.getByName("${name}RuntimeClasspath").exclude(group: 'org.languagetool', module: 'languagetool-core') + configurations.getByName("${name}RuntimeClasspath").exclude(group: languageToolGroup, module: 'languagetool-core') tasks.getByName("${name}Classes") { group = 'languagetool' } @@ -77,7 +81,9 @@ plugins.forEach { args -> 'Plugin-Author': 'OmegaT team', 'Plugin-Link': 'https://omegat.org', 'Plugin-Description': "Provide ${lang} Languagetool library", - 'Plugin-Version': "${languageToolVersion}") + 'Plugin-Category': 'language', + 'Plugin-Version': "${languageToolVersion}" + ) } group = 'languagetool' } diff --git a/languagetools/src/ar/java/org/omegat/languagetool/language/ArabicPlugin.java b/languagetools/src/ar/java/org/omegat/languagetool/language/ArabicPlugin.java new file mode 100644 index 0000000000..1d4ca2c925 --- /dev/null +++ b/languagetools/src/ar/java/org/omegat/languagetool/language/ArabicPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class ArabicPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/ast/java/org/omegat/languagetool/language/AsturianPlugin.java b/languagetools/src/ast/java/org/omegat/languagetool/language/AsturianPlugin.java new file mode 100644 index 0000000000..9bc8331955 --- /dev/null +++ b/languagetools/src/ast/java/org/omegat/languagetool/language/AsturianPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class AsturianPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/be/java/org/omegat/languagetool/language/BelarusianPlugin.java b/languagetools/src/be/java/org/omegat/languagetool/language/BelarusianPlugin.java new file mode 100644 index 0000000000..794b57ce0f --- /dev/null +++ b/languagetools/src/be/java/org/omegat/languagetool/language/BelarusianPlugin.java @@ -0,0 +1,42 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +import org.languagetool.language.Belarusian; + +import org.omegat.languagetools.LanguageToolLanguageManager; + +public class BelarusianPlugin { + + @SuppressWarnings("deprecation") + public static void loadPlugins() { + LanguageToolLanguageManager.registerLTLanguage(new Belarusian()); + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/br/java/org/omegat/languagetool/language/BretonPlugin.java b/languagetools/src/br/java/org/omegat/languagetool/language/BretonPlugin.java new file mode 100644 index 0000000000..d9a8dcffdf --- /dev/null +++ b/languagetools/src/br/java/org/omegat/languagetool/language/BretonPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class BretonPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/ca/java/org/omegat/languagetool/language/CatalanPlugin.java b/languagetools/src/ca/java/org/omegat/languagetool/language/CatalanPlugin.java new file mode 100644 index 0000000000..c38d280598 --- /dev/null +++ b/languagetools/src/ca/java/org/omegat/languagetool/language/CatalanPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class CatalanPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/da/java/org/omegat/languagetool/language/DanishPlugin.java b/languagetools/src/da/java/org/omegat/languagetool/language/DanishPlugin.java new file mode 100644 index 0000000000..49d5072c2d --- /dev/null +++ b/languagetools/src/da/java/org/omegat/languagetool/language/DanishPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class DanishPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/de/java/org/omegat/languagetool/language/GermanPlugin.java b/languagetools/src/de/java/org/omegat/languagetool/language/GermanPlugin.java new file mode 100644 index 0000000000..0c6e2214f8 --- /dev/null +++ b/languagetools/src/de/java/org/omegat/languagetool/language/GermanPlugin.java @@ -0,0 +1,45 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +import org.languagetool.language.AustrianGerman; +import org.languagetool.language.GermanyGerman; +import org.languagetool.language.SwissGerman; + +import org.omegat.languagetools.LanguageToolLanguageManager; + +public class GermanPlugin { + + public static void loadPlugins() { + LanguageToolLanguageManager.registerLTLanguage(new AustrianGerman()); + LanguageToolLanguageManager.registerLTLanguage(new GermanyGerman()); + LanguageToolLanguageManager.registerLTLanguage(new SwissGerman()); + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/el/java/org/omegat/languagetool/language/GreekPlugin.java b/languagetools/src/el/java/org/omegat/languagetool/language/GreekPlugin.java new file mode 100644 index 0000000000..492d727e77 --- /dev/null +++ b/languagetools/src/el/java/org/omegat/languagetool/language/GreekPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class GreekPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/en/java/org/omegat/languagetool/language/EnglishPlugin.java b/languagetools/src/en/java/org/omegat/languagetool/language/EnglishPlugin.java new file mode 100644 index 0000000000..89494bd46c --- /dev/null +++ b/languagetools/src/en/java/org/omegat/languagetool/language/EnglishPlugin.java @@ -0,0 +1,51 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +import java.io.IOException; + +import org.languagetool.language.AmericanEnglish; +import org.languagetool.language.AustralianEnglish; +import org.languagetool.language.CanadianEnglish; +import org.languagetool.language.NewZealandEnglish; +import org.languagetool.language.SouthAfricanEnglish; + +import org.omegat.languagetools.LanguageToolLanguageManager; + +public class EnglishPlugin { + + public static void loadPlugins() throws IOException { + LanguageToolLanguageManager.registerLTLanguage(new AmericanEnglish()); + LanguageToolLanguageManager.registerLTLanguage(new AustralianEnglish()); + LanguageToolLanguageManager.registerLTLanguage(new CanadianEnglish()); + LanguageToolLanguageManager.registerLTLanguage(new NewZealandEnglish()); + LanguageToolLanguageManager.registerLTLanguage(new SouthAfricanEnglish()); + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/eo/java/org/omegat/languagetool/language/EsperantoPlugin.java b/languagetools/src/eo/java/org/omegat/languagetool/language/EsperantoPlugin.java new file mode 100644 index 0000000000..2cc7237491 --- /dev/null +++ b/languagetools/src/eo/java/org/omegat/languagetool/language/EsperantoPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class EsperantoPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/es/java/org/omegat/languagetool/language/SpanishPlugin.java b/languagetools/src/es/java/org/omegat/languagetool/language/SpanishPlugin.java new file mode 100644 index 0000000000..d89d856b1a --- /dev/null +++ b/languagetools/src/es/java/org/omegat/languagetool/language/SpanishPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class SpanishPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/fa/java/org/omegat/languagetool/language/PersianPlugin.java b/languagetools/src/fa/java/org/omegat/languagetool/language/PersianPlugin.java new file mode 100644 index 0000000000..b62fda792b --- /dev/null +++ b/languagetools/src/fa/java/org/omegat/languagetool/language/PersianPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class PersianPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/fr/java/org/omegat/languagetool/language/FrenchPlugin.java b/languagetools/src/fr/java/org/omegat/languagetool/language/FrenchPlugin.java new file mode 100644 index 0000000000..404a5d5769 --- /dev/null +++ b/languagetools/src/fr/java/org/omegat/languagetool/language/FrenchPlugin.java @@ -0,0 +1,41 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +import org.languagetool.language.French; + +import org.omegat.languagetools.LanguageToolLanguageManager; + +public class FrenchPlugin { + + public static void loadPlugins() { + LanguageToolLanguageManager.registerLTLanguage(new French()); + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/ga/java/org/omegat/languagetool/language/IrishPlugin.java b/languagetools/src/ga/java/org/omegat/languagetool/language/IrishPlugin.java new file mode 100644 index 0000000000..99532a816a --- /dev/null +++ b/languagetools/src/ga/java/org/omegat/languagetool/language/IrishPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class IrishPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/gl/java/org/omegat/languagetool/language/GalicianPlugin.java b/languagetools/src/gl/java/org/omegat/languagetool/language/GalicianPlugin.java new file mode 100644 index 0000000000..92b66f3f44 --- /dev/null +++ b/languagetools/src/gl/java/org/omegat/languagetool/language/GalicianPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class GalicianPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/it/java/org/omegat/languagetool/language/ItalianPlugin.java b/languagetools/src/it/java/org/omegat/languagetool/language/ItalianPlugin.java new file mode 100644 index 0000000000..b2f8fa6eb5 --- /dev/null +++ b/languagetools/src/it/java/org/omegat/languagetool/language/ItalianPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class ItalianPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/ja/java/org/omegat/languagetool/language/JapanesePlugin.java b/languagetools/src/ja/java/org/omegat/languagetool/language/JapanesePlugin.java new file mode 100644 index 0000000000..7b44103edc --- /dev/null +++ b/languagetools/src/ja/java/org/omegat/languagetool/language/JapanesePlugin.java @@ -0,0 +1,41 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +import org.languagetool.language.Japanese; + +import org.omegat.languagetools.LanguageToolLanguageManager; + +public class JapanesePlugin { + + public static void loadPlugins() { + LanguageToolLanguageManager.registerLTLanguage(new Japanese()); + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/km/java/org/omegat/languagetool/language/KhmerPlugin.java b/languagetools/src/km/java/org/omegat/languagetool/language/KhmerPlugin.java new file mode 100644 index 0000000000..806bbc3f10 --- /dev/null +++ b/languagetools/src/km/java/org/omegat/languagetool/language/KhmerPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class KhmerPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/nl/java/org/omegat/languagetool/language/DutchPlugin.java b/languagetools/src/nl/java/org/omegat/languagetool/language/DutchPlugin.java new file mode 100644 index 0000000000..14e5bbfcdb --- /dev/null +++ b/languagetools/src/nl/java/org/omegat/languagetool/language/DutchPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 miurahr + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class DutchPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/pl/java/org/omegat/languagetool/language/PolishPlugin.java b/languagetools/src/pl/java/org/omegat/languagetool/language/PolishPlugin.java new file mode 100644 index 0000000000..f5bd5d059b --- /dev/null +++ b/languagetools/src/pl/java/org/omegat/languagetool/language/PolishPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class PolishPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/pt/java/org/omegat/languagetool/language/PortuguesePlugin.java b/languagetools/src/pt/java/org/omegat/languagetool/language/PortuguesePlugin.java new file mode 100644 index 0000000000..9e57871971 --- /dev/null +++ b/languagetools/src/pt/java/org/omegat/languagetool/language/PortuguesePlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class PortuguesePlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/ro/java/org/omegat/languagetool/language/RomanianPlugin.java b/languagetools/src/ro/java/org/omegat/languagetool/language/RomanianPlugin.java new file mode 100644 index 0000000000..8be55e12e6 --- /dev/null +++ b/languagetools/src/ro/java/org/omegat/languagetool/language/RomanianPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class RomanianPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/ru/java/org/omegat/languagetool/language/RussianPlugin.java b/languagetools/src/ru/java/org/omegat/languagetool/language/RussianPlugin.java new file mode 100644 index 0000000000..6d8cca0122 --- /dev/null +++ b/languagetools/src/ru/java/org/omegat/languagetool/language/RussianPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class RussianPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/sk/java/org/omegat/languagetool/language/SlovakPlugin.java b/languagetools/src/sk/java/org/omegat/languagetool/language/SlovakPlugin.java new file mode 100644 index 0000000000..4b30214780 --- /dev/null +++ b/languagetools/src/sk/java/org/omegat/languagetool/language/SlovakPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class SlovakPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/sl/java/org/omegat/languagetool/language/SlovenianPlugin.java b/languagetools/src/sl/java/org/omegat/languagetool/language/SlovenianPlugin.java new file mode 100644 index 0000000000..1b47f079e9 --- /dev/null +++ b/languagetools/src/sl/java/org/omegat/languagetool/language/SlovenianPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class SlovenianPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/sv/java/org/omegat/languagetool/language/SwedishPlugin.java b/languagetools/src/sv/java/org/omegat/languagetool/language/SwedishPlugin.java new file mode 100644 index 0000000000..83d1c66511 --- /dev/null +++ b/languagetools/src/sv/java/org/omegat/languagetool/language/SwedishPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class SwedishPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/ta/java/org/omegat/languagetool/language/TamilPlugin.java b/languagetools/src/ta/java/org/omegat/languagetool/language/TamilPlugin.java new file mode 100644 index 0000000000..a4eb13c5e0 --- /dev/null +++ b/languagetools/src/ta/java/org/omegat/languagetool/language/TamilPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class TamilPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/tl/java/org/omegat/languagetool/language/TagalogPlugin.java b/languagetools/src/tl/java/org/omegat/languagetool/language/TagalogPlugin.java new file mode 100644 index 0000000000..62cdb71471 --- /dev/null +++ b/languagetools/src/tl/java/org/omegat/languagetool/language/TagalogPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class TagalogPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/uk/java/org/omegat/languagetool/language/UkrainianPlugin.java b/languagetools/src/uk/java/org/omegat/languagetool/language/UkrainianPlugin.java new file mode 100644 index 0000000000..528bce7a4e --- /dev/null +++ b/languagetools/src/uk/java/org/omegat/languagetool/language/UkrainianPlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class UkrainianPlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/src/zh/java/org/omegat/languagetool/language/ChinesePlugin.java b/languagetools/src/zh/java/org/omegat/languagetool/language/ChinesePlugin.java new file mode 100644 index 0000000000..334a0b8bea --- /dev/null +++ b/languagetools/src/zh/java/org/omegat/languagetool/language/ChinesePlugin.java @@ -0,0 +1,36 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023 Hiroshi Miura + * Home page: https://www.omegat.org/ + * Support center: https://omegat.org/support + * + * This file is part of OmegaT. + * + * OmegaT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OmegaT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.omegat.languagetool.language; + +public class ChinesePlugin { + + public static void loadPlugins() { + } + + public static void unloadPlugins() { + } + +} diff --git a/settings.gradle b/settings.gradle index 4e1c61bdf3..a2e5b672ff 100644 --- a/settings.gradle +++ b/settings.gradle @@ -18,6 +18,7 @@ include("machinetranslators:apertium", "machinetranslators:mymemory", "machinetranslators:yandex", "machinetranslators:dummy", + "languagetools", "aligner", "theme", "spellchecker:hunspell", diff --git a/src/org/omegat/Main.java b/src/org/omegat/Main.java index 31886cdbaf..30a884815f 100644 --- a/src/org/omegat/Main.java +++ b/src/org/omegat/Main.java @@ -69,6 +69,9 @@ import javax.swing.UIManager; import org.apache.commons.lang3.StringUtils; +import org.languagetool.JLanguageTool; +import org.omegat.languagetools.LanguageToolClassBroker; +import org.omegat.languagetools.LanguageToolDataBroker; import tokyo.northside.logging.ILogger; import org.omegat.CLIParameters.PSEUDO_TRANSLATE_TYPE; @@ -205,6 +208,9 @@ public static void main(String[] args) { // Do migration and load various settings. The order is important! ConvertConfigs.convert(); Preferences.init(); + // broker should be loaded before module loading + JLanguageTool.setClassBrokerBroker(new LanguageToolClassBroker()); + JLanguageTool.setDataBroker(new LanguageToolDataBroker()); PluginUtils.loadPlugins(PARAMS); FilterMaster.setFilterClasses(PluginUtils.getFilterClasses()); Preferences.initFilters(); @@ -332,15 +338,7 @@ private static void applyConfigFile(String path) { * Execute standard GUI. */ protected static int runGUI() { - ClassLoader cl = ClassLoader.getSystemClassLoader(); - MainClassLoader mainClassLoader; - if (cl instanceof MainClassLoader) { - mainClassLoader = (MainClassLoader) cl; - } else { - mainClassLoader = new MainClassLoader(cl); - } - PluginUtils.getThemePluginJars().forEach(mainClassLoader::addJarToClasspath); - UIManager.put("ClassLoader", mainClassLoader); + UIManager.put("ClassLoader", PluginUtils.getThemeClassLoader()); // macOS-specific - they must be set BEFORE any GUI calls if (Platform.isMacOSX()) { diff --git a/src/org/omegat/filters2/master/PluginUtils.java b/src/org/omegat/filters2/master/PluginUtils.java index 6fd0e64f83..da69d24112 100644 --- a/src/org/omegat/filters2/master/PluginUtils.java +++ b/src/org/omegat/filters2/master/PluginUtils.java @@ -35,7 +35,6 @@ import java.lang.reflect.Method; import java.net.JarURLConnection; import java.net.URL; -import java.net.URLClassLoader; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; @@ -56,6 +55,7 @@ import java.util.stream.Collectors; import org.omegat.CLIParameters; +import org.omegat.MainClassLoader; import org.omegat.core.Core; import org.omegat.core.data.PluginInformation; import org.omegat.tokenizer.DefaultTokenizer; @@ -79,6 +79,12 @@ public final class PluginUtils { public static final String PLUGINS_LIST_FILE = "Plugins.properties"; + private static final String PLUGIN_CATEGORY = "Plugin-Category"; + private static final String MAIN_CLASS = "Main-Class"; + private static final String MANIFEST_MF = "META-INF/MANIFEST.MF"; + private static final String OMEGAT_PLUGINS = "OmegaT-Plugins"; + private static final String OMEGAT_PLUGIN = "OmegaT-Plugin"; + /** * Plugin type definitions. */ @@ -124,6 +130,11 @@ public enum PluginType { * Spellchecker plugins. */ SPELLCHECK("spellcheck"), + /** + * language plugin that bundles LanguageTool-language module and + * spell-check dictionaries. + */ + LANGUAGE("language"), /** * When plugin does not define any of the above. */ @@ -155,6 +166,15 @@ public static PluginType getTypeByValue(String str) { private static final List> LOADED_PLUGINS = new ArrayList<>(); private static final Set PLUGIN_INFORMATIONS = new HashSet<>(); + private static final MainClassLoader themeClassloader; + private static final MainClassLoader languageClassloader; + + static { + ClassLoader cl = PluginUtils.class.getClassLoader(); + themeClassloader = new MainClassLoader(cl); + languageClassloader = new MainClassLoader(cl); + } + /** Private constructor to disallow creation */ private PluginUtils() { } @@ -185,26 +205,36 @@ public static void loadPlugins(final Map params) { boolean foundMain = false; // look on all manifests - URLClassLoader pluginsClassLoader = new URLClassLoader(urlList.toArray(new URL[0]), - PluginUtils.class.getClassLoader()); + ClassLoader cl = PluginUtils.class.getClassLoader(); + MainClassLoader pluginsClassLoader = new MainClassLoader(urlList.toArray(new URL[0]), cl); try { - Enumeration mlist = pluginsClassLoader.getResources("META-INF/MANIFEST.MF"); + Enumeration mlist = pluginsClassLoader.getResources(MANIFEST_MF); while (mlist.hasMoreElements()) { URL mu = mlist.nextElement(); try (InputStream in = mu.openStream()) { Manifest m = new Manifest(in); - if ("org.omegat.Main".equals(m.getMainAttributes().getValue("Main-Class"))) { + if ("org.omegat.Main".equals(m.getMainAttributes().getValue(MAIN_CLASS))) { // found a main manifest - not in development mode foundMain = true; } - loadFromManifest(m, pluginsClassLoader, mu); - if ("theme".equals(m.getMainAttributes().getValue("Plugin-Category"))) { + if ("theme".equals(m.getMainAttributes().getValue(PLUGIN_CATEGORY))) { String target = mu.toString(); for (URL url : urlList) { if (target.contains(url.toString())) { - THEME_PLUGIN_JARS.add(url); + themeClassloader.addJarToClasspath(url); + loadFromManifest(m, themeClassloader, mu); } } + } else if ("language".equals(m.getMainAttributes().getValue(PLUGIN_CATEGORY))) { + String target = mu.toString(); + for (URL url : urlList) { + if (target.contains(url.toString())) { + languageClassloader.addJarToClasspath(url); + loadFromManifest(m, languageClassloader, mu); + } + } + } else { + loadFromManifest(m, pluginsClassLoader, mu); } } catch (ClassNotFoundException e) { Log.log(e); @@ -298,8 +328,8 @@ protected static List populatePluginUrlList(List pluginsDirs) { for (URL url : urlList) { try (JarInputStream jarStream = new JarInputStream(url.openStream())) { Manifest mf = jarStream.getManifest(); - String pluginClass = mf.getMainAttributes().getValue("OmegaT-Plugins"); - String oldPluginClass = mf.getMainAttributes().getValue("OmegaT-Plugin"); + String pluginClass = mf.getMainAttributes().getValue(OMEGAT_PLUGINS); + String oldPluginClass = mf.getMainAttributes().getValue(OMEGAT_PLUGIN); // if the jar doesn't look like an OmegaT plugin (it doesn't // contain any "Omegat-Plugins?" attribute, we don't need to @@ -384,7 +414,7 @@ public static Class getTokenizerClassForLanguage(Language lang) { return exactResult; } - // Otherwise return a match for the language only (XX). + // Otherwise, return a match for the language only (XX). Class generalResult = searchForTokenizer(lang.getLanguageCode()); if (isDefault(generalResult)) { return generalResult; @@ -456,8 +486,12 @@ public static List> getGlossaryClasses() { return GLOSSARY_CLASSES; } - public static List getThemePluginJars() { - return THEME_PLUGIN_JARS; + public static ClassLoader getThemeClassLoader() { + return themeClassloader; + } + + public static ClassLoader getLanguageClassLoader() { + return languageClassloader; } private static final List> FILTER_CLASSES = new ArrayList<>(); @@ -474,8 +508,6 @@ public static List getThemePluginJars() { private static final List> BASE_PLUGIN_CLASSES = new ArrayList<>(); - private static final List THEME_PLUGIN_JARS = new ArrayList<>(); - /** * Parse one manifest file. * diff --git a/src/org/omegat/languagetools/LanguageToolClassBroker.java b/src/org/omegat/languagetools/LanguageToolClassBroker.java new file mode 100644 index 0000000000..204ab149b3 --- /dev/null +++ b/src/org/omegat/languagetools/LanguageToolClassBroker.java @@ -0,0 +1,48 @@ +/******************************************************************************* + OmegaT - Computer Assisted Translation (CAT) tool + with fuzzy matching, translation memory, keyword search, + glossaries, and translation leveraging into updated projects. + + Copyright (c) 2024 Hiroshi Miura + Home page: https://www.omegat.org/ + Support center: https://omegat.org/support + + This file is part of OmegaT. + + OmegaT is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OmegaT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + ******************************************************************************/ + +package org.omegat.languagetools; + +import org.languagetool.broker.ClassBroker; +import org.omegat.filters2.master.PluginUtils; + +public class LanguageToolClassBroker implements ClassBroker { + + + public LanguageToolClassBroker() { + } + + @Override + public Class forName(String qualifiedName) throws ClassNotFoundException { + Class clazz; + ClassLoader classLoader = PluginUtils.getLanguageClassLoader(); + try { + clazz = classLoader.loadClass(qualifiedName); + } catch (ClassNotFoundException e) { + clazz = LanguageToolClassBroker.class.getClassLoader().loadClass(qualifiedName); + } + return clazz; + } +} diff --git a/src/org/omegat/languagetools/LanguageToolDataBroker.java b/src/org/omegat/languagetools/LanguageToolDataBroker.java new file mode 100644 index 0000000000..1fd86de2b1 --- /dev/null +++ b/src/org/omegat/languagetools/LanguageToolDataBroker.java @@ -0,0 +1,216 @@ +/******************************************************************************* + OmegaT - Computer Assisted Translation (CAT) tool + with fuzzy matching, translation memory, keyword search, + glossaries, and translation leveraging into updated projects. + + Copyright (c) 2024 Hiroshi Miura + Home page: https://www.omegat.org/ + Support center: https://omegat.org/support + + This file is part of OmegaT. + + OmegaT is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OmegaT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + ******************************************************************************/ + +package org.omegat.languagetools; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.ResourceBundle; +import java.util.stream.Collectors; + +import org.jetbrains.annotations.NotNull; +import org.languagetool.Language; +import org.languagetool.broker.ResourceDataBroker; + +public class LanguageToolDataBroker implements ResourceDataBroker { + + private final String resourceDir; + private final String rulesDir; + + public LanguageToolDataBroker(String resourceDir, String rulesDir) { + this.resourceDir = resourceDir == null ? "" : resourceDir; + this.rulesDir = rulesDir == null ? "" : rulesDir; + } + + public LanguageToolDataBroker() { + this(ResourceDataBroker.RESOURCE_DIR, ResourceDataBroker.RULES_DIR); + } + + @Override + public @NotNull URL getFromResourceDirAsUrl(String path) { + String completePath = getCompleteResourceUrl(path); + URL resource = getAsURL(completePath); + return Objects.requireNonNull(resource); + } + + @Override + public @NotNull List getFromResourceDirAsUrls(String path) { + String completePath = getCompleteResourceUrl(path); + List resources = getAsURLs(completePath.substring(1)); + return Objects.requireNonNull(resources); + } + + private String getCompleteRulesUrl(String path) { + return this.appendPath(this.rulesDir, path); + } + + private String getCompleteResourceUrl(String path) { + return this.appendPath(this.resourceDir, path); + } + + @Override + public boolean resourceExists(String path) { + String completePath = this.getCompleteResourceUrl(path); + return this.getAsURL(completePath) != null; + } + + private String appendPath(String baseDir, String path) { + StringBuilder completePath = new StringBuilder(baseDir); + if (!rulesDir.endsWith("/") && !path.startsWith("/")) { + completePath.append('/'); + } + + if (rulesDir.endsWith("/") && path.startsWith("/") && path.length() > 1) { + completePath.append(path.substring(1)); + } else { + completePath.append(path); + } + + return completePath.toString(); + } + + @Override + public boolean ruleFileExists(String path) { + String completePath = this.getCompleteRulesUrl(path); + return this.getAsURL(completePath) != null; + } + + @Override + public @NotNull InputStream getFromResourceDirAsStream(String path) { + String completePath = getCompleteResourceUrl(path); + return Objects.requireNonNull(getAsStream(completePath)); + } + + @Override + public @NotNull List getFromResourceDirAsLines(String path) { + try (InputStream inputStram = getFromResourceDirAsStream(path); + InputStreamReader inputStreamReader = new InputStreamReader(inputStram, StandardCharsets.UTF_8); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { + return bufferedReader.lines().collect(Collectors.toList()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public InputStream getAsStream(String path) { + InputStream inputStream = ResourceDataBroker.class.getResourceAsStream(path); + if (inputStream == null) { + Language lang = LanguageToolLanguageManager.getLTLanguage( + LanguageToolLanguageManager.getProjectTargetLanguage()); + if (lang == null) { + lang = LanguageToolLanguageManager.getLTLanguage(new org.omegat.util.Language("en")); + } + if (lang != null) { + inputStream = lang.getClass().getResourceAsStream(path); + } + } + return inputStream; + } + + @Override + public URL getAsURL(String path) { + URL url = ResourceDataBroker.class.getResource(path); + if (url == null) { + Language lang = LanguageToolLanguageManager.getLTLanguage( + LanguageToolLanguageManager.getProjectTargetLanguage()); + if (lang == null) { + lang = LanguageToolLanguageManager.getLTLanguage(new org.omegat.util.Language("en")); + } + if (lang != null) { + url = lang.getClass().getResource(path); + } + } + return url; + } + + @Override + public @NotNull List getAsURLs(String path) { + List urls; + Enumeration enumeration = null; + try { + enumeration = ResourceDataBroker.class.getClassLoader().getResources(path); + } catch (IOException ignored) { + } + if (enumeration != null) { + urls = Collections.list(enumeration); + if (!urls.isEmpty()) { + return urls; + } + } + try { + Language lang = LanguageToolLanguageManager.getLTLanguage( + LanguageToolLanguageManager.getProjectTargetLanguage()); + if (lang == null) { + lang = LanguageToolLanguageManager.getLTLanguage(new org.omegat.util.Language("en")); + } + if (lang != null) { + enumeration = lang.getClass().getClassLoader().getResources(path); + } else { + return List.of(); + } + } catch (IOException ignored) { + return List.of(); + } + return Collections.list(enumeration); + } + + @Override + public @NotNull URL getFromRulesDirAsUrl(String path) { + String completePath = getCompleteRulesUrl(path); + return Objects.requireNonNull(getAsURL(completePath)); + } + + @Override + public @NotNull InputStream getFromRulesDirAsStream(String path) { + String completePath = getCompleteRulesUrl(path); + InputStream inputStream = getAsStream(completePath); + return Objects.requireNonNull(inputStream); + } + + @Override + public String getResourceDir() { + return resourceDir; + } + + @Override + public String getRulesDir() { + return rulesDir; + } + + @Override + public ResourceBundle getResourceBundle(String baseName, Locale locale) { + return ResourceBundle.getBundle(baseName, locale); + } +} diff --git a/src/org/omegat/languagetools/LanguageToolLanguageManager.java b/src/org/omegat/languagetools/LanguageToolLanguageManager.java new file mode 100644 index 0000000000..94565d5400 --- /dev/null +++ b/src/org/omegat/languagetools/LanguageToolLanguageManager.java @@ -0,0 +1,48 @@ +package org.omegat.languagetools; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.languagetool.Language; + +import org.omegat.core.Core; + + +public final class LanguageToolLanguageManager { + + private static final Set LT_LANGUAGE_CLASS_MAP = new HashSet<>(); + + private LanguageToolLanguageManager() {} + + public static void registerLTLanguage(Language language) { + LT_LANGUAGE_CLASS_MAP.add(language); + } + + static Language getLTLanguage(org.omegat.util.Language lang) { + // Search for full xx-YY match + String omLang = lang.getLanguageCode(); + String omCountry = lang.getCountryCode(); + for (Language ltLang : LT_LANGUAGE_CLASS_MAP) { + if (omLang.equalsIgnoreCase(ltLang.getShortCode())) { + List countries = Arrays.asList(ltLang.getCountries()); + if (countries.contains(omCountry)) { + return ltLang; + } + } + } + + // Search for just xx match + for (Language ltLang : LT_LANGUAGE_CLASS_MAP) { + if (omLang.equalsIgnoreCase(ltLang.getShortCode())) { + return ltLang; + } + } + return null; + } + + static org.omegat.util.Language getProjectTargetLanguage() { + return Core.getProject().getProjectProperties().getTargetLanguage(); + } +} diff --git a/src/org/omegat/languagetools/LanguageToolNativeBridge.java b/src/org/omegat/languagetools/LanguageToolNativeBridge.java index e12892ffb2..62188a75c3 100644 --- a/src/org/omegat/languagetools/LanguageToolNativeBridge.java +++ b/src/org/omegat/languagetools/LanguageToolNativeBridge.java @@ -26,7 +26,6 @@ **************************************************************************/ package org.omegat.languagetools; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Set; @@ -39,6 +38,7 @@ import org.languagetool.rules.RuleMatch; import org.languagetool.rules.bitext.BitextRule; import org.languagetool.tools.Tools; + import org.omegat.util.Log; public class LanguageToolNativeBridge extends BaseLanguageToolBridge { @@ -135,34 +135,6 @@ List getRuleMatches(String sourceText, String translationText) throws * getLanguageForLanguageNameOnly in {@link Languages}. */ public static Language getLTLanguage(org.omegat.util.Language lang) { - List ltLangs = Languages.get(); - - // Search for full xx-YY match - String omLang = lang.getLanguageCode(); - String omCountry = lang.getCountryCode(); - for (Language ltLang : ltLangs) { - if (omLang.equalsIgnoreCase(ltLang.getShortCode())) { - List countries = Arrays.asList(ltLang.getCountries()); - if (countries.contains(omCountry)) { - return ltLang; - } - } - } - - // Search for just xx match - for (Language ltLang : ltLangs) { - if (omLang.equalsIgnoreCase(ltLang.getShortCode()) && ltLang.hasVariant()) { - Language defaultVariant = ltLang.getDefaultLanguageVariant(); - if (defaultVariant != null) { - return ltLang; - } - } - } - for (Language ltLang : ltLangs) { - if (omLang.equalsIgnoreCase(ltLang.getShortCode()) && !ltLang.hasVariant()) { - return ltLang; - } - } - return null; + return LanguageToolLanguageManager.getLTLanguage(lang); } } diff --git a/src/org/omegat/languagetools/LanguageToolWrapper.java b/src/org/omegat/languagetools/LanguageToolWrapper.java index d475b30bb6..bbbd95b19c 100644 --- a/src/org/omegat/languagetools/LanguageToolWrapper.java +++ b/src/org/omegat/languagetools/LanguageToolWrapper.java @@ -32,6 +32,7 @@ import javax.swing.text.Highlighter.HighlightPainter; +import org.languagetool.JLanguageTool; import org.omegat.core.Core; import org.omegat.core.CoreEvents; import org.omegat.core.data.SourceTextEntry; diff --git a/test/src/org/omegat/languagetools/LanguageToolTest.java b/test/src/org/omegat/languagetools/LanguageToolTest.java index 5f5f54851d..8be0e07ea2 100644 --- a/test/src/org/omegat/languagetools/LanguageToolTest.java +++ b/test/src/org/omegat/languagetools/LanguageToolTest.java @@ -36,9 +36,16 @@ import java.util.Locale; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.languagetool.JLanguageTool; import org.languagetool.Languages; +import org.languagetool.language.AmericanEnglish; +import org.languagetool.language.Belarusian; +import org.languagetool.language.CanadianEnglish; +import org.languagetool.language.English; +import org.languagetool.language.French; +import org.languagetool.language.Japanese; import org.languagetool.rules.RuleMatch; import org.languagetool.rules.patterns.PatternRule; import org.languagetool.server.HTTPServer; @@ -54,6 +61,19 @@ public class LanguageToolTest { private static final Language SOURCE_LANG = new Language(Locale.FRENCH); private static final Language TARGET_LANG = new Language(Locale.ENGLISH); + @BeforeClass + @SuppressWarnings("deprecation") + public static void setUpClass() { + JLanguageTool.setClassBrokerBroker(new LanguageToolClassBroker()); + JLanguageTool.setDataBroker(new LanguageToolDataBroker()); + LanguageToolLanguageManager.registerLTLanguage(new English()); + LanguageToolLanguageManager.registerLTLanguage(new AmericanEnglish()); + LanguageToolLanguageManager.registerLTLanguage(new CanadianEnglish()); + LanguageToolLanguageManager.registerLTLanguage(new Belarusian()); + LanguageToolLanguageManager.registerLTLanguage(new French()); + LanguageToolLanguageManager.registerLTLanguage(new Japanese()); + } + @Before public final void setUp() throws Exception { TestPreferencesInitializer.init();