From a9c0eddef53934603ed3b62c319c4fd1a8916524 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 01:15:34 +0900 Subject: [PATCH 01/85] chore(deps): bump com.github.spotbugs from 6.0.15 to 6.0.16 (#1054) Bumps com.github.spotbugs from 6.0.15 to 6.0.16. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 61c1eb6de3..c501194237 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -154,7 +154,7 @@ xmlunit = ["xmlunit-core", "xmlunit-assertj", "assertj"] morfologik = ['morfologik', 'morfologik-speller'] [plugins] -spotbugs = {id = "com.github.spotbugs", version = "6.0.15"} +spotbugs = {id = "com.github.spotbugs", version = "6.0.16"} spotless = {id = "com.diffplug.spotless", version = "6.25.0"} launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.5"} versions = {id = "com.github.ben-manes.versions", version = "0.51.0"} From 0b46861771213b9a71bb41060d3e76e12bdecb38 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 13 Jun 2024 12:52:36 +0900 Subject: [PATCH 02/85] chore: bump jdk 11.0.23+9 for test-integ (#1056) also - update Gradle@8.8 for test-integ - ca certificates@1.0.3-1 - compose to specify openjdk@17.0.11.0.0+9 Signed-off-by: Hiroshi Miura --- compose.yml | 4 ++-- test-integration/docker/client/Dockerfile | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compose.yml b/compose.yml index da7732afc2..ec1016da91 100644 --- a/compose.yml +++ b/compose.yml @@ -16,8 +16,8 @@ services: context: test-integration/docker/client args: JAVA: 17 - JDKVER: jdk_17.0.8.1.0+1 - GRADLE: 8.4 + JDKVER: jdk_17.0.11.0.0+9 + GRADLE: 8.8 depends_on: - server volumes: diff --git a/test-integration/docker/client/Dockerfile b/test-integration/docker/client/Dockerfile index 015aa11bfa..251ff66f42 100644 --- a/test-integration/docker/client/Dockerfile +++ b/test-integration/docker/client/Dockerfile @@ -3,7 +3,7 @@ # with fuzzy matching, translation memory, keyword search, # glossaries, and translation leveraging into updated projects. # -# Copyright (C) 2022,2023 Hiroshi Miura +# Copyright (C) 2022-2024 Hiroshi Miura # Home page: https://www.omegat.org/ # Support center: https://omegat.org/support # @@ -24,13 +24,13 @@ # **************************************************************************/ # -FROM debian:bullseye-slim -ARG CAVER=1.0.2-1 +FROM debian:bookworm-slim +ARG CAVER=1.0.3-1 ARG JAVA=11 -ARG JDKVER=jdk_11.0.20.1.0+1 -ARG GRADLE=8.4 +ARG JDKVER=jdk_11.0.23.0.0+9 +ARG GRADLE=8.8 RUN apt-get -y update && apt-get upgrade -y && apt-get install -y openssh-client git inotify-tools curl subversion unzip rsync \ - java-common libasound2 libfontconfig1 libfreetype6 libxi6 libxrender1 libxtst6 p11-kit + java-common libasound2 libfontconfig1 libfreetype6 libxi6 libxrender1 libxtst6 p11-kit openjdk-17-jdk RUN adduser --disabled-password --gecos "" --home /home/omegat --shell /bin/bash omegat && mkdir -p /home/omegat/.ssh RUN chown -R omegat.omegat /home/omegat COPY --chown=omegat ssh_config /home/omegat/.ssh/config From 176037d3ee6e0c89019abef966753d1d8944221a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:44:29 +0900 Subject: [PATCH 03/85] chore(deps): bump com.gradle.develocity from 3.17.4 to 3.17.5 (#1058) Bumps com.gradle.develocity from 3.17.4 to 3.17.5. --- updated-dependencies: - dependency-name: com.gradle.develocity dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 5d1b1d601a..4e1c61bdf3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,6 @@ plugins { id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' - id 'com.gradle.develocity' version '3.17.4' + id 'com.gradle.develocity' version '3.17.5' } develocity { buildScan { From 51f0d34292b32a12825525725f30c08367f0c3bb Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Fri, 14 Jun 2024 10:03:12 +0900 Subject: [PATCH 04/85] refactor: add IMainWindow#resetDesktopLayout (#1059) - Extend IMainWindow API - Remove dependency to "raw" mainWindow from MainWindowMenuHandler - Update test codes according to API Signed-off-by: Hiroshi Miura --- src/org/omegat/gui/main/ConsoleWindow.java | 4 ++++ src/org/omegat/gui/main/IMainWindow.java | 5 +++++ src/org/omegat/gui/main/MainWindow.java | 7 +++++++ src/org/omegat/gui/main/MainWindowMenuHandler.java | 2 +- .../omegat/gui/preferences/view/AppearanceController.java | 4 +--- .../src/org/omegat/gui/main/TestMainWindow.java | 4 ++++ .../src/org/omegat/core/data/TestTeamIntegrationChild.java | 4 ++++ test/fixtures/org/omegat/core/TestCore.java | 4 ++++ 8 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/org/omegat/gui/main/ConsoleWindow.java b/src/org/omegat/gui/main/ConsoleWindow.java index 30aa0a3003..2695c23209 100644 --- a/src/org/omegat/gui/main/ConsoleWindow.java +++ b/src/org/omegat/gui/main/ConsoleWindow.java @@ -142,6 +142,10 @@ public DockingDesktop getDesktop() { return null; } + @Override + public void resetDesktopLayout() { + } + public Cursor getCursor() { return Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); } diff --git a/src/org/omegat/gui/main/IMainWindow.java b/src/org/omegat/gui/main/IMainWindow.java index 50b7f7b6ba..987ccb8ffb 100644 --- a/src/org/omegat/gui/main/IMainWindow.java +++ b/src/org/omegat/gui/main/IMainWindow.java @@ -204,4 +204,9 @@ public interface IMainWindow { * Retrieve main docking desktop. */ DockingDesktop getDesktop(); + + /** + * Restores the main window layout to the default values. + */ + default void resetDesktopLayout() {} } diff --git a/src/org/omegat/gui/main/MainWindow.java b/src/org/omegat/gui/main/MainWindow.java index f6d34a9082..14d41379a2 100644 --- a/src/org/omegat/gui/main/MainWindow.java +++ b/src/org/omegat/gui/main/MainWindow.java @@ -176,6 +176,13 @@ public void onApplicationShutdown() { }); } + /** + * {@inheritDoc} + */ + public void resetDesktopLayout() { + MainWindowUI.resetDesktopLayout(this); + } + @SuppressWarnings("unchecked") private void initMainMenu() { MainWindowMenuHandler mainWindowMenuHandler = new MainWindowMenuHandler(this); diff --git a/src/org/omegat/gui/main/MainWindowMenuHandler.java b/src/org/omegat/gui/main/MainWindowMenuHandler.java index 5bc5d721c7..83bc925860 100644 --- a/src/org/omegat/gui/main/MainWindowMenuHandler.java +++ b/src/org/omegat/gui/main/MainWindowMenuHandler.java @@ -988,7 +988,7 @@ public void optionsWorkflowMenuItemActionPerformed() { * defaults. */ public void viewRestoreGUIMenuItemActionPerformed() { - MainWindowUI.resetDesktopLayout(mainWindow); + Core.getMainWindow().resetDesktopLayout(); } public void optionsAccessConfigDirMenuItemActionPerformed() { diff --git a/src/org/omegat/gui/preferences/view/AppearanceController.java b/src/org/omegat/gui/preferences/view/AppearanceController.java index 43e36419eb..491bd0f542 100644 --- a/src/org/omegat/gui/preferences/view/AppearanceController.java +++ b/src/org/omegat/gui/preferences/view/AppearanceController.java @@ -40,8 +40,6 @@ import org.openide.awt.Mnemonics; import org.omegat.core.Core; -import org.omegat.gui.main.MainWindow; -import org.omegat.gui.main.MainWindowUI; import org.omegat.gui.preferences.BasePreferencesController; import org.omegat.gui.preferences.IMenuPreferece; import org.omegat.gui.preferences.MainMenuUI; @@ -188,7 +186,7 @@ protected void initFromPrefs() { private void initListeners() { panel.restoreWindowButton - .addActionListener(e -> MainWindowUI.resetDesktopLayout((MainWindow) Core.getMainWindow())); + .addActionListener(e -> Core.getMainWindow().resetDesktopLayout()); panel.cbLightThemeSelect.addActionListener(e -> setRestartRequired(isModified())); panel.cbDarkThemeSelect.addActionListener(e -> setRestartRequired(isModified())); panel.useDarkThemeRB.addActionListener(e -> setRestartRequired(isModified())); diff --git a/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java b/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java index 8e7f1a6a2d..ca46dbf691 100644 --- a/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java +++ b/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java @@ -291,4 +291,8 @@ public DockingDesktop getDesktop() { return desktop; } + @Override + public void resetDesktopLayout() { + } + } diff --git a/test-integration/src/org/omegat/core/data/TestTeamIntegrationChild.java b/test-integration/src/org/omegat/core/data/TestTeamIntegrationChild.java index aeada09dd3..603734aff0 100644 --- a/test-integration/src/org/omegat/core/data/TestTeamIntegrationChild.java +++ b/test-integration/src/org/omegat/core/data/TestTeamIntegrationChild.java @@ -678,6 +678,10 @@ public DockingDesktop getDesktop() { return null; } + @Override + public void resetDesktopLayout() { + } + public Cursor getCursor() { return null; } diff --git a/test/fixtures/org/omegat/core/TestCore.java b/test/fixtures/org/omegat/core/TestCore.java index bda24d9a09..1dd19b617d 100644 --- a/test/fixtures/org/omegat/core/TestCore.java +++ b/test/fixtures/org/omegat/core/TestCore.java @@ -274,6 +274,10 @@ public DockingDesktop getDesktop() { return null; } + @Override + public void resetDesktopLayout() { + } + public Cursor getCursor() { return null; } From 592684eaa7c60a7247ff577f49ede9db1223dd32 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Fri, 14 Jun 2024 13:42:17 +0900 Subject: [PATCH 05/85] chore: test-integ: fix spawn with Java 17 (#1061) * chore: test-integ: fix spawn with Java 17 Java 13 and later change launch mechanism on linux https://bugs.openjdk.org/browse/JDK-8213192 This fixes a child process spawn error on Java 17 Signed-off-by: Hiroshi Miura * style: spotless apply Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- .../src/org/omegat/core/data/TestTeamIntegration.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test-integration/src/org/omegat/core/data/TestTeamIntegration.java b/test-integration/src/org/omegat/core/data/TestTeamIntegration.java index ba841f2c89..3442695c38 100644 --- a/test-integration/src/org/omegat/core/data/TestTeamIntegration.java +++ b/test-integration/src/org/omegat/core/data/TestTeamIntegration.java @@ -29,6 +29,7 @@ import java.io.InputStream; import java.lang.management.ManagementFactory; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; @@ -409,8 +410,10 @@ static class Run extends Thread { if (!new File(DIR + "/" + source + "/omegat/").mkdirs()) { throw new Exception("Impossible to create test dir"); } + // Get `java` command path from java.home + Path javaBin = Paths.get(System.getProperty("java.home")).resolve("bin/java"); List cmd = new ArrayList<>(); - cmd.add("java"); + cmd.add(javaBin.toString()); cmd.add("-Duser.name=" + source); if (logConfig != null) { cmd.add("-Djava.util.logging.config.file=" + logConfig); From 62150a7c65e7b9f1b66ba3ec822c9a553e7e1066 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:22:32 +0900 Subject: [PATCH 06/85] chore(deps): bump jgit from 6.9.0.202403050737-r to 6.10.0.202406032230-r (#1057) * chore(deps): bump jgit Bumps `jgit` from 6.9.0.202403050737-r to 6.10.0.202406032230-r. Updates `org.eclipse.jgit:org.eclipse.jgit` from 6.9.0.202403050737-r to 6.10.0.202406032230-r Updates `org.eclipse.jgit:org.eclipse.jgit.ssh.apache` from 6.9.0.202403050737-r to 6.10.0.202406032230-r Updates `org.eclipse.jgit:org.eclipse.jgit.ssh.apache.agent` from 6.9.0.202403050737-r to 6.10.0.202406032230-r Updates `org.eclipse.jgit:org.eclipse.jgit.http.apache` from 6.9.0.202403050737-r to 6.10.0.202406032230-r Updates `org.eclipse.jgit:org.eclipse.jgit.gpg.bc` from 6.9.0.202403050737-r to 6.10.0.202406032230-r --- updated-dependencies: - dependency-name: org.eclipse.jgit:org.eclipse.jgit dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.eclipse.jgit:org.eclipse.jgit.ssh.apache dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.eclipse.jgit:org.eclipse.jgit.ssh.apache.agent dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.eclipse.jgit:org.eclipse.jgit.http.apache dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.eclipse.jgit:org.eclipse.jgit.gpg.bc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * chore(deps): bump bouncycastle(bc) Bumps `bouncycastle` from 1.77 to 1.78.1. Signed-off-by: Hiroshi Miura --------- Signed-off-by: dependabot[bot] Signed-off-by: Hiroshi Miura Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Hiroshi Miura --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c501194237..2eb8c78c18 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,11 +17,11 @@ lucene = "5.5.5" checkstyle = "8.45.1" guava = "32.1.2-jre" annotations = "23.0.0" -jgit = "6.9.0.202403050737-r" +jgit = "6.10.0.202406032230-r" svnkit = "1.10.11" ivy = "2.5.2" jackson = "2.16.1" -bc = "1.77" +bc = "1.78.1" nashorn = "15.4" caffeine = "3.1.8" wiremock = "3.6.0" From ed70bd1dcee0bd83846b61fea21d7660abc9193d Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 15 Jun 2024 09:26:55 +0900 Subject: [PATCH 07/85] refactor: reduce direct reference to real MainWindow object from MenuHandler (#1062) It is required to decouple MenuHandler with real MainWindow object reference to allow mocking MainWindow in Acceptance Test. This changes a reference to mainWindow field of MainWindowMenuHandler to get application frame when exit application. Signed-off-by: Hiroshi Miura --- src/org/omegat/gui/main/MainWindowMenuHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/omegat/gui/main/MainWindowMenuHandler.java b/src/org/omegat/gui/main/MainWindowMenuHandler.java index 83bc925860..d241ebe28b 100644 --- a/src/org/omegat/gui/main/MainWindowMenuHandler.java +++ b/src/org/omegat/gui/main/MainWindowMenuHandler.java @@ -409,7 +409,7 @@ protected void prepareForExit(Runnable onCompletion) { // RFE 1302358 // Add Yes/No Warning before OmegaT quits if (projectModified || Preferences.isPreference(Preferences.ALWAYS_CONFIRM_QUIT)) { - if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(mainWindow.getApplicationFrame(), + if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(Core.getMainWindow().getApplicationFrame(), OStrings.getString("MW_QUIT_CONFIRM"), OStrings.getString("CONFIRM_DIALOG_TITLE"), JOptionPane.YES_NO_OPTION)) { return; From ae1ac0b6e2ac18f16f15fd3b22132d099e6791b4 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 16 Jun 2024 10:45:58 +0900 Subject: [PATCH 08/85] chore(ci): bump bundle JRE@17.0.23+9 (#1064) Signed-off-by: Hiroshi Miura --- ci/azure-pipelines/build_steps.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ci/azure-pipelines/build_steps.yml b/ci/azure-pipelines/build_steps.yml index 24d465e877..5b580c68e6 100644 --- a/ci/azure-pipelines/build_steps.yml +++ b/ci/azure-pipelines/build_steps.yml @@ -7,12 +7,12 @@ steps: mkdir -p $(System.ArtifactsDirectory)/asset cd $(System.ArtifactsDirectory)/asset || exit 1 jres=( - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9/OpenJDK17U-jre_aarch64_mac_hotspot_17.0.9_9.tar.gz - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9/OpenJDK17U-jre_aarch64_linux_hotspot_17.0.9_9.tar.gz - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9/OpenJDK17U-jre_x64_linux_hotspot_17.0.9_9.tar.gz - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9/OpenJDK17U-jre_x64_mac_hotspot_17.0.9_9.tar.gz - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9.1/OpenJDK17U-jre_x64_windows_hotspot_17.0.9_9.zip - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9.1/OpenJDK17U-jre_x86-32_windows_hotspot_17.0.9_9.zip + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9/OpenJDK17U-jre_aarch64_mac_hotspot_17.0.23_9.tar.gz + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9/OpenJDK17U-jre_aarch64_linux_hotspot_17.0.23_9.tar.gz + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9/OpenJDK17U-jre_x64_linux_hotspot_17.0.23_9.tar.gz + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9/OpenJDK17U-jre_x64_mac_hotspot_17.0.23_9.tar.gz + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9.1/OpenJDK17U-jre_x64_windows_hotspot_17.0.23_9.zip + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9.1/OpenJDK17U-jre_x86-32_windows_hotspot_17.0.23_9.zip ) for url in "${jres[@]}"; do curl -L -O "$url" @@ -45,4 +45,4 @@ steps: exit 1 fi condition: always() - displayName: Stop Gradle daemon \ No newline at end of file + displayName: Stop Gradle daemon From 3d883f93a76b373194ba2421d45d263587e0c582 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 16 Jun 2024 11:17:13 +0900 Subject: [PATCH 09/85] chore(ci): change build scripts (#1065) - move scripts to check version after cache resume to speed up - change scp option to "-p -s" for publish_* scripts to use SFTP for upload and preserve build date/time Signed-off-by: Hiroshi Miura --- azure-pipelines.yml | 24 ++++++++++++++++++++++-- ci/azure-pipelines/build_steps.yml | 11 ----------- ci/azure-pipelines/publish_release.yml | 2 +- ci/azure-pipelines/publish_weekly.yml | 2 +- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a3d7a04f6b..ff31617b4d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -140,10 +140,20 @@ stages: - checkout: self fetchDepth: 1 fetchTags: false + - template: ci/azure-pipelines/build_steps.yml + - script: echo "##vso[task.setvariable variable=result;]false" + condition: failed() - script: | version=$(./gradlew -qq printVersion | head -n -1 ) echo "##vso[task.setvariable variable=version]$version" - - template: ci/azure-pipelines/build_steps.yml + # stop the Gradle daemon to ensure no files are left open (impacting the save cache operation later) + ./gradlew --stop + # Check task result + if [[ "$(result)" == "false" ]]; then + exit 1 + fi + condition: always() + displayName: Stop Gradle daemon - template: ci/azure-pipelines/publish_weekly.yml parameters: omegatVersion: $(version) @@ -168,10 +178,20 @@ stages: - checkout: self fetchDepth: 0 fetchTags: true + - template: ci/azure-pipelines/build_steps.yml + - script: echo "##vso[task.setvariable variable=result;]false" + condition: failed() - script: | version=$(./gradlew -qq printVersion | head -n -1 ) echo "##vso[task.setvariable variable=version]$version" - - template: ci/azure-pipelines/build_steps.yml + # stop the Gradle daemon to ensure no files are left open (impacting the save cache operation later) + ./gradlew --stop + # Check task result + if [[ "$(result)" == "false" ]]; then + exit 1 + fi + condition: always() + displayName: Stop Gradle daemon - template: ci/azure-pipelines/publish_release.yml parameters: omegatVersion: $(version) diff --git a/ci/azure-pipelines/build_steps.yml b/ci/azure-pipelines/build_steps.yml index 5b580c68e6..b42f75b5b5 100644 --- a/ci/azure-pipelines/build_steps.yml +++ b/ci/azure-pipelines/build_steps.yml @@ -35,14 +35,3 @@ steps: options: '--build-cache -PenvIsCi --scan -PassetDir=$(System.ArtifactsDirectory)/asset' jdkVersionOption: '1.17' displayName: 'Build distribution packages and docs' - - script: echo "##vso[task.setvariable variable=result;]false" - condition: failed() - - script: | - # stop the Gradle daemon to ensure no files are left open (impacting the save cache operation later) - ./gradlew --stop - # Check task result - if [[ "$(result)" == "false" ]]; then - exit 1 - fi - condition: always() - displayName: Stop Gradle daemon diff --git a/ci/azure-pipelines/publish_release.yml b/ci/azure-pipelines/publish_release.yml index 57891d1d1e..805e660b40 100644 --- a/ci/azure-pipelines/publish_release.yml +++ b/ci/azure-pipelines/publish_release.yml @@ -15,5 +15,5 @@ steps: dest=$(SOURCEFORGE_FILE_USER)@frs.sourceforge.net destdir="/home/frs/project/omegat/OmegaT\\ -\\ Latest/OmegaT\\ ${{ parameters.omegatVersion }}/" echo "mkdir $destdir" | SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e sftp -v $dest || true - SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -r -v -oStrictHostKeyChecking=no $srcdir/* "$dest:$destdir" + SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -p -s -oStrictHostKeyChecking=no $srcdir/* "$dest:$destdir" diff --git a/ci/azure-pipelines/publish_weekly.yml b/ci/azure-pipelines/publish_weekly.yml index a12368fccc..c77dbd9173 100644 --- a/ci/azure-pipelines/publish_weekly.yml +++ b/ci/azure-pipelines/publish_weekly.yml @@ -16,4 +16,4 @@ steps: dest=$(SOURCEFORGE_FILE_USER)@frs.sourceforge.net destdir=/home/frs/project/omegat/Weekly echo "mkdir $destdir" | SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e sftp -v $dest || true - SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -r -v -oStrictHostKeyChecking=no $srcdir/* $dest:$destdir + SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -p -s -oStrictHostKeyChecking=no $srcdir/* $dest:$destdir From 7c22b2a6ec0491fb4d4926fefb22d15968fc31a8 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 16 Jun 2024 12:10:15 +0900 Subject: [PATCH 10/85] chore(ci): update jre@17.0.11+9 Signed-off-by: Hiroshi Miura --- ci/azure-pipelines/build_steps.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ci/azure-pipelines/build_steps.yml b/ci/azure-pipelines/build_steps.yml index b42f75b5b5..de885b0b16 100644 --- a/ci/azure-pipelines/build_steps.yml +++ b/ci/azure-pipelines/build_steps.yml @@ -7,12 +7,12 @@ steps: mkdir -p $(System.ArtifactsDirectory)/asset cd $(System.ArtifactsDirectory)/asset || exit 1 jres=( - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9/OpenJDK17U-jre_aarch64_mac_hotspot_17.0.23_9.tar.gz - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9/OpenJDK17U-jre_aarch64_linux_hotspot_17.0.23_9.tar.gz - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9/OpenJDK17U-jre_x64_linux_hotspot_17.0.23_9.tar.gz - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9/OpenJDK17U-jre_x64_mac_hotspot_17.0.23_9.tar.gz - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9.1/OpenJDK17U-jre_x64_windows_hotspot_17.0.23_9.zip - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.23%2B9.1/OpenJDK17U-jre_x86-32_windows_hotspot_17.0.23_9.zip + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.11%2B9/OpenJDK17U-jre_aarch64_mac_hotspot_17.0.11_9.tar.gz + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.11%2B9/OpenJDK17U-jre_aarch64_linux_hotspot_17.0.11_9.tar.gz + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.11%2B9/OpenJDK17U-jre_x64_linux_hotspot_17.0.11_9.tar.gz + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.11%2B9/OpenJDK17U-jre_x64_mac_hotspot_17.0.11_9.tar.gz + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.11%2B9/OpenJDK17U-jre_x64_windows_hotspot_17.0.11_9.zip + https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.11%2B9/OpenJDK17U-jre_x86-32_windows_hotspot_17.0.11_9.zip ) for url in "${jres[@]}"; do curl -L -O "$url" From cf30b1e9a275f98ab79d5ed436884d29a270eb33 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 16 Jun 2024 16:45:41 +0900 Subject: [PATCH 11/85] chore(ci): update weekly release upload script Signed-off-by: Hiroshi Miura --- ci/azure-pipelines/publish_weekly.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ci/azure-pipelines/publish_weekly.yml b/ci/azure-pipelines/publish_weekly.yml index c77dbd9173..4926213aa0 100644 --- a/ci/azure-pipelines/publish_weekly.yml +++ b/ci/azure-pipelines/publish_weekly.yml @@ -13,7 +13,8 @@ steps: script: | echo "Push OmegaT ${{ parameters.omegatVersion }} files to SourceForge file manager" srcdir=$(system.defaultworkingdirectory)/build/distributions/ + ls -l $srcdir/* dest=$(SOURCEFORGE_FILE_USER)@frs.sourceforge.net destdir=/home/frs/project/omegat/Weekly - echo "mkdir $destdir" | SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e sftp -v $dest || true - SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -p -s -oStrictHostKeyChecking=no $srcdir/* $dest:$destdir + echo "mkdir $destdir" | SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e sftp -oStrictHostKeyChecking=no $dest || true + SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -s -oStrictHostKeyChecking=no $srcdir/* $dest:$destdir From f5504cfb43f12b7bf9c80e1ed717c3ceee449b1a Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 16 Jun 2024 17:02:06 +0900 Subject: [PATCH 12/85] refactor: avoid usage of direct LT language class (#1066) - When migrating Java platform module system(JPMS), LT need to move package paths of language classes, so we should avoid direct reference of LT language classes. - We can use LT utility methods; Languages.getLanguageByName getLanguageByShortCode getLanguageByLocale Signed-off-by: Hiroshi Miura --- .../languagetools/LanguageToolTest.java | 23 ++++++++----------- .../LuceneGosenCompatibilityTest.java | 8 ++++--- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/test/src/org/omegat/languagetools/LanguageToolTest.java b/test/src/org/omegat/languagetools/LanguageToolTest.java index 1bff75fb60..5f5f54851d 100644 --- a/test/src/org/omegat/languagetools/LanguageToolTest.java +++ b/test/src/org/omegat/languagetools/LanguageToolTest.java @@ -38,10 +38,7 @@ import org.junit.Before; import org.junit.Test; import org.languagetool.JLanguageTool; -import org.languagetool.language.AmericanEnglish; -import org.languagetool.language.CanadianEnglish; -import org.languagetool.language.English; -import org.languagetool.language.French; +import org.languagetool.Languages; import org.languagetool.rules.RuleMatch; import org.languagetool.rules.patterns.PatternRule; import org.languagetool.server.HTTPServer; @@ -65,7 +62,7 @@ public final void setUp() throws Exception { @Test @SuppressWarnings("deprecation") public void testExecuteLanguageToolCheck() throws Exception { - JLanguageTool lt = new JLanguageTool(new org.languagetool.language.Belarusian()); + JLanguageTool lt = new JLanguageTool(Languages.getLanguageForShortCode("be")); // The test string is Belarusian; originally it was actual UTF-8, // but that causes the test to fail when environment encodings aren't set @@ -77,7 +74,7 @@ public void testExecuteLanguageToolCheck() throws Exception { @Test public void testFrench() throws Exception { - JLanguageTool lt = new JLanguageTool(new French()); + JLanguageTool lt = new JLanguageTool(Languages.getLanguageForShortCode("fr")); // example from https://github.com/languagetool-org/languagetool/issues/2852 List matches = lt.check("Il est par cons\u00E9quent perdue."); @@ -87,7 +84,7 @@ public void testFrench() throws Exception { @Test public void testEnglish() throws Exception { - JLanguageTool lt = new JLanguageTool(new AmericanEnglish()); + JLanguageTool lt = new JLanguageTool(Languages.getLanguageForLocale(new Locale("en", "US"))); List matches = lt.check("Check test"); assertEquals(0, matches.size()); @@ -152,29 +149,29 @@ public void testWrapperInit() throws Exception { public void testLanguageMapping() { { org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("en-US")); - assertEquals(AmericanEnglish.class, lang.getClass()); + assertEquals(Languages.getLanguageForLocale(new Locale("en", "US")).getClass(), lang.getClass()); } { org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("en-CA")); - assertEquals(CanadianEnglish.class, lang.getClass()); + assertEquals(Languages.getLanguageForLocale(new Locale("en", "CA")).getClass(), lang.getClass()); } { org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("en")); - assertEquals(English.class, lang.getClass()); + assertEquals(Languages.getLanguageForShortCode("en").getClass(), lang.getClass()); } { // Unknown region--fall back to generic class org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("en-JA")); - assertEquals(English.class, lang.getClass()); + assertEquals(Languages.getLanguageForShortCode("en").getClass(), lang.getClass()); } { org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("be-BY")); - assertEquals(org.languagetool.language.Belarusian.class, lang.getClass()); + assertEquals(Languages.getLanguageForShortCode("be").getClass(), lang.getClass()); } { // Belarusian is offered in be-BY only; ensure hit with just "be" org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("be")); - assertEquals(org.languagetool.language.Belarusian.class, lang.getClass()); + assertEquals(Languages.getLanguageForShortCode("be").getClass(), lang.getClass()); } { org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("xyz")); diff --git a/test/src/org/omegat/languagetools/LuceneGosenCompatibilityTest.java b/test/src/org/omegat/languagetools/LuceneGosenCompatibilityTest.java index beac596f99..7ed786f92f 100644 --- a/test/src/org/omegat/languagetools/LuceneGosenCompatibilityTest.java +++ b/test/src/org/omegat/languagetools/LuceneGosenCompatibilityTest.java @@ -30,6 +30,7 @@ import static org.junit.Assert.assertTrue; import java.util.List; +import java.util.Objects; import net.java.sen.SenFactory; import net.java.sen.StringTagger; @@ -37,7 +38,7 @@ import org.junit.Test; import org.languagetool.JLanguageTool; -import org.languagetool.language.Japanese; +import org.languagetool.Languages; import org.languagetool.rules.RuleMatch; import org.languagetool.rules.patterns.PatternRule; @@ -45,7 +46,8 @@ public class LuceneGosenCompatibilityTest { /** * Regression test for bugs#1204. - * https://sourceforge.net/p/omegat/bugs/1204/ + * + * LanguageTool6 lucene-gosen-ipadic from omegat project is incompatible */ @Test public void testLuceneGosenGetStringTagger6() { @@ -55,7 +57,7 @@ public void testLuceneGosenGetStringTagger6() { @Test public void testJapanese() throws Exception { - JLanguageTool lt = new JLanguageTool(new Japanese()); + JLanguageTool lt = new JLanguageTool(Objects.requireNonNull(Languages.getLanguageForName("Japanese"))); List matches = lt.check("そんじゃそこらのやつらとは違う"); assertEquals(1, matches.size()); assertTrue(matches.get(0).getRule() instanceof PatternRule); From 9e0e991b7a33cb9fb37742183804bc246e3a54ee Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 16 Jun 2024 17:03:02 +0900 Subject: [PATCH 13/85] chore(ci): update release upload scripts - manual snapshots - release publish script Signed-off-by: Hiroshi Miura --- ci/azure-pipelines/publish_manual_snapshot.yml | 4 ++-- ci/azure-pipelines/publish_release.yml | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ci/azure-pipelines/publish_manual_snapshot.yml b/ci/azure-pipelines/publish_manual_snapshot.yml index 9b05c7c413..5babe4b0d3 100644 --- a/ci/azure-pipelines/publish_manual_snapshot.yml +++ b/ci/azure-pipelines/publish_manual_snapshot.yml @@ -12,5 +12,5 @@ steps: srcdir=$(system.defaultworkingdirectory)/build/docs/manual/ dest=$(SOURCEFORGE_FILE_USER)@frs.sourceforge.net destdir=/home/project-web/omegat/htdocs/manual-snapshot/ - echo "mkdir $destdir" | SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e sftp -v $dest || true - SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -v -r -oStrictHostKeyChecking=no $srcdir/* $dest:$destdir + echo "mkdir $destdir" | SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e sftp -oStrictHostKeyChecking=no $dest || true + SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -s -oStrictHostKeyChecking=no $srcdir/* $dest:$destdir diff --git a/ci/azure-pipelines/publish_release.yml b/ci/azure-pipelines/publish_release.yml index 805e660b40..ad15ead0c9 100644 --- a/ci/azure-pipelines/publish_release.yml +++ b/ci/azure-pipelines/publish_release.yml @@ -14,6 +14,5 @@ steps: srcdir=$(system.defaultworkingdirectory)/build/distributions/ dest=$(SOURCEFORGE_FILE_USER)@frs.sourceforge.net destdir="/home/frs/project/omegat/OmegaT\\ -\\ Latest/OmegaT\\ ${{ parameters.omegatVersion }}/" - echo "mkdir $destdir" | SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e sftp -v $dest || true - SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -p -s -oStrictHostKeyChecking=no $srcdir/* "$dest:$destdir" - + echo "mkdir $destdir" | SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e sftp -oStrictHostKeyChecking=no $dest || true + SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -s -oStrictHostKeyChecking=no $srcdir/* "$dest:$destdir" From 969bc41de9a9716b67c98b8f1f323a092b352e73 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 16 Jun 2024 20:06:52 +0900 Subject: [PATCH 14/85] refactor: Replace mainWindow obj access with Core.getMainWindow API (#1068) Signed-off-by: Hiroshi Miura --- .../gui/main/MainWindowMenuHandler.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/org/omegat/gui/main/MainWindowMenuHandler.java b/src/org/omegat/gui/main/MainWindowMenuHandler.java index d241ebe28b..243889c7c3 100644 --- a/src/org/omegat/gui/main/MainWindowMenuHandler.java +++ b/src/org/omegat/gui/main/MainWindowMenuHandler.java @@ -592,7 +592,7 @@ public void editReplaceInProjectMenuItemActionPerformed() { private String getTrimmedSelectedTextInMainWindow() { String selection = null; - Component component = mainWindow.getApplicationFrame().getMostRecentFocusOwner(); + Component component = Core.getMainWindow().getApplicationFrame().getMostRecentFocusOwner(); if (component instanceof JTextComponent) { selection = ((JTextComponent) component).getSelectedText(); if (!StringUtil.isEmpty(selection)) { @@ -760,7 +760,7 @@ public void gotoEditorPanelMenuItemActionPerformed() { */ public void gotoSegmentMenuItemActionPerformed() { // Create a dialog for input - GoToSegmentDialog dialog = new GoToSegmentDialog(mainWindow.getApplicationFrame()); + GoToSegmentDialog dialog = new GoToSegmentDialog(Core.getMainWindow().getApplicationFrame()); dialog.setVisible(true); int jumpTo = dialog.getResult(); @@ -884,7 +884,7 @@ public void viewDisplayModificationInfoAllRadioButtonMenuItemActionPerformed() { public void toolsCheckIssuesMenuItemActionPerformed() { if (!Preferences.isPreference(Preferences.ISSUE_PROVIDERS_DONT_ASK)) { IssueProvidersSelectorController dialog = new IssueProvidersSelectorController(); - if (!dialog.show(mainWindow.getApplicationFrame())) { + if (!dialog.show(Core.getMainWindow().getApplicationFrame())) { return; } } @@ -965,14 +965,14 @@ public void optionsDictionaryFuzzyMatchingCheckBoxMenuItemActionPerformed() { * Displays the filters setup dialog to allow customizing file filters in detail. */ public void optionsSetupFileFiltersMenuItemActionPerformed() { - new PreferencesWindowController().show(mainWindow.getApplicationFrame(), FiltersCustomizerController.class); + new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), FiltersCustomizerController.class); } /** * Displays the segmentation setup dialog to allow customizing the segmentation rules in detail. */ public void optionsSentsegMenuItemActionPerformed() { - new PreferencesWindowController().show(mainWindow.getApplicationFrame(), SegmentationCustomizerController.class); + new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), SegmentationCustomizerController.class); } @@ -980,7 +980,7 @@ public void optionsSentsegMenuItemActionPerformed() { * Displays the workflow setup dialog to allow customizing the diverse workflow options. */ public void optionsWorkflowMenuItemActionPerformed() { - new PreferencesWindowController().show(mainWindow.getApplicationFrame(), EditingBehaviorController.class); + new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), EditingBehaviorController.class); } /** @@ -1002,7 +1002,7 @@ public void helpContentsMenuItemActionPerformed() { try { Help.showHelp(); } catch (Exception ex) { - JOptionPane.showMessageDialog(mainWindow.getApplicationFrame(), ex.getLocalizedMessage(), OStrings.getString( + JOptionPane.showMessageDialog(Core.getMainWindow().getApplicationFrame(), ex.getLocalizedMessage(), OStrings.getString( "ERROR_TITLE"), JOptionPane.ERROR_MESSAGE); Log.log(ex); @@ -1013,27 +1013,27 @@ public void helpContentsMenuItemActionPerformed() { * Shows About dialog */ public void helpAboutMenuItemActionPerformed() { - new AboutDialog(mainWindow.getApplicationFrame()).setVisible(true); + new AboutDialog(Core.getMainWindow().getApplicationFrame()).setVisible(true); } /** * Shows Last changes */ public void helpLastChangesMenuItemActionPerformed() { - new LastChangesDialog(mainWindow.getApplicationFrame()).setVisible(true); + new LastChangesDialog(Core.getMainWindow().getApplicationFrame()).setVisible(true); } /** * Show log */ public void helpLogMenuItemActionPerformed() { - new LogDialog(mainWindow.getApplicationFrame()).setVisible(true); + new LogDialog(Core.getMainWindow().getApplicationFrame()).setVisible(true); } /** * Check for updates */ public void helpUpdateCheckMenuItemActionPerformed() { - VersionCheckDialog.checkAndShowResultAsync(mainWindow.getApplicationFrame()); + VersionCheckDialog.checkAndShowResultAsync(Core.getMainWindow().getApplicationFrame()); } } From ffcfcc0f153d9a6973513266c17f7135befed569 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 16 Jun 2024 20:28:23 +0900 Subject: [PATCH 15/85] refactor: Update EditorContoller to reference MainMenu fields (#1067) Signed-off-by: Hiroshi Miura --- src/org/omegat/gui/editor/EditorController.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/org/omegat/gui/editor/EditorController.java b/src/org/omegat/gui/editor/EditorController.java index c1e16448a8..27af65be09 100644 --- a/src/org/omegat/gui/editor/EditorController.java +++ b/src/org/omegat/gui/editor/EditorController.java @@ -105,7 +105,9 @@ import org.omegat.gui.editor.mark.ComesFromMTMarker; import org.omegat.gui.editor.mark.EntryMarks; import org.omegat.gui.editor.mark.Mark; +import org.omegat.gui.main.BaseMainWindowMenu; import org.omegat.gui.main.DockablePanel; +import org.omegat.gui.main.IMainMenu; import org.omegat.gui.main.MainWindow; import org.omegat.gui.main.MainWindowStatusBar; import org.omegat.gui.main.ProjectUICommands; @@ -857,10 +859,14 @@ public void activateEntry(CaretPosition pos) { private void setMenuEnabled() { // update history menu items - mw.menu.gotoHistoryBackMenuItem.setEnabled(history.hasPrev()); - mw.menu.gotoHistoryForwardMenuItem.setEnabled(history.hasNext()); - mw.menu.editMultipleDefault.setEnabled(!m_docSegList[displayedEntryIndex].isDefaultTranslation()); - mw.menu.editMultipleAlternate.setEnabled(m_docSegList[displayedEntryIndex].isDefaultTranslation()); + IMainMenu menu = Core.getMainWindow().getMainMenu(); + if (menu instanceof BaseMainWindowMenu) { + BaseMainWindowMenu mainMenu = (BaseMainWindowMenu) menu; + mainMenu.gotoHistoryBackMenuItem.setEnabled(history.hasPrev()); + mainMenu.gotoHistoryForwardMenuItem.setEnabled(history.hasNext()); + mainMenu.editMultipleDefault.setEnabled(!m_docSegList[displayedEntryIndex].isDefaultTranslation()); + mainMenu.editMultipleAlternate.setEnabled(m_docSegList[displayedEntryIndex].isDefaultTranslation()); + } } /** From ab63fa63ef34015872018e54464ce5452420b7f6 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 16 Jun 2024 20:33:23 +0900 Subject: [PATCH 16/85] chore: fix release related task - Sync task removes other distributions Signed-off-by: Hiroshi Miura --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a400435010..441e2976a0 100644 --- a/build.gradle +++ b/build.gradle @@ -1347,7 +1347,7 @@ ext.makeWinTask = { args -> } } - tasks.register(distsTaskName, Sync) { + tasks.register(distsTaskName, Copy) { description = "Create a Windows installer for ${args.name} distro. " + 'Requires Inno Setup (http://www.jrsoftware.org/isinfo.php).' onlyIf { From a2509302854b5c2be4e680580672579da6a04b69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 04:30:24 +0900 Subject: [PATCH 17/85] chore(deps): bump com.github.spotbugs from 6.0.16 to 6.0.17 (#1069) Bumps com.github.spotbugs from 6.0.16 to 6.0.17. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2eb8c78c18..cd4f705db3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -154,7 +154,7 @@ xmlunit = ["xmlunit-core", "xmlunit-assertj", "assertj"] morfologik = ['morfologik', 'morfologik-speller'] [plugins] -spotbugs = {id = "com.github.spotbugs", version = "6.0.16"} +spotbugs = {id = "com.github.spotbugs", version = "6.0.17"} spotless = {id = "com.diffplug.spotless", version = "6.25.0"} launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.5"} versions = {id = "com.github.ben-manes.versions", version = "0.51.0"} From 004b3d79e6889621bd58875a3be4485479f408d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Jun 2024 07:42:06 +0900 Subject: [PATCH 18/85] chore(deps): bump com.github.spotbugs from 6.0.17 to 6.0.18 (#1070) Bumps com.github.spotbugs from 6.0.17 to 6.0.18. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cd4f705db3..d77844cfb5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -154,7 +154,7 @@ xmlunit = ["xmlunit-core", "xmlunit-assertj", "assertj"] morfologik = ['morfologik', 'morfologik-speller'] [plugins] -spotbugs = {id = "com.github.spotbugs", version = "6.0.17"} +spotbugs = {id = "com.github.spotbugs", version = "6.0.18"} spotless = {id = "com.diffplug.spotless", version = "6.25.0"} launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.5"} versions = {id = "com.github.ben-manes.versions", version = "0.51.0"} From dd573c388433a56ca4b21c407bb0efbd48b2f5b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 07:46:45 +0900 Subject: [PATCH 19/85] chore(deps): bump org.wiremock:wiremock from 3.6.0 to 3.8.0 (#1075) Bumps [org.wiremock:wiremock](https://github.com/wiremock/wiremock) from 3.6.0 to 3.8.0. - [Release notes](https://github.com/wiremock/wiremock/releases) - [Commits](https://github.com/wiremock/wiremock/compare/3.6.0...3.8.0) --- updated-dependencies: - dependency-name: org.wiremock:wiremock dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d77844cfb5..3c61ecdff5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -24,7 +24,7 @@ jackson = "2.16.1" bc = "1.78.1" nashorn = "15.4" caffeine = "3.1.8" -wiremock = "3.6.0" +wiremock = "3.8.0" vldocking = "3.0.5-2" xmlunit = "2.10.0" assertj = "3.26.0" From 5db715d8d34f8d87d85f9091ac546db670284b06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 07:49:53 +0900 Subject: [PATCH 20/85] chore(deps): bump com.fifesoft:rsyntaxtextarea from 3.4.0 to 3.4.1 (#1073) Bumps [com.fifesoft:rsyntaxtextarea](https://github.com/bobbylight/rsyntaxtextarea) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/bobbylight/rsyntaxtextarea/releases) - [Commits](https://github.com/bobbylight/rsyntaxtextarea/compare/3.4.0...3.4.1) --- updated-dependencies: - dependency-name: com.fifesoft:rsyntaxtextarea dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3c61ecdff5..9547bb3f52 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -102,7 +102,7 @@ bc-pg = {group = "org.bouncycastle", name = "bcpg-jdk18on", version.ref = "bc"} bc-pkix = {group = "org.bouncycastle", name = "bcpkix-jdk18on", version.ref = "bc"} svnkit = {group = "org.tmatesoft.svnkit", name = "svnkit", version.ref = "svnkit"} nashorn-core = {group = "org.openjdk.nashorn", name = "nashorn-core", version.ref = "nashorn"} -fifesoft-rsyntaxtextarea = {group = "com.fifesoft", name = "rsyntaxtextarea", version = "3.4.0"} +fifesoft-rsyntaxtextarea = {group = "com.fifesoft", name = "rsyntaxtextarea", version = "3.4.1"} fifesoft-rstaui = {group = "com.fifesoft", name = "rstaui", version = "3.3.1"} fifesoft-languagesupport = {group = "com.fifesoft", name = "languagesupport", version = "3.3.0"} fifesoft-autocomplete = {group = "com.fifesoft", name = "autocomplete", version = "3.3.1"} From 06a2ae6357f1797b244d077186f28d113e6289f4 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 6 Jul 2024 11:09:18 +0900 Subject: [PATCH 21/85] refactor: extend MainWindow API, and move MenuHandler functions in ProjectUICommands, then introduce SearchWindowManager (#1063) * refactor: Add IMainWindow#saveDesktopLayout and IMainWindow#resetDesktopLayout Signed-off-by: Hiroshi Miura * refactor: move handler functions Define the following functions and remove it from MainWindowMenuHandler class - MainWindowUI.createSearchWindow - MainWindowUI.getTrimmedSelectedTextInMainWindow - ProjectUICommands.projectExit - ProjectUICommands.projectRestart - ProjectUICommands.prepareForExit - ProjectUICommands.openFile - ProjectUICommands.openWriteableGlossaryFile - ProjectUICommands.areTagsValid Signed-off-by: Hiroshi Miura * refactor: introduce SearchWindowManager Defines SearchWindow management functions Signed-off-by: Hiroshi Miura * feat: add IMainWindow#getSelectedText - Introduce API IMainWindow#getSelectedText - MainWindow#getSelectedText calls MainWindowUI.getTrimmedSelectedTextInMainWindow as implementation - Menu handler use it - SearchWindowManager#createSearch use it Signed-off-by: Hiroshi Miura * style: private constructor for utility SearchWindowManager Signed-off-by: Hiroshi Miura * style: drop inheritdoc only javadoc comment - MainWindowUI.createSearchWindow - MainWindowUI.findInProjectReuseLastWindow - MainWindowUI.getTrimmedSelectedTextInMainWindow - MainWindowUI.projectExit - MainWindowUI.projectRestart - MainWindowUI.prepareForExit Signed-off-by: Hiroshi Miura * refactor: drop unused variables and utility method Signed-off-by: Hiroshi Miura * style: remove unused imports and tweak indents Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- src/org/omegat/gui/main/ConsoleWindow.java | 10 +- src/org/omegat/gui/main/IMainWindow.java | 9 + src/org/omegat/gui/main/MainWindow.java | 52 +--- .../gui/main/MainWindowMenuHandler.java | 263 ++++-------------- src/org/omegat/gui/main/MainWindowUI.java | 97 ++----- .../omegat/gui/main/ProjectUICommands.java | 131 +++++++++ .../gui/search/SearchWindowManager.java | 95 +++++++ .../org/omegat/gui/main/TestMainWindow.java | 4 - test/fixtures/org/omegat/core/TestCore.java | 4 - 9 files changed, 328 insertions(+), 337 deletions(-) create mode 100644 src/org/omegat/gui/search/SearchWindowManager.java diff --git a/src/org/omegat/gui/main/ConsoleWindow.java b/src/org/omegat/gui/main/ConsoleWindow.java index 2695c23209..ee144ea017 100644 --- a/src/org/omegat/gui/main/ConsoleWindow.java +++ b/src/org/omegat/gui/main/ConsoleWindow.java @@ -142,10 +142,6 @@ public DockingDesktop getDesktop() { return null; } - @Override - public void resetDesktopLayout() { - } - public Cursor getCursor() { return Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); } @@ -153,13 +149,13 @@ public Cursor getCursor() { public void setCursor(Cursor cursor) { } - public int showConfirmDialog(Object message, String title, int optionType, - int messageType) throws HeadlessException { + public int showConfirmDialog(Object message, String title, int optionType, int messageType) + throws HeadlessException { System.out.println(title); System.out.println(message); System.out.println(OStrings.getString("TF_CHOSEN_YES")); - return 0; //JOptionPane.YES_OPTION + return 0; // JOptionPane.YES_OPTION } public void showMessageDialog(String message) { diff --git a/src/org/omegat/gui/main/IMainWindow.java b/src/org/omegat/gui/main/IMainWindow.java index 987ccb8ffb..6bb2284e8c 100644 --- a/src/org/omegat/gui/main/IMainWindow.java +++ b/src/org/omegat/gui/main/IMainWindow.java @@ -195,6 +195,10 @@ public interface IMainWindow { */ Cursor getCursor(); + default String getSelectedText() { + return ""; + } + /** * Retrieve main manu instance. */ @@ -209,4 +213,9 @@ public interface IMainWindow { * Restores the main window layout to the default values. */ default void resetDesktopLayout() {} + + /** + * Save the main window layout. + */ + default void saveDesktopLayout() {} } diff --git a/src/org/omegat/gui/main/MainWindow.java b/src/org/omegat/gui/main/MainWindow.java index 14d41379a2..0fea5f0908 100644 --- a/src/org/omegat/gui/main/MainWindow.java +++ b/src/org/omegat/gui/main/MainWindow.java @@ -75,6 +75,7 @@ import org.omegat.core.events.IProjectEventListener; import org.omegat.core.matching.NearString; import org.omegat.gui.matches.IMatcher; +import org.omegat.gui.search.SearchWindowManager; import org.omegat.util.OStrings; import org.omegat.util.Preferences; import org.omegat.util.StaticUtils; @@ -137,7 +138,7 @@ public MainWindow() throws IOException { CoreEvents.registerProjectChangeListener(eventType -> { updateTitle(); if (eventType == IProjectEventListener.PROJECT_CHANGE_TYPE.CLOSE) { - MainWindowUI.closeSearchWindows(); + SearchWindowManager.closeSearchWindows(); } }); @@ -176,11 +177,9 @@ public void onApplicationShutdown() { }); } - /** - * {@inheritDoc} - */ + @Override public void resetDesktopLayout() { - MainWindowUI.resetDesktopLayout(this); + MainWindowUI.resetDesktopLayout(this); } @SuppressWarnings("unchecked") @@ -231,6 +230,11 @@ public void windowDeactivated(WindowEvent we) { } } + @Override + public void saveDesktopLayout() { + MainWindowUI.saveScreenLayout(this); + } + /** * Create docking desktop panel and status bar. */ @@ -247,30 +251,18 @@ private void initDockingAndStatusBar() { applicationFrame.pack(); } - /** - * {@inheritDoc} - */ public JFrame getApplicationFrame() { return applicationFrame; } - /** - * {@inheritDoc} - */ public Font getApplicationFont() { return font; } - /** - * {@inheritDoc} - */ public IMainMenu getMainMenu() { return menu; } - /** - * {@inheritDoc} - */ public void addDockable(Dockable pane) { desktop.addDockable(pane); } @@ -285,6 +277,11 @@ public Cursor getCursor() { return applicationFrame.getCursor(); } + @Override + public String getSelectedText() { + return MainWindowUI.getTrimmedSelectedTextInMainWindow(this); + } + /** * Sets the title of the main window appropriately */ @@ -362,9 +359,6 @@ private static String getSelectedTextInMatcher() { return matcher instanceof JTextComponent ? ((JTextComponent) matcher).getSelectedText() : null; } - /** - * {@inheritDoc} - */ public void showStatusMessageRB(final String messageKey, final Object... params) { final String msg = getLocalizedString(messageKey, params); UIThreadsUtil.executeInSwingThread(new Runnable() { @@ -385,9 +379,6 @@ private String getLocalizedString(String messageKey, Object... params) { } } - /** - * {@inheritDoc} - */ @Override public void showTimedStatusMessageRB(String messageKey, Object... params) { showStatusMessageRB(messageKey, params); @@ -449,16 +440,10 @@ public void showLockInsertMessage(String messageText, String toolTip) { private JPanel lastDialogText; private String lastDialogKey; - /** - * {@inheritDoc} - */ public void displayWarningRB(String warningKey, Object... params) { displayWarningRB(warningKey, null, params); }; - /** - * {@inheritDoc} - */ public void displayWarningRB(final String warningKey, final String supercedesKey, final Object... params) { UIThreadsUtil.executeInSwingThread(() -> { @@ -492,9 +477,6 @@ public void displayWarningRB(final String warningKey, final String supercedesKey }); } - /** - * {@inheritDoc} - */ public void displayErrorRB(final Throwable ex, final String errorKey, final Object... params) { UIThreadsUtil.executeInSwingThread(() -> { String msg; @@ -547,9 +529,6 @@ public void displayErrorRB(final Throwable ex, final String errorKey, final Obje }); } - /** - * {@inheritDoc} - */ public void lockUI() { UIThreadsUtil.mustBeSwingThread(); @@ -573,9 +552,6 @@ public void lockUI() { } } - /** - * {@inheritDoc} - */ public void unlockUI() { UIThreadsUtil.mustBeSwingThread(); diff --git a/src/org/omegat/gui/main/MainWindowMenuHandler.java b/src/org/omegat/gui/main/MainWindowMenuHandler.java index 243889c7c3..58021a13af 100644 --- a/src/org/omegat/gui/main/MainWindowMenuHandler.java +++ b/src/org/omegat/gui/main/MainWindowMenuHandler.java @@ -44,23 +44,14 @@ import java.util.regex.Pattern; import javax.swing.JOptionPane; -import javax.swing.SwingWorker; -import javax.swing.text.JTextComponent; -import org.omegat.Main; import org.omegat.core.Core; -import org.omegat.core.CoreEvents; -import org.omegat.core.KnownException; -import org.omegat.core.data.ProjectFactory; -import org.omegat.core.data.ProjectTMX; import org.omegat.core.data.SourceTextEntry; import org.omegat.core.data.TMXEntry; import org.omegat.core.matching.NearString; import org.omegat.core.matching.NearString.MATCH_SOURCE; import org.omegat.core.search.SearchMode; -import org.omegat.core.spellchecker.ISpellChecker; import org.omegat.core.tagvalidation.ErrorReport; -import org.omegat.filters2.master.PluginUtils; import org.omegat.gui.dialogs.AboutDialog; import org.omegat.gui.dialogs.GoToSegmentDialog; import org.omegat.gui.dialogs.LastChangesDialog; @@ -76,6 +67,7 @@ import org.omegat.gui.issues.IssueProvidersSelectorController; import org.omegat.gui.preferences.PreferencesWindowController; import org.omegat.gui.preferences.view.EditingBehaviorController; +import org.omegat.gui.search.SearchWindowManager; import org.omegat.gui.segmentation.SegmentationCustomizerController; import org.omegat.gui.stat.StatisticsWindow; import org.omegat.help.Help; @@ -87,7 +79,6 @@ import org.omegat.util.StringUtil; import org.omegat.util.TagUtil; import org.omegat.util.TagUtil.Tag; -import org.omegat.util.gui.DesktopWrapper; /** * Handler for main menu items. @@ -106,7 +97,6 @@ * @author Aaron Madlon-Kay */ public final class MainWindowMenuHandler extends BaseMainWindowMenuHandler { - private static final String PROP_ORIGIN = ProjectTMX.PROP_ORIGIN; private final MainWindow mainWindow; @@ -186,34 +176,15 @@ public void projectSaveMenuItemActionPerformed() { * Create translated documents. */ public void projectCompileMenuItemActionPerformed() { - if (!checkTags()) { - return; - } - - ProjectUICommands.projectCompile(); - } - - /** - * Check whether tags are OK - * @return false is there is a tag issue, true otherwise - */ - private boolean checkTags() { - if (Preferences.isPreference(Preferences.TAGS_VALID_REQUIRED)) { - List stes = Core.getTagValidation().listInvalidTags(); - if (!stes.isEmpty()) { - Core.getIssues().showAll(OStrings.getString("TF_MESSAGE_COMPILE")); - return false; - } + if (ProjectUICommands.areTagsValid()) { + ProjectUICommands.projectCompile(); } - return true; } public void projectCommitTargetFilesActionPerformed() { - if (!checkTags()) { - return; + if (ProjectUICommands.areTagsValid()) { + ProjectUICommands.projectCompileAndCommit(); } - - ProjectUICommands.projectCompileAndCommit(); } /** @@ -250,7 +221,7 @@ public void projectEditMenuItemActionPerformed() { } public void viewFileListMenuItemActionPerformed() { - IProjectFilesList projWin = Core.getProjectFilesList(); + IProjectFilesList projWin = Core.getProjectFilesList(); if (projWin == null) { mainWindow.menu.viewFileListMenuItem.setSelected(false); return; @@ -264,7 +235,7 @@ public void projectAccessRootMenuItemActionPerformed() { return; } String path = Core.getProject().getProjectProperties().getProjectRoot(); - openFile(new File(path)); + ProjectUICommands.openFile(new File(path)); } public void projectAccessDictionaryMenuItemActionPerformed() { @@ -272,7 +243,7 @@ public void projectAccessDictionaryMenuItemActionPerformed() { return; } String path = Core.getProject().getProjectProperties().getDictRoot(); - openFile(new File(path)); + ProjectUICommands.openFile(new File(path)); } public void projectAccessGlossaryMenuItemActionPerformed() { @@ -280,7 +251,7 @@ public void projectAccessGlossaryMenuItemActionPerformed() { return; } String path = Core.getProject().getProjectProperties().getGlossaryRoot(); - openFile(new File(path)); + ProjectUICommands.openFile(new File(path)); } public void projectAccessSourceMenuItemActionPerformed() { @@ -288,7 +259,7 @@ public void projectAccessSourceMenuItemActionPerformed() { return; } String path = Core.getProject().getProjectProperties().getSourceRoot(); - openFile(new File(path)); + ProjectUICommands.openFile(new File(path)); } public void projectAccessTargetMenuItemActionPerformed() { @@ -296,7 +267,7 @@ public void projectAccessTargetMenuItemActionPerformed() { return; } String path = Core.getProject().getProjectProperties().getTargetRoot(); - openFile(new File(path)); + ProjectUICommands.openFile(new File(path)); } public void projectAccessTMMenuItemActionPerformed() { @@ -304,7 +275,7 @@ public void projectAccessTMMenuItemActionPerformed() { return; } String path = Core.getProject().getProjectProperties().getTMRoot(); - openFile(new File(path)); + ProjectUICommands.openFile(new File(path)); } public void projectAccessExportTMMenuItemActionPerformed() { @@ -312,7 +283,7 @@ public void projectAccessExportTMMenuItemActionPerformed() { return; } String path = Core.getProject().getProjectProperties().getExportTMRoot(); - openFile(new File(path)); + ProjectUICommands.openFile(new File(path)); } public void projectAccessCurrentSourceDocumentMenuItemActionPerformed(int modifier) { @@ -328,7 +299,7 @@ public void projectAccessCurrentSourceDocumentMenuItemActionPerformed(int modifi if ((modifier & ActionEvent.ALT_MASK) != 0) { toOpen = toOpen.getParentFile(); } - openFile(toOpen); + ProjectUICommands.openFile(toOpen); } public void projectAccessCurrentTargetDocumentMenuItemActionPerformed(int modifier) { @@ -344,45 +315,16 @@ public void projectAccessCurrentTargetDocumentMenuItemActionPerformed(int modifi if ((modifier & ActionEvent.ALT_MASK) != 0) { toOpen = toOpen.getParentFile(); } - openFile(toOpen); + ProjectUICommands.openFile(toOpen); } public void projectAccessWriteableGlossaryMenuItemActionPerformed(int modifier) { - if (!Core.getProject().isProjectLoaded()) { - return; - } - String path = Core.getProject().getProjectProperties().getWriteableGlossary(); - if (StringUtil.isEmpty(path)) { - return; - } - File toOpen = new File(path); - if ((modifier & ActionEvent.ALT_MASK) != 0) { - toOpen = toOpen.getParentFile(); - } - openFile(toOpen); - } - - private void openFile(File path) { - try { - path = path.getCanonicalFile(); // Normalize file name in case it is displayed - } catch (Exception ex) { - // Ignore - } - if (!path.exists()) { - Core.getMainWindow().showStatusMessageRB("LFC_ERROR_FILE_DOESNT_EXIST", path); - return; - } - try { - DesktopWrapper.open(path); - } catch (Exception ex) { - Log.logErrorRB(ex, "RPF_ERROR"); - Core.getMainWindow().displayErrorRB(ex, "RPF_ERROR"); - } + ProjectUICommands.openWriteableGlossaryFile((modifier & ActionEvent.ALT_MASK) != 0); } /** Quits OmegaT */ public void projectExitMenuItemActionPerformed() { - prepareForExit(() -> System.exit(0)); + ProjectUICommands.projectExit(); } /** Restart OmegaT */ @@ -390,74 +332,7 @@ public void projectRestartMenuItemActionPerformed() { String projectDir = Core.getProject().isProjectLoaded() ? Core.getProject().getProjectProperties().getProjectRoot() : null; - prepareForExit(() -> { - Main.restartGUI(projectDir); - }); - } - - protected void prepareForExit(Runnable onCompletion) { - // Bug #902: commit the current entry first - // We do it before checking project status, so that it can eventually change it - if (Core.getProject().isProjectLoaded()) { - Core.getEditor().commitAndLeave(); - } - - boolean projectModified = false; - if (Core.getProject().isProjectLoaded()) { - projectModified = Core.getProject().isProjectModified(); - } - // RFE 1302358 - // Add Yes/No Warning before OmegaT quits - if (projectModified || Preferences.isPreference(Preferences.ALWAYS_CONFIRM_QUIT)) { - if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(Core.getMainWindow().getApplicationFrame(), - OStrings.getString("MW_QUIT_CONFIRM"), OStrings.getString("CONFIRM_DIALOG_TITLE"), - JOptionPane.YES_NO_OPTION)) { - return; - } - } - - SegmentExportImport.flushExportedSegments(); - - new SwingWorker() { - @Override - protected Void doInBackground() throws Exception { - if (Core.getProject().isProjectLoaded()) { - // Save the list of learned and ignore words - ISpellChecker sc = Core.getSpellChecker(); - sc.saveWordLists(); - try { - Core.executeExclusively(true, () -> { - Core.getProject().saveProject(true); - ProjectFactory.closeProject(); - }); - } catch (KnownException ex) { - // hide exception on shutdown - } - } - - CoreEvents.fireApplicationShutdown(); - - PluginUtils.unloadPlugins(); - - return null; - } - - @Override - protected void done() { - try { - get(); - - MainWindowUI.saveScreenLayout(mainWindow); - - Preferences.save(); - - onCompletion.run(); - } catch (Exception ex) { - Log.logErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"); - Core.getMainWindow().displayErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"); - } - } - }.execute(); + ProjectUICommands.projectRestart(projectDir); } public void editUndoMenuItemActionPerformed() { @@ -565,42 +440,34 @@ public void editCreateGlossaryEntryMenuItemActionPerformed() { Core.getGlossary().showCreateGlossaryEntryDialog(Core.getMainWindow().getApplicationFrame()); } - public void editFindInProjectMenuItemActionPerformed() { + /** + * Used in BaseMainWindowMenu#configuraActions for macOS. + */ + void findInProjectReuseLastWindow() { if (!Core.getProject().isProjectLoaded()) { return; } - MainWindowUI.createSearchWindow(SearchMode.SEARCH, getTrimmedSelectedTextInMainWindow()); - } - - void findInProjectReuseLastWindow() { - if (!Core.getProject().isProjectLoaded()) { + String text = Core.getMainWindow().getSelectedText(); + if (text == null) { return; } - String text = getTrimmedSelectedTextInMainWindow(); - if (!MainWindowUI.reuseSearchWindow(text)) { - MainWindowUI.createSearchWindow(SearchMode.SEARCH, text); + if (!SearchWindowManager.reuseSearchWindow(text)) { + SearchWindowManager.createSearchWindow(SearchMode.SEARCH, text); } - editFindInProjectMenuItemActionPerformed(); } - public void editReplaceInProjectMenuItemActionPerformed() { + public void editFindInProjectMenuItemActionPerformed() { if (!Core.getProject().isProjectLoaded()) { return; } - MainWindowUI.createSearchWindow(SearchMode.REPLACE, getTrimmedSelectedTextInMainWindow()); + SearchWindowManager.createSearchWindow(SearchMode.SEARCH); } - private String getTrimmedSelectedTextInMainWindow() { - String selection = null; - Component component = Core.getMainWindow().getApplicationFrame().getMostRecentFocusOwner(); - if (component instanceof JTextComponent) { - selection = ((JTextComponent) component).getSelectedText(); - if (!StringUtil.isEmpty(selection)) { - selection = EditorUtils.removeDirectionChars(selection); - selection = selection.trim(); - } + public void editReplaceInProjectMenuItemActionPerformed() { + if (!Core.getProject().isProjectLoaded()) { + return; } - return selection; + SearchWindowManager.createSearchWindow(SearchMode.REPLACE); } /** Set active match to #1. */ @@ -791,59 +658,41 @@ public void viewMarkTranslatedSegmentsCheckBoxMenuItemActionPerformed() { } public void viewMarkUntranslatedSegmentsCheckBoxMenuItemActionPerformed() { - Core.getEditor() - .getSettings() - .setMarkUntranslated( - mainWindow.menu.viewMarkUntranslatedSegmentsCheckBoxMenuItem.isSelected()); + Core.getEditor().getSettings().setMarkUntranslated( + mainWindow.menu.viewMarkUntranslatedSegmentsCheckBoxMenuItem.isSelected()); } public void viewMarkParagraphStartCheckBoxMenuItemActionPerformed() { - Core.getEditor() - .getSettings() - .setMarkParagraphDelimitations( - mainWindow.menu.viewMarkParagraphStartCheckBoxMenuItem.isSelected()); + Core.getEditor().getSettings().setMarkParagraphDelimitations( + mainWindow.menu.viewMarkParagraphStartCheckBoxMenuItem.isSelected()); } public void viewDisplaySegmentSourceCheckBoxMenuItemActionPerformed() { - Core.getEditor() - .getSettings() - .setDisplaySegmentSources( - mainWindow.menu.viewDisplaySegmentSourceCheckBoxMenuItem.isSelected()); + Core.getEditor().getSettings().setDisplaySegmentSources( + mainWindow.menu.viewDisplaySegmentSourceCheckBoxMenuItem.isSelected()); } public void viewMarkNonUniqueSegmentsCheckBoxMenuItemActionPerformed() { - Core.getEditor() - .getSettings() - .setMarkNonUniqueSegments( - mainWindow.menu.viewMarkNonUniqueSegmentsCheckBoxMenuItem.isSelected()); + Core.getEditor().getSettings().setMarkNonUniqueSegments( + mainWindow.menu.viewMarkNonUniqueSegmentsCheckBoxMenuItem.isSelected()); } public void viewMarkNotedSegmentsCheckBoxMenuItemActionPerformed() { - Core.getEditor() - .getSettings() - .setMarkNotedSegments( - mainWindow.menu.viewMarkNotedSegmentsCheckBoxMenuItem.isSelected()); + Core.getEditor().getSettings() + .setMarkNotedSegments(mainWindow.menu.viewMarkNotedSegmentsCheckBoxMenuItem.isSelected()); } public void viewMarkNBSPCheckBoxMenuItemActionPerformed() { - Core.getEditor() - .getSettings() - .setMarkNBSP( - mainWindow.menu.viewMarkNBSPCheckBoxMenuItem.isSelected()); + Core.getEditor().getSettings().setMarkNBSP(mainWindow.menu.viewMarkNBSPCheckBoxMenuItem.isSelected()); } public void viewMarkWhitespaceCheckBoxMenuItemActionPerformed() { - Core.getEditor() - .getSettings() - .setMarkWhitespace( - mainWindow.menu.viewMarkWhitespaceCheckBoxMenuItem.isSelected()); + Core.getEditor().getSettings() + .setMarkWhitespace(mainWindow.menu.viewMarkWhitespaceCheckBoxMenuItem.isSelected()); } public void viewMarkBidiCheckBoxMenuItemActionPerformed() { - Core.getEditor() - .getSettings() - .setMarkBidi( - mainWindow.menu.viewMarkBidiCheckBoxMenuItem.isSelected()); + Core.getEditor().getSettings().setMarkBidi(mainWindow.menu.viewMarkBidiCheckBoxMenuItem.isSelected()); } public void viewMarkAutoPopulatedCheckBoxMenuItemActionPerformed() { @@ -925,8 +774,8 @@ public void toolsShowStatisticsMatchesMenuItemActionPerformed() { } public void toolsShowStatisticsMatchesPerFileMenuItemActionPerformed() { - new StatisticsWindow(Core.getMainWindow().getApplicationFrame(), StatisticsWindow.STAT_TYPE.MATCHES_PER_FILE) - .setVisible(true); + new StatisticsWindow(Core.getMainWindow().getApplicationFrame(), + StatisticsWindow.STAT_TYPE.MATCHES_PER_FILE).setVisible(true); } public void optionsAutoCompleteShowAutomaticallyItemActionPerformed() { @@ -965,14 +814,16 @@ public void optionsDictionaryFuzzyMatchingCheckBoxMenuItemActionPerformed() { * Displays the filters setup dialog to allow customizing file filters in detail. */ public void optionsSetupFileFiltersMenuItemActionPerformed() { - new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), FiltersCustomizerController.class); + new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), + FiltersCustomizerController.class); } /** * Displays the segmentation setup dialog to allow customizing the segmentation rules in detail. */ public void optionsSentsegMenuItemActionPerformed() { - new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), SegmentationCustomizerController.class); + new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), + SegmentationCustomizerController.class); } @@ -980,7 +831,8 @@ public void optionsSentsegMenuItemActionPerformed() { * Displays the workflow setup dialog to allow customizing the diverse workflow options. */ public void optionsWorkflowMenuItemActionPerformed() { - new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), EditingBehaviorController.class); + new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), + EditingBehaviorController.class); } /** @@ -992,7 +844,7 @@ public void viewRestoreGUIMenuItemActionPerformed() { } public void optionsAccessConfigDirMenuItemActionPerformed() { - openFile(new File(StaticUtils.getConfigDir())); + ProjectUICommands.openFile(new File(StaticUtils.getConfigDir())); } /** @@ -1002,9 +854,8 @@ public void helpContentsMenuItemActionPerformed() { try { Help.showHelp(); } catch (Exception ex) { - JOptionPane.showMessageDialog(Core.getMainWindow().getApplicationFrame(), ex.getLocalizedMessage(), OStrings.getString( - "ERROR_TITLE"), - JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(Core.getMainWindow().getApplicationFrame(), + ex.getLocalizedMessage(), OStrings.getString("ERROR_TITLE"), JOptionPane.ERROR_MESSAGE); Log.log(ex); } } diff --git a/src/org/omegat/gui/main/MainWindowUI.java b/src/org/omegat/gui/main/MainWindowUI.java index 43b526bbe9..186b8db8de 100644 --- a/src/org/omegat/gui/main/MainWindowUI.java +++ b/src/org/omegat/gui/main/MainWindowUI.java @@ -31,34 +31,29 @@ package org.omegat.gui.main; +import java.awt.Component; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; + +import javax.swing.text.JTextComponent; import org.omegat.core.Core; import org.omegat.core.CoreEvents; import org.omegat.core.events.IApplicationEventListener; import org.omegat.core.events.IProjectEventListener; -import org.omegat.core.search.SearchMode; -import org.omegat.gui.search.SearchWindowController; +import org.omegat.gui.editor.EditorUtils; import org.omegat.util.Log; import org.omegat.util.OConsts; import org.omegat.util.OStrings; import org.omegat.util.StaticUtils; +import org.omegat.util.StringUtil; import org.omegat.util.gui.UIDesignManager; -import com.vlsolutions.swing.docking.DockingDesktop; -import com.vlsolutions.swing.docking.event.DockableStateWillChangeEvent; -import com.vlsolutions.swing.docking.event.DockableStateWillChangeListener; - /** * Class for initialize, load/save, etc. for main window UI components. * @@ -75,32 +70,11 @@ */ public final class MainWindowUI { - /** - * Set of all open search windows. - */ - private static final List searches = new ArrayList<>(); - private MainWindowUI() { } public static final String UI_LAYOUT_FILE = "uiLayout" + OStrings.getBrandingToken() + ".xml"; - /** - * Create docking desktop panel. - */ - public static DockingDesktop initDocking(final MainWindow mainWindow) { - mainWindow.desktop = new DockingDesktop(); - mainWindow.desktop.addDockableStateWillChangeListener(new DockableStateWillChangeListener() { - public void dockableStateWillChange(DockableStateWillChangeEvent event) { - if (event.getFutureState().isClosed()) { - event.cancel(); - } - } - }); - - return mainWindow.desktop; - } - /** * Installs a {@link IProjectEventListener} that handles loading, storing, * and restoring the main window layout when a project-specific layout is @@ -112,51 +86,6 @@ public static void handlePerProjectLayouts(final MainWindow mainWindow) { CoreEvents.registerApplicationEventListener(handler); } - static void createSearchWindow(SearchMode mode, String query) { - SearchWindowController search = new SearchWindowController(mode); - addSearchWindow(search); - search.makeVisible(query); - } - - static void closeSearchWindows() { - synchronized (searches) { - // dispose other windows - for (SearchWindowController sw : searches) { - sw.dispose(); - } - searches.clear(); - } - } - - static boolean reuseSearchWindow(String text) { - for (int i = searches.size() - 1; i >= 0; i--) { - SearchWindowController swc = searches.get(i); - if (swc.getMode() == SearchMode.SEARCH) { - swc.makeVisible(text); - return true; - } - } - return false; - } - - private static void addSearchWindow(final SearchWindowController newSearchWindow) { - newSearchWindow.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - removeSearchWindow(newSearchWindow); - } - }); - synchronized (searches) { - searches.add(newSearchWindow); - } - } - - private static void removeSearchWindow(SearchWindowController searchWindow) { - synchronized (searches) { - searches.remove(searchWindow); - } - } - private static class PerProjectLayoutHandler implements IProjectEventListener, IApplicationEventListener { private final MainWindow mainWindow; @@ -252,8 +181,7 @@ public static void initializeScreenLayout(MainWindow mainWindow) { // Ensure any "closed" Dockables are visible. These can be newly added // panes not included in an older layout file, or e.g. panes installed - // by - // plugins. + // by plugins. UIDesignManager.ensureDockablesVisible(mainWindow.desktop); } @@ -313,4 +241,17 @@ public static void resetDesktopLayout(MainWindow mainWindow) { Log.log(e); } } + + public static String getTrimmedSelectedTextInMainWindow(MainWindow mainWindow) { + String selection = null; + Component component = mainWindow.getApplicationFrame().getMostRecentFocusOwner(); + if (component instanceof JTextComponent) { + selection = ((JTextComponent) component).getSelectedText(); + if (!StringUtil.isEmpty(selection)) { + selection = EditorUtils.removeDirectionChars(selection); + selection = selection.trim(); + } + } + return selection; + } } diff --git a/src/org/omegat/gui/main/ProjectUICommands.java b/src/org/omegat/gui/main/ProjectUICommands.java index 817acbe067..69ac9eb506 100644 --- a/src/org/omegat/gui/main/ProjectUICommands.java +++ b/src/org/omegat/gui/main/ProjectUICommands.java @@ -53,6 +53,7 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.omegat.CLIParameters; +import org.omegat.Main; import org.omegat.convert.ConvertProject; import org.omegat.core.Core; import org.omegat.core.CoreEvents; @@ -62,15 +63,19 @@ import org.omegat.core.events.IProjectEventListener; import org.omegat.core.segmentation.SRX; import org.omegat.core.segmentation.Segmenter; +import org.omegat.core.spellchecker.ISpellChecker; +import org.omegat.core.tagvalidation.ErrorReport; import org.omegat.core.team2.IRemoteRepository2; import org.omegat.core.team2.RemoteRepositoryProvider; import org.omegat.filters2.master.FilterMaster; +import org.omegat.filters2.master.PluginUtils; import org.omegat.gui.dialogs.ChooseMedProject; import org.omegat.gui.dialogs.FileCollisionDialog; import org.omegat.gui.dialogs.NewProjectFileChooser; import org.omegat.gui.dialogs.NewTeamProjectController; import org.omegat.gui.dialogs.ProjectPropertiesDialog; import org.omegat.gui.dialogs.ProjectPropertiesDialogController; +import org.omegat.gui.editor.SegmentExportImport; import org.omegat.util.FileUtil; import org.omegat.util.FileUtil.ICollisionCallback; import org.omegat.util.HttpConnectionUtils; @@ -83,6 +88,7 @@ import org.omegat.util.StaticUtils; import org.omegat.util.StringUtil; import org.omegat.util.WikiGet; +import org.omegat.util.gui.DesktopWrapper; import org.omegat.util.gui.OmegaTFileChooser; import org.omegat.util.gui.OpenProjectFileChooser; import org.omegat.util.gui.UIThreadsUtil; @@ -1240,6 +1246,131 @@ public static void projectImportFiles(String destination, File[] toImport, boole } } + public static void openWriteableGlossaryFile(boolean parent) { + if (!Core.getProject().isProjectLoaded()) { + return; + } + String path = Core.getProject().getProjectProperties().getWriteableGlossary(); + if (StringUtil.isEmpty(path)) { + return; + } + File toOpen = new File(path); + if (parent) { + toOpen = toOpen.getParentFile(); + } + openFile(toOpen); + } + + public static void openFile(File path) { + try { + path = path.getCanonicalFile(); // Normalize file name in case it is + // displayed + } catch (Exception ex) { + // Ignore + } + if (!path.exists()) { + Core.getMainWindow().showStatusMessageRB("LFC_ERROR_FILE_DOESNT_EXIST", path); + return; + } + try { + DesktopWrapper.open(path); + } catch (Exception ex) { + Log.logErrorRB(ex, "RPF_ERROR"); + Core.getMainWindow().displayErrorRB(ex, "RPF_ERROR"); + } + } + + /** + * Check whether tags are OK + * + * @return false is there is a tag issue, true otherwise + */ + static boolean areTagsValid() { + boolean result = false; + if (Preferences.isPreference(Preferences.TAGS_VALID_REQUIRED)) { + List stes = Core.getTagValidation().listInvalidTags(); + if (!stes.isEmpty()) { + Core.getIssues().showAll(OStrings.getString("TF_MESSAGE_COMPILE")); + result = true; + } + } + return !result; + } + + public static void projectExit() { + prepareForExit(() -> System.exit(-1)); + } + + public static void projectRestart(String projectDir) { + prepareForExit(() -> Main.restartGUI(projectDir)); + } + + private static void prepareForExit(Runnable onCompletion) { + // Bug #902: commit the current entry first + // We do it before checking project status, so that it can eventually + // change it + if (Core.getProject().isProjectLoaded()) { + Core.getEditor().commitAndLeave(); + } + + boolean projectModified = false; + if (Core.getProject().isProjectLoaded()) { + projectModified = Core.getProject().isProjectModified(); + } + // RFE 1302358 + // Add Yes/No Warning before OmegaT quits + if (projectModified || Preferences.isPreference(Preferences.ALWAYS_CONFIRM_QUIT)) { + if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(Core.getMainWindow().getApplicationFrame(), + OStrings.getString("MW_QUIT_CONFIRM"), OStrings.getString("CONFIRM_DIALOG_TITLE"), + JOptionPane.YES_NO_OPTION)) { + return; + } + } + + SegmentExportImport.flushExportedSegments(); + + new SwingWorker() { + @Override + protected Void doInBackground() throws Exception { + if (Core.getProject().isProjectLoaded()) { + // Save the list of learned and ignore words + ISpellChecker sc = Core.getSpellChecker(); + sc.saveWordLists(); + try { + Core.executeExclusively(true, () -> { + Core.getProject().saveProject(true); + ProjectFactory.closeProject(); + }); + } catch (KnownException ex) { + // hide exception on shutdown + } + } + + CoreEvents.fireApplicationShutdown(); + + PluginUtils.unloadPlugins(); + + return null; + } + + @Override + protected void done() { + try { + get(); + + Core.getMainWindow().saveDesktopLayout(); + + Preferences.save(); + + onCompletion.run(); + } catch (Exception ex) { + Log.logErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"); + Core.getMainWindow().displayErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"); + } + } + }.execute(); + } + private static class CollisionCallback implements ICollisionCallback { private boolean isCanceled = false; private boolean yesToAll = false; diff --git a/src/org/omegat/gui/search/SearchWindowManager.java b/src/org/omegat/gui/search/SearchWindowManager.java new file mode 100644 index 0000000000..ab4456e3e2 --- /dev/null +++ b/src/org/omegat/gui/search/SearchWindowManager.java @@ -0,0 +1,95 @@ +/******************************************************************************* + 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.gui.search; + +import org.omegat.core.Core; +import org.omegat.core.search.SearchMode; + +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.ArrayList; +import java.util.List; + +public final class SearchWindowManager { + + private SearchWindowManager() { + } + + /** + * Set of all open search windows. + */ + private static final List searches = new ArrayList<>(); + + public static void createSearchWindow(SearchMode mode) { + String text = Core.getMainWindow().getSelectedText(); + createSearchWindow(mode, text); + } + + public static void createSearchWindow(SearchMode mode, String query) { + SearchWindowController search = new SearchWindowController(mode); + addSearchWindow(search); + search.makeVisible(query); + } + + public static void closeSearchWindows() { + synchronized (searches) { + // dispose other windows + for (SearchWindowController sw : searches) { + sw.dispose(); + } + searches.clear(); + } + } + + public static boolean reuseSearchWindow(String text) { + for (int i = searches.size() - 1; i >= 0; i--) { + SearchWindowController swc = searches.get(i); + if (swc.getMode() == SearchMode.SEARCH) { + swc.makeVisible(text); + return true; + } + } + return false; + } + + private static void addSearchWindow(final SearchWindowController newSearchWindow) { + newSearchWindow.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + removeSearchWindow(newSearchWindow); + } + }); + synchronized (searches) { + searches.add(newSearchWindow); + } + } + + private static void removeSearchWindow(SearchWindowController searchWindow) { + synchronized (searches) { + searches.remove(searchWindow); + } + } +} diff --git a/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java b/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java index ca46dbf691..8e7f1a6a2d 100644 --- a/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java +++ b/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java @@ -291,8 +291,4 @@ public DockingDesktop getDesktop() { return desktop; } - @Override - public void resetDesktopLayout() { - } - } diff --git a/test/fixtures/org/omegat/core/TestCore.java b/test/fixtures/org/omegat/core/TestCore.java index 1dd19b617d..bda24d9a09 100644 --- a/test/fixtures/org/omegat/core/TestCore.java +++ b/test/fixtures/org/omegat/core/TestCore.java @@ -274,10 +274,6 @@ public DockingDesktop getDesktop() { return null; } - @Override - public void resetDesktopLayout() { - } - public Cursor getCursor() { return null; } From 2c0ca920fba3f886c6a5bf3945959962119563e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 6 Jul 2024 11:19:21 +0900 Subject: [PATCH 22/85] chore(deps): bump groovy from 4.0.21 to 4.0.22 (#1074) Bumps `groovy` from 4.0.21 to 4.0.22. Updates `org.apache.groovy:groovy-jsr223` from 4.0.21 to 4.0.22 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy-dateutil` from 4.0.21 to 4.0.22 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy-json` from 4.0.21 to 4.0.22 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy-xml` from 4.0.21 to 4.0.22 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy-swing` from 4.0.21 to 4.0.22 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy-templates` from 4.0.21 to 4.0.22 - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-jsr223 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy-dateutil dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy-json dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy-xml dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy-swing dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy-templates dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9547bb3f52..6ef8df693b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] slf4j = { strictly = "[2.0.7, 2.1[", prefer = "2.0.7" } slf4j-format = "0.5.1" -groovy = "4.0.21" +groovy = "4.0.22" junit = "4.13.2" commons_lang3 = "3.14.0" commons_io = "2.16.1" From 3f0a3717aee8812a7c036ce5d0fcb837847d067d Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 6 Jul 2024 14:52:02 +0900 Subject: [PATCH 23/85] fix: write startup log into file (#1076) * fix: write startup log into file - refactor: Log static initialization - changed: logger configuration to show time in log file - changed: update start up message with timezone Signed-off-by: Hiroshi Miura * style: unused import Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- src/org/omegat/Main.java | 28 ++++++++++++++++++---------- src/org/omegat/logger.properties | 4 ++-- src/org/omegat/util/Log.java | 11 ++++++++--- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/org/omegat/Main.java b/src/org/omegat/Main.java index 101a30e01e..31886cdbaf 100644 --- a/src/org/omegat/Main.java +++ b/src/org/omegat/Main.java @@ -50,9 +50,11 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.text.MessageFormat; +import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; +import java.time.format.TextStyle; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -66,8 +68,8 @@ import javax.swing.SwingUtilities; import javax.swing.UIManager; +import org.apache.commons.lang3.StringUtils; import tokyo.northside.logging.ILogger; -import tokyo.northside.logging.LoggerFactory; import org.omegat.CLIParameters.PSEUDO_TRANSLATE_TYPE; import org.omegat.CLIParameters.TAG_VALIDATION_MODE; @@ -117,12 +119,11 @@ * @author Hiroshi Miura */ public final class Main { - private static final ILogger LOGGER = LoggerFactory.getLogger(Main.class, OStrings.getResourceBundle()); private Main() { } - /** Project location for load on startup. */ + /** Project location for a load on startup. */ protected static File projectLocation = null; /** Remote project location. */ @@ -183,13 +184,20 @@ public static void main(String[] args) { if (PARAMS.containsKey(CLIParameters.DISABLE_LOCATION_SAVE)) { RuntimePreferences.setLocationSaveEnabled(false); } - LOGGER.atInfo().log( - "\n===================================================================\n" - + "{0} ({1}) Locale {2}", - OStrings.getNameAndVersion(), DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT) - .withLocale(Locale.getDefault()).format(ZonedDateTime.now()), - Locale.getDefault().getDisplayName()); - LOGGER.atInfo().logRB("LOG_STARTUP_INFO", System.getProperty("java.vendor"), + + // initialize logging backend and loading configuration. + ILogger logger = Log.getLogger(Main.class); + + logger.atInfo() + .setMessage("\n{0}\n{1} (started on {2} {3}) Locale {4}") + .addArgument(StringUtils.repeat('=', 120)) + .addArgument(OStrings.getNameAndVersion()) + .addArgument(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM) + .withLocale(Locale.getDefault()).format(ZonedDateTime.now())) + .addArgument(ZoneId.systemDefault().getDisplayName(TextStyle.SHORT, Locale.getDefault())) + .addArgument(Locale.getDefault().toLanguageTag()) + .log(); + logger.atInfo().logRB("LOG_STARTUP_INFO", System.getProperty("java.vendor"), System.getProperty("java.version"), System.getProperty("java.home")); System.setProperty("http.agent", OStrings.getDisplayNameAndVersion()); diff --git a/src/org/omegat/logger.properties b/src/org/omegat/logger.properties index 6808566195..0b0df17e52 100644 --- a/src/org/omegat/logger.properties +++ b/src/org/omegat/logger.properties @@ -8,10 +8,10 @@ org.omegat.level = ALL java.util.logging.ConsoleHandler.level = ALL org.omegat.util.logging.OmegaTFileHandler.level = ALL -org.omegat.util.logging.OmegaTLogFormatter.mask=$mark: $level: $text $key +org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $level: $text $key #org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $threadName [$level] $key $text -#org.omegat.util.logging.OmegaTLogFormatter.timeFormat=HH:mm:ss,SSSS +org.omegat.util.logging.OmegaTLogFormatter.timeFormat=HH:mm:ss,SSSS java.util.logging.ConsoleHandler.formatter = org.omegat.util.logging.OmegaTLogFormatter diff --git a/src/org/omegat/util/Log.java b/src/org/omegat/util/Log.java index 050f66ff7b..a69ea8ef0c 100644 --- a/src/org/omegat/util/Log.java +++ b/src/org/omegat/util/Log.java @@ -56,19 +56,24 @@ */ public final class Log { - private static final ILogger LOGGER = LoggerFactory.getLogger(ILogger.ROOT_LOGGER_NAME, - OStrings.getResourceBundle()); + private static final ILogger LOGGER; private Log() { } static { + LOGGER = LoggerFactory.getLogger(ILogger.ROOT_LOGGER_NAME, + OStrings.getResourceBundle()); + init(); + } + + private static void init() { boolean loaded = false; // Ask slf4j-format-jdk14 to append (KEY) to log message. // When you switch to backend other than slf4j-jdk14(aka. JUL), // you should set to false. Otherwise, you may get duplicated key - // in message. + // in a message. System.setProperty(LoggerDecorator.LOCALISATION_KEY_APPENDER, "true"); String customLogConfig = System.getProperty("java.util.logging.config.file"); From 1be9c8f5e8b4e781c8022211b4dcd41d14f6ad66 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 6 Jul 2024 17:28:29 +0900 Subject: [PATCH 24/85] fix: logger.properties - revert a logging format change in previous commit Signed-off-by: Hiroshi Miura --- src/org/omegat/logger.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/omegat/logger.properties b/src/org/omegat/logger.properties index 0b0df17e52..dbcd046734 100644 --- a/src/org/omegat/logger.properties +++ b/src/org/omegat/logger.properties @@ -8,7 +8,7 @@ org.omegat.level = ALL java.util.logging.ConsoleHandler.level = ALL org.omegat.util.logging.OmegaTFileHandler.level = ALL -org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $level: $text $key +org.omegat.util.logging.OmegaTLogFormatter.mask=$mark: $level: $text $key #org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $threadName [$level] $key $text org.omegat.util.logging.OmegaTLogFormatter.timeFormat=HH:mm:ss,SSSS From 887096ce505b99f1cc9219bbcb71e6c81363a410 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 6 Jul 2024 22:52:16 +0900 Subject: [PATCH 25/85] chore(ci): set integ-test projectName Integration test in Azure pipelines failed with wrong project name. It set project name. Signed-off-by: Hiroshi Miura --- ci/azure-pipelines/integ_test_steps.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/azure-pipelines/integ_test_steps.yml b/ci/azure-pipelines/integ_test_steps.yml index 5123ff21be..ca96c1150b 100644 --- a/ci/azure-pipelines/integ_test_steps.yml +++ b/ci/azure-pipelines/integ_test_steps.yml @@ -10,6 +10,7 @@ steps: - task: DockerCompose@0 displayName: 'Execute Integration-Test' inputs: + projectName: omegat action: Run services containerregistrytype: Container Registry dockerComposeFile: compose.yml @@ -22,6 +23,7 @@ steps: - task: DockerCompose@0 displayName: 'Clean up Integration-Test' inputs: + projectName: omegat action: Run a Docker Compose command containerregistrytype: Container Registry dockerComposeFile: compose.yml From 98a29b399c3a14d1eb1efec7f103bb0b7b35e9be Mon Sep 17 00:00:00 2001 From: Thomas CORDONNIER Date: Tue, 9 Jul 2024 17:47:30 +0200 Subject: [PATCH 26/85] Add copyright for parts copied from old filter --- src/org/omegat/filters4/xml/openxml/MsOfficeFileFilter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/org/omegat/filters4/xml/openxml/MsOfficeFileFilter.java b/src/org/omegat/filters4/xml/openxml/MsOfficeFileFilter.java index 719121cf2b..6e695fb216 100755 --- a/src/org/omegat/filters4/xml/openxml/MsOfficeFileFilter.java +++ b/src/org/omegat/filters4/xml/openxml/MsOfficeFileFilter.java @@ -4,6 +4,9 @@ glossaries, and translation leveraging into updated projects. Copyright (C) 2018 Thomas Cordonnier + 2007-2013 Didier Briel + 2015-2016 Didier Briel + 2019 Didier Briel Home page: https://www.omegat.org/ Support center: http://groups.yahoo.com/group/OmegaT/ @@ -45,6 +48,7 @@ * Filter for Microsoft Open XML. * * @author Thomas Cordonnier + * @author Didier Briel */ public class MsOfficeFileFilter extends AbstractZipFilter { private String DOCUMENTS; From 541e57b242488dab7c74f0200026c6b8abe6693a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Jul 2024 08:42:59 +0900 Subject: [PATCH 27/85] chore(deps): bump edu.sc.seis.launch4j from 3.0.5 to 3.0.6 (#1079) Bumps edu.sc.seis.launch4j from 3.0.5 to 3.0.6. --- updated-dependencies: - dependency-name: edu.sc.seis.launch4j dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6ef8df693b..26d4ba4ded 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -156,6 +156,6 @@ morfologik = ['morfologik', 'morfologik-speller'] [plugins] spotbugs = {id = "com.github.spotbugs", version = "6.0.18"} spotless = {id = "com.diffplug.spotless", version = "6.25.0"} -launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.5"} +launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.6"} versions = {id = "com.github.ben-manes.versions", version = "0.51.0"} ssh = {id = "org.hidetake.ssh", version = "2.11.2"} From 8cc4c2d405b10a8b91e505925b080563145cb117 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 11 Jul 2024 14:46:06 +0900 Subject: [PATCH 28/85] [RFE#1736] feat: Alternative translation highlight (#1082) * [RFE#1736] feat: Alternative translation highlight * [PR#950] Suggested changes * [PR#950] Remove unused import * Add copyright/license comment * [PR#950] Suggested changes #2 * Update Plugins.properties * Add test * Revert "[PR#950] Suggested changes" - OmegaT core is not mature for marker to enable plugin fully. - I withdraw my previous suggestion This reverts commit 87c722e8602fca95c6349fba512afea3a8514e96. Signed-off-by: Hiroshi Miura * Revert "[PR#950] Remove unused import" This reverts commit 00e6d5b1aa276e8b3699c176dd5df113cc18a7ce. * style: apply spotless and update suppressions for checkstyle This reverts commit 87c722e8602fca95c6349fba512afea3a8514e96. Signed-off-by: Hiroshi Miura * Revert "Update Plugins.properties" This reverts commit efdb31b907ad0fff22823cdab32bf84a40736125. Signed-off-by: Hiroshi Miura * fix: test compile error Signed-off-by: Hiroshi Miura * fix: extension position in View menu - Adding "Alt translation mark" item cause a location change of extension point Signed-off-by: Hiroshi Miura * docs: update changes.txt - add RFE#1736 Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura Co-authored-by: Lev Abashkin --- config/checkstyle/suppressions.xml | 2 +- release/changes.txt | 5 +- src/org/omegat/Bundle.properties | 2 + src/org/omegat/ColorScheme_dark.properties | 1 + src/org/omegat/ColorScheme_light.properties | 1 + src/org/omegat/gui/editor/EditorSettings.java | 73 ++++++++--- .../omegat/gui/editor/IEditorSettings.java | 8 +- .../omegat/gui/editor/MarkerController.java | 2 + .../editor/mark/AltTranslationsMarker.java | 65 ++++++++++ .../omegat/gui/main/BaseMainWindowMenu.java | 8 ++ .../gui/main/MainWindowMenuHandler.java | 21 ++- src/org/omegat/util/Preferences.java | 2 + src/org/omegat/util/gui/MenuExtender.java | 2 +- src/org/omegat/util/gui/Styles.java | 2 + test/data/mark/alternative.tmx | 27 ++++ test/fixtures/org/omegat/core/TestCore.java | 9 ++ .../mark/AltTranslationsMarkerTest.java | 122 ++++++++++++++++++ .../gui/editor/mark/MarkerTestBase.java | 11 ++ 18 files changed, 331 insertions(+), 32 deletions(-) create mode 100644 src/org/omegat/gui/editor/mark/AltTranslationsMarker.java create mode 100644 test/data/mark/alternative.tmx create mode 100644 test/src/org/omegat/gui/editor/mark/AltTranslationsMarkerTest.java diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml index e8874b3b41..b5da6b7561 100644 --- a/config/checkstyle/suppressions.xml +++ b/config/checkstyle/suppressions.xml @@ -101,7 +101,7 @@ - + diff --git a/release/changes.txt b/release/changes.txt index 612e20afdb..f4349365a3 100644 --- a/release/changes.txt +++ b/release/changes.txt @@ -1,7 +1,7 @@ ---------------------------------------------------------------------- OmegaT 6.1.0 ---------------------------------------------------------------------- - 44 Enhancement + 45 Enhancement 69 Bug fixes 5 Localisation updates ---------------------------------------------------------------------- @@ -9,6 +9,9 @@ Implemented requests: + - Alternative translation highlight + https://sourceforge.net/p/omegat/feature-requests/1736/ + - Support for Stardict's Pango content type https://sourceforge.net/p/omegat/feature-requests/1727/ diff --git a/src/org/omegat/Bundle.properties b/src/org/omegat/Bundle.properties index 017e3b12aa..e4fffd5370 100644 --- a/src/org/omegat/Bundle.properties +++ b/src/org/omegat/Bundle.properties @@ -425,6 +425,7 @@ MW_VIEW_MENU_MARK_WHITESPACE=Displa&y Whitespace MW_VIEW_MENU_MARK_BIDI=Display &Bidi Control Characters MW_VIEW_MENU_MARK_AUTOPOPULATED=Highlight &Auto-Populated Segments +MW_VIEW_MENU_MARK_ALT_TRANSLATIONS=Highlight Segments with Alternative Translation MW_VIEW_GLOSSARY_MARK=Mark Gl&ossary Matches LT_OPTIONS_MENU_ENABLED=Mark &Language Checker Issues @@ -2562,6 +2563,7 @@ COLOR_ALIGNER_NEEDSREVIEW=Aligner \"Needs Review\" group COLOR_ALIGNER_HIGHLIGHT=Aligner highlight COLOR_ALIGNER_TABLE_ROW_HIGHLIGHT=Aligner table row highlight COLOR_MACHINETRANSLATE_SELECTED_HIGHLIGHT=Machine translate highlight +COLOR_MARK_ALT_TRANSLATION=Alternative translation highlight GUI_COLORS_COLOR=Item: GUI_COLORS_RESET_COLOR=&Reset Colour PREFS_TITLE_COLORS=Colours diff --git a/src/org/omegat/ColorScheme_dark.properties b/src/org/omegat/ColorScheme_dark.properties index 94f4ecc075..e64e38d876 100644 --- a/src/org/omegat/ColorScheme_dark.properties +++ b/src/org/omegat/ColorScheme_dark.properties @@ -42,3 +42,4 @@ OmegaT.searchFieldErrorText=#7f0000 OmegaT.searchDimmedBackground=#80808080 OmegaT.searchResultBorder=#EED20080 OmegaT.machinetranslateSelectedHighlight=#ffcc00 +OmegaT.markAltTranslations=#006666 \ No newline at end of file diff --git a/src/org/omegat/ColorScheme_light.properties b/src/org/omegat/ColorScheme_light.properties index 3d42c54011..8bcb13fc62 100644 --- a/src/org/omegat/ColorScheme_light.properties +++ b/src/org/omegat/ColorScheme_light.properties @@ -42,3 +42,4 @@ OmegaT.searchFieldErrorText=#ff0000 OmegaT.searchDimmedBackground=#80808080 OmegaT.searchResultBorder=#EED20080 OmegaT.machinetranslateSelectedHighlight=#ffff00 +OmegaT.markAltTranslations=#33ffff diff --git a/src/org/omegat/gui/editor/EditorSettings.java b/src/org/omegat/gui/editor/EditorSettings.java index fefe1eb009..8599e908a8 100644 --- a/src/org/omegat/gui/editor/EditorSettings.java +++ b/src/org/omegat/gui/editor/EditorSettings.java @@ -62,6 +62,7 @@ public class EditorSettings implements IEditorSettings { private boolean markWhitespace; private boolean markParagraphDelimitations; private boolean markBidi; + private boolean markAltTranslations; private String displayModificationInfo; private boolean autoSpellChecking; private boolean viewSourceBold; @@ -83,19 +84,20 @@ public class EditorSettings implements IEditorSettings { protected EditorSettings(final EditorController parent) { this.parent = parent; - //options from menu 'view' + // options from menu 'view' useTabForAdvance = Preferences.isPreference(Preferences.USE_TAB_TO_ADVANCE); markTranslated = Preferences.isPreference(Preferences.MARK_TRANSLATED_SEGMENTS); markUntranslated = Preferences.isPreference(Preferences.MARK_UNTRANSLATED_SEGMENTS); displaySegmentSources = Preferences.isPreference(Preferences.DISPLAY_SEGMENT_SOURCES); markNonUniqueSegments = Preferences.isPreferenceDefault(Preferences.MARK_NON_UNIQUE_SEGMENTS, - MARK_NON_UNIQUE_SEGMENTS_DEFAULT); + MARK_NON_UNIQUE_SEGMENTS_DEFAULT); markNoted = Preferences.isPreference(Preferences.MARK_NOTED_SEGMENTS); - markNBSP = Preferences.isPreference(Preferences.MARK_NBSP); + markAltTranslations = Preferences.isPreference(Preferences.MARK_ALT_TRANSLATIONS); + markNBSP = Preferences.isPreference(Preferences.MARK_NBSP); markParagraphDelimitations = Preferences.isPreferenceDefault(Preferences.MARK_PARA_DELIMITATIONS, MARK_PARA_DELIMITATIONS_DEFAULT); - markWhitespace = Preferences.isPreference(Preferences.MARK_WHITESPACE); - markBidi = Preferences.isPreference(Preferences.MARK_BIDI); + markWhitespace = Preferences.isPreference(Preferences.MARK_WHITESPACE); + markBidi = Preferences.isPreference(Preferences.MARK_BIDI); displayModificationInfo = Preferences.getPreferenceDefault(Preferences.DISPLAY_MODIFICATION_INFO, DISPLAY_MODIFICATION_INFO_SELECTED); autoSpellChecking = Preferences.isPreference(Preferences.ALLOW_AUTO_SPELLCHECKING); @@ -211,21 +213,29 @@ public boolean isMarkNotedSegments() { public boolean isMarkNBSP() { return markNBSP; } + /** * mark whitespace? + * * @return true when set, false otherwise */ public boolean isMarkWhitespace() { return markWhitespace; } + /** * mark Bidirectional control characters + * * @return true when set, false otherwise */ public boolean isMarkBidi() { return markBidi; } + public boolean isMarkAltTranslations() { + return markAltTranslations; + } + public boolean isDoFontFallback() { return doFontFallback; } @@ -285,6 +295,7 @@ public void setMarkNBSP(boolean markNBSP) { parent.activateEntry(); } } + public void setMarkWhitespace(boolean markWhitespace) { UIThreadsUtil.mustBeSwingThread(); @@ -298,7 +309,7 @@ public void setMarkWhitespace(boolean markWhitespace) { parent.activateEntry(); } } - + public void setMarkParagraphDelimitations(boolean delimitations) { UIThreadsUtil.mustBeSwingThread(); @@ -331,6 +342,20 @@ public void setMarkBidi(boolean markBidi) { } } + public void setMarkAltTranslations(boolean markAltTranslations) { + UIThreadsUtil.mustBeSwingThread(); + + parent.commitAndDeactivate(); + + this.markAltTranslations = markAltTranslations; + Preferences.setPreference(Preferences.MARK_ALT_TRANSLATIONS, markAltTranslations); + + if (Core.getProject().isProjectLoaded()) { + parent.loadDocument(); + parent.activateEntry(); + } + } + public void setDoFontFallback(boolean doFontFalback) { UIThreadsUtil.mustBeSwingThread(); @@ -437,15 +462,15 @@ public void setAutoSpellChecking(boolean autoSpellChecking) { } /** - * repaint segments in editor according to new view options. Use when options change to make them effective - * immediately. + * repaint segments in editor according to new view options. Use when + * options change to make them effective immediately. */ public void updateViewPreferences() { UIThreadsUtil.mustBeSwingThread(); parent.commitAndDeactivate(); - //update variables + // update variables viewSourceBold = Preferences.isPreference(Preferences.VIEW_OPTION_SOURCE_ALL_BOLD); viewActiveSourceBold = Preferences.isPreference(Preferences.VIEW_OPTION_SOURCE_ACTIVE_BOLD); markFirstNonUnique = Preferences.isPreference(Preferences.VIEW_OPTION_UNIQUE_FIRST); @@ -457,15 +482,16 @@ public void updateViewPreferences() { } /** - * repaint segments in editor according to new view tag validation options. Use when options change to make them - * effective immediately. + * repaint segments in editor according to new view tag validation options. + * Use when options change to make them effective immediately. */ public void updateTagValidationPreferences() { UIThreadsUtil.mustBeSwingThread(); parent.commitAndDeactivate(); - // nothing special to do: tags/placeholders are determined by segment builder and info is passed as argument to + // nothing special to do: tags/placeholders are determined by segment + // builder and info is passed as argument to // getattributeSet. if (Core.getProject().isProjectLoaded()) { @@ -480,12 +506,14 @@ public void updateTagValidationPreferences() { * @param isSource * is it a source segment or a target segment * @param isPlaceholder - * is it for a placeholder (OmegaT tag or sprintf-variable etc.) or regular text inside the segment? + * is it for a placeholder (OmegaT tag or sprintf-variable etc.) + * or regular text inside the segment? * @param isRemoveText * is it text that should be removed from translation? * @param duplicate - * is the sourceTextEntry a duplicate or not? values: DUPLICATE.NONE, DUPLICATE.FIRST or DUPLICATE.NEXT. - * See sourceTextEntryste.getDuplicate() + * is the sourceTextEntry a duplicate or not? values: + * DUPLICATE.NONE, DUPLICATE.FIRST or DUPLICATE.NEXT. See + * sourceTextEntryste.getDuplicate() * @param active * is it an active segment? * @param translationExists @@ -544,7 +572,7 @@ public AttributeSet getAttributeSet(boolean isSource, boolean isPlaceholder, boo fg = Styles.EditorColor.COLOR_REMOVETEXT_TARGET.getColor(); } - //determine background color + // determine background color Color bg = null; if (active) { if (isSource) { @@ -585,11 +613,12 @@ public AttributeSet getAttributeSet(boolean isSource, boolean isPlaceholder, boo break; } } - if (isNBSP && isMarkNBSP()) { //overwrite others, because space is smallest. + if (isNBSP && isMarkNBSP()) { // overwrite others, because space is + // smallest. bg = Styles.EditorColor.COLOR_NBSP.getColor(); } - //determine bold + // determine bold Boolean bold = false; if (isSource) { if (viewSourceBold || (active && viewActiveSourceBold)) { @@ -597,7 +626,7 @@ public AttributeSet getAttributeSet(boolean isSource, boolean isPlaceholder, boo } } - //determine italic + // determine italic Boolean italic = false; if (isRemoveText && isSource) { italic = true; @@ -608,15 +637,17 @@ public AttributeSet getAttributeSet(boolean isSource, boolean isPlaceholder, boo /** * Returns font attributes for paragraph start + * * @return */ public AttributeSet getParagraphStartAttributeSet() { - return Styles.createAttributeSet(Styles.EditorColor.COLOR_PARAGRAPH_START.getColor(), - null, false, true); + return Styles.createAttributeSet(Styles.EditorColor.COLOR_PARAGRAPH_START.getColor(), null, false, + true); } /** * Returns font attributes for the modification info line. + * * @return */ public AttributeSet getModificationInfoAttributeSet() { diff --git a/src/org/omegat/gui/editor/IEditorSettings.java b/src/org/omegat/gui/editor/IEditorSettings.java index b7785b877c..1e1a44ddc2 100644 --- a/src/org/omegat/gui/editor/IEditorSettings.java +++ b/src/org/omegat/gui/editor/IEditorSettings.java @@ -66,15 +66,19 @@ public interface IEditorSettings { boolean isMarkWhitespace(); void setMarkWhitespace(boolean markWhitespace); - + void setMarkParagraphDelimitations(boolean mark); - + boolean isMarkParagraphDelimitations(); boolean isMarkBidi(); void setMarkBidi(boolean markBidi); + boolean isMarkAltTranslations(); + + void setMarkAltTranslations(boolean markAltTranslations); + boolean isAutoSpellChecking(); void setAutoSpellChecking(boolean isNeedToSpell); diff --git a/src/org/omegat/gui/editor/MarkerController.java b/src/org/omegat/gui/editor/MarkerController.java index 9753c59e93..a158cb3c65 100644 --- a/src/org/omegat/gui/editor/MarkerController.java +++ b/src/org/omegat/gui/editor/MarkerController.java @@ -40,6 +40,7 @@ import org.omegat.core.Core; import org.omegat.core.spellchecker.SpellCheckerMarker; import org.omegat.filters2.master.PluginUtils; +import org.omegat.gui.editor.mark.AltTranslationsMarker; import org.omegat.gui.editor.mark.BidiMarkers; import org.omegat.gui.editor.mark.CalcMarkersThread; import org.omegat.gui.editor.mark.ComesFromAutoTMMarker; @@ -87,6 +88,7 @@ public static void init() throws Exception { Core.registerMarker(new ComesFromMTMarker()); Core.registerMarker(new FontFallbackMarker()); Core.registerMarker(new SpellCheckerMarker()); + Core.registerMarker(new AltTranslationsMarker()); } diff --git a/src/org/omegat/gui/editor/mark/AltTranslationsMarker.java b/src/org/omegat/gui/editor/mark/AltTranslationsMarker.java new file mode 100644 index 0000000000..8782d69d3a --- /dev/null +++ b/src/org/omegat/gui/editor/mark/AltTranslationsMarker.java @@ -0,0 +1,65 @@ +/************************************************************************** + OmegaT - Computer Assisted Translation (CAT) tool + with fuzzy matching, translation memory, keyword search, + glossaries, and translation leveraging into updated projects. + + Copyright (C) 2024 Lev Abashkin + 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.gui.editor.mark; + +import org.omegat.core.Core; +import org.omegat.core.data.SourceTextEntry; +import org.omegat.util.gui.Styles; + +import javax.swing.text.Highlighter; +import java.util.Collections; +import java.util.List; + +public class AltTranslationsMarker extends AbstractMarker { + + private final Highlighter.HighlightPainter painter = new TransparentHighlightPainter( + Styles.EditorColor.COLOR_MARK_ALT_TRANSLATION.getColor(), 0.5F); + + public AltTranslationsMarker() throws Exception { + super(); + } + + @Override + protected boolean isEnabled() { + return Core.getEditor().getSettings().isMarkAltTranslations(); + } + + @Override + public List getMarksForEntry(SourceTextEntry ste, String sourceText, String translationText, + boolean isActive) throws Exception { + if (!isEnabled()) { + return null; + } + + if (!Core.getProject().getTranslationInfo(ste).defaultTranslation) { + Mark m = new Mark(Mark.ENTRY_PART.TRANSLATION, 0, translationText.length()); + m.painter = painter; + return Collections.singletonList(m); + } + + return null; + } +} diff --git a/src/org/omegat/gui/main/BaseMainWindowMenu.java b/src/org/omegat/gui/main/BaseMainWindowMenu.java index be2e9d55ed..5048808df5 100644 --- a/src/org/omegat/gui/main/BaseMainWindowMenu.java +++ b/src/org/omegat/gui/main/BaseMainWindowMenu.java @@ -334,6 +334,8 @@ protected void createComponents() { "MW_VIEW_MENU_DISPLAY_SEGMENT_SOURCES"); viewMarkNonUniqueSegmentsCheckBoxMenuItem = createCheckboxMenuItem( "MW_VIEW_MENU_MARK_NON_UNIQUE_SEGMENTS"); + viewMarkAlternativeTranslationsCheckBoxMenuItem = createCheckboxMenuItem( + "MW_VIEW_MENU_MARK_ALT_TRANSLATIONS"); viewMarkNotedSegmentsCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_MENU_MARK_NOTED_SEGMENTS"); viewMarkNBSPCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_MENU_MARK_NBSP"); viewMarkWhitespaceCheckBoxMenuItem = createCheckboxMenuItem("MW_VIEW_MENU_MARK_WHITESPACE"); @@ -362,6 +364,8 @@ protected void createComponents() { .setIcon(MainMenuIcons.newTextIcon(Styles.EditorColor.COLOR_NON_UNIQUE.getColor(), 'M')); viewMarkNotedSegmentsCheckBoxMenuItem .setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_NOTED.getColor())); + viewMarkAlternativeTranslationsCheckBoxMenuItem + .setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_MARK_ALT_TRANSLATION.getColor())); viewMarkNBSPCheckBoxMenuItem .setIcon(MainMenuIcons.newColorIcon(Styles.EditorColor.COLOR_NBSP.getColor())); viewMarkWhitespaceCheckBoxMenuItem @@ -551,6 +555,7 @@ protected void constructMenu() { viewMenu.add(viewMarkParagraphStartCheckBoxMenuItem); viewMenu.add(viewDisplaySegmentSourceCheckBoxMenuItem); viewMenu.add(viewMarkNonUniqueSegmentsCheckBoxMenuItem); + viewMenu.add(viewMarkAlternativeTranslationsCheckBoxMenuItem); viewMenu.add(viewMarkNotedSegmentsCheckBoxMenuItem); viewMenu.add(viewMarkNBSPCheckBoxMenuItem); viewMenu.add(viewMarkWhitespaceCheckBoxMenuItem); @@ -892,6 +897,8 @@ protected void updateCheckboxesOnStart() { .setSelected(Core.getEditor().getSettings().isMarkNonUniqueSegments()); viewMarkNotedSegmentsCheckBoxMenuItem .setSelected(Core.getEditor().getSettings().isMarkNotedSegments()); + viewMarkAlternativeTranslationsCheckBoxMenuItem + .setSelected(Core.getEditor().getSettings().isMarkAltTranslations()); viewMarkNBSPCheckBoxMenuItem.setSelected(Core.getEditor().getSettings().isMarkNBSP()); viewMarkWhitespaceCheckBoxMenuItem.setSelected(Core.getEditor().getSettings().isMarkWhitespace()); viewMarkBidiCheckBoxMenuItem.setSelected(Core.getEditor().getSettings().isMarkBidi()); @@ -1112,6 +1119,7 @@ public JMenu getMenu(MenuExtender.MenuKey marker) { JMenuItem upperCaseMenuItem; JCheckBoxMenuItem viewDisplaySegmentSourceCheckBoxMenuItem; JCheckBoxMenuItem viewMarkNonUniqueSegmentsCheckBoxMenuItem; + JCheckBoxMenuItem viewMarkAlternativeTranslationsCheckBoxMenuItem; JCheckBoxMenuItem viewMarkNotedSegmentsCheckBoxMenuItem; JCheckBoxMenuItem viewMarkNBSPCheckBoxMenuItem; JCheckBoxMenuItem viewMarkWhitespaceCheckBoxMenuItem; diff --git a/src/org/omegat/gui/main/MainWindowMenuHandler.java b/src/org/omegat/gui/main/MainWindowMenuHandler.java index 58021a13af..0328bf2fda 100644 --- a/src/org/omegat/gui/main/MainWindowMenuHandler.java +++ b/src/org/omegat/gui/main/MainWindowMenuHandler.java @@ -695,6 +695,11 @@ public void viewMarkBidiCheckBoxMenuItemActionPerformed() { Core.getEditor().getSettings().setMarkBidi(mainWindow.menu.viewMarkBidiCheckBoxMenuItem.isSelected()); } + public void viewMarkAlternativeTranslationsCheckBoxMenuItemActionPerformed() { + Core.getEditor().getSettings().setMarkAltTranslations( + mainWindow.menu.viewMarkAlternativeTranslationsCheckBoxMenuItem.isSelected()); + } + public void viewMarkAutoPopulatedCheckBoxMenuItemActionPerformed() { Core.getEditor().getSettings() .setMarkAutoPopulated(mainWindow.menu.viewMarkAutoPopulatedCheckBoxMenuItem.isSelected()); @@ -745,7 +750,8 @@ public void toolsCheckIssuesCurrentFileMenuItemActionPerformed() { } /** - * Identify all the placeholders in the source text and automatically inserts them into the target text. + * Identify all the placeholders in the source text and automatically + * inserts them into the target text. */ public void editTagPainterMenuItemActionPerformed() { // insert tags @@ -811,7 +817,8 @@ public void optionsDictionaryFuzzyMatchingCheckBoxMenuItemActionPerformed() { } /** - * Displays the filters setup dialog to allow customizing file filters in detail. + * Displays the filters setup dialog to allow customizing file filters in + * detail. */ public void optionsSetupFileFiltersMenuItemActionPerformed() { new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), @@ -819,7 +826,8 @@ public void optionsSetupFileFiltersMenuItemActionPerformed() { } /** - * Displays the segmentation setup dialog to allow customizing the segmentation rules in detail. + * Displays the segmentation setup dialog to allow customizing the + * segmentation rules in detail. */ public void optionsSentsegMenuItemActionPerformed() { new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), @@ -828,7 +836,8 @@ public void optionsSentsegMenuItemActionPerformed() { } /** - * Displays the workflow setup dialog to allow customizing the diverse workflow options. + * Displays the workflow setup dialog to allow customizing the diverse + * workflow options. */ public void optionsWorkflowMenuItemActionPerformed() { new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), @@ -836,8 +845,8 @@ public void optionsWorkflowMenuItemActionPerformed() { } /** - * Restores defaults for all dockable parts. May be expanded in the future to reset the entire GUI to its - * defaults. + * Restores defaults for all dockable parts. May be expanded in the future + * to reset the entire GUI to its defaults. */ public void viewRestoreGUIMenuItemActionPerformed() { Core.getMainWindow().resetDesktopLayout(); diff --git a/src/org/omegat/util/Preferences.java b/src/org/omegat/util/Preferences.java index 42337926f0..221b204989 100644 --- a/src/org/omegat/util/Preferences.java +++ b/src/org/omegat/util/Preferences.java @@ -187,6 +187,8 @@ public final class Preferences { public static final String MARK_WHITESPACE = "mark_whitespace"; /** Mark Bidi controls as symbols */ public static final String MARK_BIDI = "mark_bidi"; + /** Mark alternative translations */ + public static final String MARK_ALT_TRANSLATIONS = "mark_alt_translations"; /** Do aggressive font fallback */ public static final String FONT_FALLBACK = "font_fallback"; diff --git a/src/org/omegat/util/gui/MenuExtender.java b/src/org/omegat/util/gui/MenuExtender.java index 784b729140..97d6f79df9 100644 --- a/src/org/omegat/util/gui/MenuExtender.java +++ b/src/org/omegat/util/gui/MenuExtender.java @@ -54,7 +54,7 @@ public enum MenuKey { /** * View menu. */ - VIEW("view", 13), + VIEW("view", 14), /** * Tools menu. */ diff --git a/src/org/omegat/util/gui/Styles.java b/src/org/omegat/util/gui/Styles.java index e38c2b8cb2..2937971fd2 100644 --- a/src/org/omegat/util/gui/Styles.java +++ b/src/org/omegat/util/gui/Styles.java @@ -120,6 +120,8 @@ public enum EditorColor { COLOR_MARK_COMES_FROM_TM_XENFORCED(UIManager.getColor("OmegaT.markComesFromTmXenforced")), + COLOR_MARK_ALT_TRANSLATION(UIManager.getColor("OmegaT.markAltTranslations")), + COLOR_REPLACE(UIManager.getColor("OmegaT.replace")), COLOR_LANGUAGE_TOOLS(UIManager.getColor("OmegaT.languageTools")), diff --git a/test/data/mark/alternative.tmx b/test/data/mark/alternative.tmx new file mode 100644 index 0000000000..83be1c7464 --- /dev/null +++ b/test/data/mark/alternative.tmx @@ -0,0 +1,27 @@ + + + +
+ + + + Edit + + + default + + + + file1 + 1_1 + prev1 + next1 + + Edit + + + alternative + + + + \ No newline at end of file diff --git a/test/fixtures/org/omegat/core/TestCore.java b/test/fixtures/org/omegat/core/TestCore.java index bda24d9a09..ae30b89485 100644 --- a/test/fixtures/org/omegat/core/TestCore.java +++ b/test/fixtures/org/omegat/core/TestCore.java @@ -386,6 +386,15 @@ public boolean isMarkBidi() { public void setMarkBidi(boolean markBidi) { } + @Override + public boolean isMarkAltTranslations() { + return false; + } + + @Override + public void setMarkAltTranslations(final boolean markAltTranslations) { + } + @Override public boolean isAutoSpellChecking() { return false; diff --git a/test/src/org/omegat/gui/editor/mark/AltTranslationsMarkerTest.java b/test/src/org/omegat/gui/editor/mark/AltTranslationsMarkerTest.java new file mode 100644 index 0000000000..730d2bf5d8 --- /dev/null +++ b/test/src/org/omegat/gui/editor/mark/AltTranslationsMarkerTest.java @@ -0,0 +1,122 @@ +/************************************************************************** + OmegaT - Computer Assisted Translation (CAT) tool + with fuzzy matching, translation memory, keyword search, + glossaries, and translation leveraging into updated projects. + + Copyright (C) 2024 Lev Abashkin + 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.gui.editor.mark; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.nio.file.Paths; +import java.util.Collections; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; + +import org.omegat.core.Core; +import org.omegat.core.TestCoreInitializer; +import org.omegat.core.data.EntryKey; +import org.omegat.core.data.NotLoadedProject; +import org.omegat.core.data.ProjectProperties; +import org.omegat.core.data.ProjectTMX; +import org.omegat.core.data.SourceTextEntry; +import org.omegat.core.data.TMXEntry; +import org.omegat.core.segmentation.SRX; +import org.omegat.core.segmentation.Segmenter; +import org.omegat.util.Language; + +public class AltTranslationsMarkerTest extends MarkerTestBase { + + private ProjectTMX projectTMX; + + @Before + public void preUp() throws Exception { + TestCoreInitializer.initEditor(editor); + Core.setSegmenter(new Segmenter(SRX.getDefault())); + projectTMX = new ProjectTMX(new Language("en"), new Language("fr"), true, + Paths.get("test/data/mark/alternative.tmx").toFile(), null); + Core.setProject(new NotLoadedProject() { + @Override + public boolean isProjectLoaded() { + return true; + } + + @Override + public ProjectProperties getProjectProperties() { + return new ProjectProperties() { + @Override + public Language getSourceLanguage() { + return new Language("en"); + } + + @Override + public Language getTargetLanguage() { + return new Language("fr"); + } + }; + } + + @Override + public TMXEntry getTranslationInfo(SourceTextEntry ste) { + if (ste == null || projectTMX == null) { + return EMPTY_TRANSLATION; + } + TMXEntry r = projectTMX.getMultipleTranslation(ste.getKey()); + if (r == null) { + r = projectTMX.getDefaultTranslation(ste.getSrcText()); + } + if (r == null) { + r = EMPTY_TRANSLATION; + } + return r; + } + + }); + } + + @Test + public void testAltTranslationsMarker() throws Exception { + IMarker marker = new AltTranslationsMarker(); + Core.getEditor().getSettings().setMarkAltTranslations(true); + String sourceText = "Edit"; + String translationText = "default"; + // default entry: file and + EntryKey key0 = new EntryKey("file0", sourceText, "1_0", "prev0", "next0", "path"); + SourceTextEntry ste0 = new SourceTextEntry(key0, 1, new String[0], sourceText, + Collections.emptyList()); + List result = marker.getMarksForEntry(ste0, sourceText, translationText, true); + assertNull(result); + // alternative entry: file and 1_0 + translationText = "alternative"; + EntryKey key1 = new EntryKey("file1", sourceText, "1_1", "prev1", "next1", null); + SourceTextEntry ste1 = new SourceTextEntry(key1, 1, new String[0], sourceText, + Collections.emptyList()); + result = marker.getMarksForEntry(ste1, sourceText, translationText, true); + assertNotNull(result); + assertEquals(1, result.size()); + // TODO: further checks + } +} diff --git a/test/src/org/omegat/gui/editor/mark/MarkerTestBase.java b/test/src/org/omegat/gui/editor/mark/MarkerTestBase.java index 1282b08a62..cb2509ab0a 100644 --- a/test/src/org/omegat/gui/editor/mark/MarkerTestBase.java +++ b/test/src/org/omegat/gui/editor/mark/MarkerTestBase.java @@ -63,6 +63,7 @@ public static class MockEditorSettings implements IEditorSettings { private boolean markGlossaryMatches; private boolean markLanguageChecker; private boolean doFontFallback; + private boolean markAlt; @Override public boolean isUseTabForAdvance() { @@ -164,6 +165,16 @@ public void setMarkBidi(boolean markBidi) { this.markBidi = markBidi; } + @Override + public boolean isMarkAltTranslations() { + return markAlt; + } + + @Override + public void setMarkAltTranslations(final boolean markAltTranslations) { + markAlt = markAltTranslations; + } + @Override public boolean isAutoSpellChecking() { return autoSpellChecking; From 6290d19a2379b66c8c80af01c38da2684c713b45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Jul 2024 21:30:01 +0900 Subject: [PATCH 29/85] chore(deps): bump org.jsoup:jsoup from 1.17.2 to 1.18.1 (#1081) Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.17.2 to 1.18.1. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES.md) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.17.2...jsoup-1.18.1) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 26d4ba4ded..fbcb9cfd38 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,7 +7,7 @@ commons_lang3 = "3.14.0" commons_io = "2.16.1" commons_text = "1.11.0" commons_validator = "1.9.0" -jsoup = "1.17.2" +jsoup = "1.18.1" icu4j = { require = "[70,73.2[", prefer = "72.1" } stax2api = "4.2.2" woodstox = "6.5.0" From 378d9d2b60cd90d0ba71c5fbd20586d54b30a7ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:01:42 +0900 Subject: [PATCH 30/85] chore(deps): bump com.github.spotbugs from 6.0.18 to 6.0.19 (#1083) Bumps com.github.spotbugs from 6.0.18 to 6.0.19. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fbcb9cfd38..23e965ea8d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -154,7 +154,7 @@ xmlunit = ["xmlunit-core", "xmlunit-assertj", "assertj"] morfologik = ['morfologik', 'morfologik-speller'] [plugins] -spotbugs = {id = "com.github.spotbugs", version = "6.0.18"} +spotbugs = {id = "com.github.spotbugs", version = "6.0.19"} spotless = {id = "com.diffplug.spotless", version = "6.25.0"} launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.6"} versions = {id = "com.github.ben-manes.versions", version = "0.51.0"} From 3853182bb0525756e6c00f4ec30a4d970a570dfc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 23:10:16 +0900 Subject: [PATCH 31/85] chore(deps): bump com.gradle.develocity from 3.17.5 to 3.17.6 (#1089) Bumps com.gradle.develocity from 3.17.5 to 3.17.6. --- updated-dependencies: - dependency-name: com.gradle.develocity dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 4e1c61bdf3..c3fc45b792 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,6 @@ plugins { id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' - id 'com.gradle.develocity' version '3.17.5' + id 'com.gradle.develocity' version '3.17.6' } develocity { buildScan { From ef4b01a66def9776e2748f895bfc298eb364a536 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 23:10:55 +0900 Subject: [PATCH 32/85] chore(deps): bump com.formdev:flatlaf from 3.4.1 to 3.5 (#1085) Bumps [com.formdev:flatlaf](https://github.com/JFormDesigner/FlatLaf) from 3.4.1 to 3.5. - [Release notes](https://github.com/JFormDesigner/FlatLaf/releases) - [Changelog](https://github.com/JFormDesigner/FlatLaf/blob/main/CHANGELOG.md) - [Commits](https://github.com/JFormDesigner/FlatLaf/compare/3.4.1...3.5) --- updated-dependencies: - dependency-name: com.formdev:flatlaf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 23e965ea8d..92a6e276f7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -48,7 +48,7 @@ xjc = "2.3.4" jna = "5.13.0" jfa = "1.2.0" tipoftheday = "0.4.4" -flatlaf="3.4.1" +flatlaf="3.5" assertj_swing_junit = "4.0.0-beta-1" morfologik = "2.1.9" From 4541e8aa3ed9d7ba393b8940a502e55db7442aa1 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 25 Jul 2024 23:12:50 +0900 Subject: [PATCH 33/85] feat: show only a current session log when Help>Log (#1077) * feat: introduce LogDialogController - Add LogDialogController class - Update form with NetBeans Gui editor Signed-off-by: Hiroshi Miura * feat: log to OmegaT_session_yyyyMMddHHmmss.log file Signed-off-by: Hiroshi Miura * feat: use timestap for log message Signed-off-by: Hiroshi Miura * docs: update manual Signed-off-by: Hiroshi Miura * fix: remove unused property Signed-off-by: Hiroshi Miura * feat: accept both size, count and retention Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- doc_src/en/App_ConfigurationFolder.xml | 10 +- src/org/omegat/gui/dialogs/LogDialog.form | 8 +- src/org/omegat/gui/dialogs/LogDialog.java | 76 +-------- .../gui/dialogs/LogDialogController.java | 151 ++++++++++++++++++ .../gui/main/MainWindowMenuHandler.java | 4 +- src/org/omegat/logger.properties | 14 +- src/org/omegat/util/Log.java | 16 ++ .../util/logging/OmegaTFileHandler.java | 119 +++++++++----- .../util/logging/OmegaTLogFormatter.java | 24 +-- .../gui/main/TestMainWindowMenuHandler.java | 4 +- 10 files changed, 292 insertions(+), 134 deletions(-) create mode 100644 src/org/omegat/gui/dialogs/LogDialogController.java diff --git a/doc_src/en/App_ConfigurationFolder.xml b/doc_src/en/App_ConfigurationFolder.xml index 17ec5d5725..cba1850a2c 100644 --- a/doc_src/en/App_ConfigurationFolder.xml +++ b/doc_src/en/App_ConfigurationFolder.xml @@ -74,8 +74,12 @@ logs/ - This folder contains a number of log files. The most current is - OmegaT.log. + This folder contains a number of log files. The file name format is + OmegaT_99999_yyyyMMdd-hhmmss.log. + + 99999 part is 5 digit session id from 00000 to 99999. It will be random number. + + yyyyMMdd-hhmmss part is a date and time, like 20240704-201200 means July 4th, 2024, 20:12:00 in local time. These files record various internal state and program event messages generated while OmegaT is running. If OmegaT behaves @@ -84,7 +88,7 @@ Use to view the - contents of the file. + contents of the log file of current session. diff --git a/src/org/omegat/gui/dialogs/LogDialog.form b/src/org/omegat/gui/dialogs/LogDialog.form index a891937b66..859ed1d401 100644 --- a/src/org/omegat/gui/dialogs/LogDialog.form +++ b/src/org/omegat/gui/dialogs/LogDialog.form @@ -44,6 +44,9 @@ + + + @@ -71,10 +74,8 @@ - - - + @@ -88,6 +89,7 @@ + diff --git a/src/org/omegat/gui/dialogs/LogDialog.java b/src/org/omegat/gui/dialogs/LogDialog.java index 62e57ce6e1..6022ed5884 100644 --- a/src/org/omegat/gui/dialogs/LogDialog.java +++ b/src/org/omegat/gui/dialogs/LogDialog.java @@ -28,20 +28,9 @@ package org.omegat.gui.dialogs; import java.awt.Font; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import javax.swing.JFileChooser; -import javax.swing.SwingWorker; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import org.omegat.util.Log; import org.omegat.util.OStrings; -import org.omegat.util.Preferences; -import org.omegat.util.gui.OSXIntegration; import org.omegat.util.gui.StaticUIUtils; /** @@ -57,9 +46,6 @@ public class LogDialog extends javax.swing.JDialog { public static final int RET_CANCEL = 0; /** A return status code - returned if OK button has been pressed */ public static final int RET_OK = 1; - public static final String DIALOG_NAME = "log_dialog"; - public static final String OK_BUTTON_NAME = "log_dialog_ok_button"; - public static final String LOG_TEXTPANE_NAME = "log_dialog_log_textpane"; private int returnStatus = RET_CANCEL; @@ -71,9 +57,6 @@ public LogDialog(java.awt.Frame parent) { initComponents(); setTitle(OStrings.getString("LOGDIALOG_TITLE") + " " + Log.getLogFileName()); - setName(DIALOG_NAME); - okButton.setName(OK_BUTTON_NAME); - logTextPane.setName(LOG_TEXTPANE_NAME); StaticUIUtils.setEscapeClosable(this); @@ -82,26 +65,6 @@ public LogDialog(java.awt.Frame parent) { Font currFont = logTextPane.getFont(); logTextPane.setFont(new Font(Font.MONOSPACED, currFont.getStyle(), currFont.getSize())); - - File logLocation = new File(Log.getLogFilePath()); - new SwingWorker() { - @Override - protected String doInBackground() throws Exception { - try (FileInputStream fis = new FileInputStream(logLocation)) { - return IOUtils.toString(fis, StandardCharsets.UTF_8); - } catch (Exception e) { - return ""; - } - } - protected void done() { - try { - logTextPane.setText(get()); - } catch (Exception e) { - Log.log(e); - } - OSXIntegration.setProxyIcon(getRootPane(), logLocation); - }; - }.execute(); } /** @@ -116,6 +79,7 @@ public int getReturnStatus() { * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ + // //GEN-BEGIN:initComponents private void initComponents() { @@ -143,11 +107,6 @@ public void windowClosing(java.awt.event.WindowEvent evt) { innerButtonPanel.setLayout(new javax.swing.BoxLayout(innerButtonPanel, javax.swing.BoxLayout.LINE_AXIS)); org.openide.awt.Mnemonics.setLocalizedText(saveAsButton, OStrings.getString("BUTTON_SAVE_AS")); // NOI18N - saveAsButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - saveAsButtonActionPerformed(evt); - } - }); innerButtonPanel.add(saveAsButton); org.openide.awt.Mnemonics.setLocalizedText(okButton, OStrings.getString("BUTTON_OK")); // NOI18N @@ -165,32 +124,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { pack(); }// //GEN-END:initComponents - private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_okButtonActionPerformed doClose(RET_OK); - }//GEN-LAST:event_okButtonActionPerformed + }// GEN-LAST:event_okButtonActionPerformed - private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog + private void closeDialog(java.awt.event.WindowEvent evt) {// GEN-FIRST:event_closeDialog doClose(RET_CANCEL); - }//GEN-LAST:event_closeDialog - - private void saveAsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsButtonActionPerformed - String curDir = Preferences.getPreferenceDefault(Preferences.CURRENT_FOLDER, System.getProperty("user.home")); - JFileChooser chooser = new JFileChooser(); - chooser.setSelectedFile(new File(curDir, Log.getLogFileName())); - if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) { - return; - } - File outFile = chooser.getSelectedFile(); - if (outFile.exists() && !FileCollisionDialog.promptToReplace(this, outFile.getName())) { - return; - } - try { - FileUtils.copyFile(new File(Log.getLogFilePath()), chooser.getSelectedFile()); - } catch (IOException ex) { - Log.log(ex); - } - Preferences.setPreference(Preferences.CURRENT_FOLDER, outFile.getParent()); - }//GEN-LAST:event_saveAsButtonActionPerformed + }// GEN-LAST:event_closeDialog private void doClose(int retStatus) { returnStatus = retStatus; @@ -201,9 +141,9 @@ private void doClose(int retStatus) { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel buttonPanel; private javax.swing.JPanel innerButtonPanel; - private javax.swing.JTextPane logTextPane; - private javax.swing.JButton okButton; - private javax.swing.JButton saveAsButton; + javax.swing.JTextPane logTextPane; + javax.swing.JButton okButton; + javax.swing.JButton saveAsButton; private javax.swing.JScrollPane scroll; // End of variables declaration//GEN-END:variables } diff --git a/src/org/omegat/gui/dialogs/LogDialogController.java b/src/org/omegat/gui/dialogs/LogDialogController.java new file mode 100644 index 0000000000..829e9be36c --- /dev/null +++ b/src/org/omegat/gui/dialogs/LogDialogController.java @@ -0,0 +1,151 @@ +/******************************************************************************* + 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.gui.dialogs; + +import java.awt.event.ActionEvent; +import java.io.BufferedWriter; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.stream.Stream; + +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JTextPane; +import javax.swing.SwingWorker; + +import org.omegat.util.Log; +import org.omegat.util.Preferences; +import org.omegat.util.gui.OSXIntegration; + +/** + * @author miurahr + */ +public class LogDialogController { + public static final String DIALOG_NAME = "log_dialog"; + public static final String OK_BUTTON_NAME = "log_dialog_ok_button"; + public static final String SAVE_AS_BUTTON_NAME = "log_dialog_save_as_button"; + public static final String LOG_TEXTPANE_NAME = "log_dialog_log_textpane"; + private final LogDialog logDialog; + + /** + * Create LogDialog dialog. + * + * @param parent + * parent frame of the dialog. + */ + public LogDialogController(JFrame parent) { + logDialog = new LogDialog(parent); + } + + /** + * Utility function to show LogDialog dialog and load current session log. + * + * @param parent + * parent frame of the dialog. + */ + public static void show(JFrame parent) { + new LogDialogController(parent).show(); + } + + /** + * Load the current session log on the LogDialog and show it. + */ + public void show() { + logDialog.setName(DIALOG_NAME); + logDialog.okButton.setName(OK_BUTTON_NAME); + logDialog.saveAsButton.setName(SAVE_AS_BUTTON_NAME); + logDialog.logTextPane.setName(LOG_TEXTPANE_NAME); + logDialog.saveAsButton.addActionListener(this::saveAsButtonActionPerformed); + loadCurrentSessionLog(logDialog.logTextPane); + logDialog.setVisible(true); + } + + private void loadCurrentSessionLog(JTextPane logTextPane) { + File logLocation = new File(Log.getLogFilePath()); + new SwingWorker() { + @Override + protected String doInBackground() throws Exception { + return loadCurrentSessionLogFromFile(logLocation); + } + + protected void done() { + try { + logTextPane.setText(get()); + } catch (Exception e) { + Log.log(e); + } + OSXIntegration.setProxyIcon(logDialog.getRootPane(), logLocation); + }; + }.execute(); + } + + /** + * Load current session log from log file. + * + * @param logLocation + * log file path to retrieve log messages. + * @return Log messages as String. + */ + protected String loadCurrentSessionLogFromFile(File logLocation) { + final StringBuilder sb = new StringBuilder(); + try (Stream lines = Files.lines(logLocation.toPath())) { + lines.forEachOrdered(s -> sb.append(s).append("\n")); + } catch (Exception ignored) { + } + return sb.toString(); + } + + private void saveAsButtonActionPerformed(ActionEvent evt) { + File outFile = showChooserLogFile(); + if (outFile == null) { + return; + } + try { + try (BufferedWriter writer = Files.newBufferedWriter(outFile.toPath())) { + logDialog.logTextPane.write(writer); + } + } catch (IOException ex) { + Log.log(ex); + } + Preferences.setPreference(Preferences.CURRENT_FOLDER, outFile.getParent()); + } + + private File showChooserLogFile() { + String curDir = Preferences.getPreferenceDefault(Preferences.CURRENT_FOLDER, + System.getProperty("user.home")); + JFileChooser chooser = new JFileChooser(); + chooser.setSelectedFile(new File(curDir, Log.getLogFileName())); + if (chooser.showSaveDialog(logDialog) != JFileChooser.APPROVE_OPTION) { + return null; + } + File outFile = chooser.getSelectedFile(); + if (outFile.exists() && !FileCollisionDialog.promptToReplace(logDialog, outFile.getName())) { + return null; + } + return outFile; + } +} diff --git a/src/org/omegat/gui/main/MainWindowMenuHandler.java b/src/org/omegat/gui/main/MainWindowMenuHandler.java index 0328bf2fda..400e209760 100644 --- a/src/org/omegat/gui/main/MainWindowMenuHandler.java +++ b/src/org/omegat/gui/main/MainWindowMenuHandler.java @@ -55,7 +55,7 @@ import org.omegat.gui.dialogs.AboutDialog; import org.omegat.gui.dialogs.GoToSegmentDialog; import org.omegat.gui.dialogs.LastChangesDialog; -import org.omegat.gui.dialogs.LogDialog; +import org.omegat.gui.dialogs.LogDialogController; import org.omegat.gui.dialogs.VersionCheckDialog; import org.omegat.gui.editor.EditorSettings; import org.omegat.gui.editor.EditorUtils; @@ -887,7 +887,7 @@ public void helpLastChangesMenuItemActionPerformed() { * Show log */ public void helpLogMenuItemActionPerformed() { - new LogDialog(Core.getMainWindow().getApplicationFrame()).setVisible(true); + LogDialogController.show(Core.getMainWindow().getApplicationFrame()); } /** diff --git a/src/org/omegat/logger.properties b/src/org/omegat/logger.properties index dbcd046734..cd7ab32c1d 100644 --- a/src/org/omegat/logger.properties +++ b/src/org/omegat/logger.properties @@ -8,16 +8,24 @@ org.omegat.level = ALL java.util.logging.ConsoleHandler.level = ALL org.omegat.util.logging.OmegaTFileHandler.level = ALL -org.omegat.util.logging.OmegaTLogFormatter.mask=$mark: $level: $text $key +org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $level: $text $key #org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $threadName [$level] $key $text +#org.omegat.util.logging.OmegaTLogFormatter.mask=$mark: $level: $text $key -org.omegat.util.logging.OmegaTLogFormatter.timeFormat=HH:mm:ss,SSSS +org.omegat.util.logging.OmegaTLogFormatter.timeFormat=HH:mm:ss.SSS java.util.logging.ConsoleHandler.formatter = org.omegat.util.logging.OmegaTLogFormatter org.omegat.util.logging.OmegaTFileHandler.formatter = org.omegat.util.logging.OmegaTLogFormatter + +# maximum log file size, which triggers rotation org.omegat.util.logging.OmegaTFileHandler.size=1048576 -org.omegat.util.logging.OmegaTFileHandler.count=10 + +# retention policy: maximum 30 files +org.omegat.util.logging.OmegaTFileHandler.count=30 +# retention policy; remove older than specified duration. +# 20 days * 24 hours * 60 min * 60 sec = 1,020,000 seconds +org.omegat.util.logging.OmegaTFileHandler.retention=1020000 # precise control of log levels, please change when debug org.omegat.core.data.level = INFO diff --git a/src/org/omegat/util/Log.java b/src/org/omegat/util/Log.java index a69ea8ef0c..4ae381383a 100644 --- a/src/org/omegat/util/Log.java +++ b/src/org/omegat/util/Log.java @@ -34,7 +34,9 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.time.ZonedDateTime; import java.util.Properties; +import java.util.concurrent.ThreadLocalRandom; import java.util.logging.Formatter; import java.util.logging.Handler; import java.util.logging.Level; @@ -58,15 +60,29 @@ public final class Log { private static final ILogger LOGGER; + // Line mark is day-of-the-year and five-character random number + private static final String SESSION_ID; + private static final ZonedDateTime SESSION_START_DATETIME; + private Log() { } static { + SESSION_ID = String.format("%05d", ThreadLocalRandom.current().nextInt(100000)); + SESSION_START_DATETIME = ZonedDateTime.now(); LOGGER = LoggerFactory.getLogger(ILogger.ROOT_LOGGER_NAME, OStrings.getResourceBundle()); init(); } + public static String getSessionId() { + return SESSION_ID; + } + + public static ZonedDateTime getSessionStartDateTime() { + return SESSION_START_DATETIME; + } + private static void init() { boolean loaded = false; diff --git a/src/org/omegat/util/logging/OmegaTFileHandler.java b/src/org/omegat/util/logging/OmegaTFileHandler.java index 4977eb52c6..f145dddb8b 100644 --- a/src/org/omegat/util/logging/OmegaTFileHandler.java +++ b/src/org/omegat/util/logging/OmegaTFileHandler.java @@ -5,6 +5,7 @@ Copyright (C) 2008 Alex Buloichik 2013 Didier Briel + 2024 Hiroshi Miura Home page: https://www.omegat.org/ Support center: https://omegat.org/support @@ -27,20 +28,22 @@ package org.omegat.util.logging; import java.io.File; -import java.io.FileFilter; import java.io.FileOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributes; +import java.time.format.DateTimeFormatter; import java.util.Arrays; -import java.util.Comparator; -import java.util.Date; import java.util.logging.ErrorManager; import java.util.logging.Level; import java.util.logging.LogManager; import java.util.logging.LogRecord; import java.util.logging.StreamHandler; +import org.omegat.util.Log; import org.omegat.util.OStrings; import org.omegat.util.StaticUtils; @@ -61,10 +64,12 @@ */ public class OmegaTFileHandler extends StreamHandler { private String logFileName; + private File logFile; private File lockFile; private FileOutputStream lockStream; private final long maxSize; private final int count; + private final long retention; public OmegaTFileHandler() throws IOException { LogManager manager = LogManager.getLogManager(); @@ -86,10 +91,17 @@ public OmegaTFileHandler() throws IOException { if (countStr != null) { count = Integer.parseInt(countStr); } else { - count = 10; + count = 30; } - openFiles(new File(StaticUtils.getConfigDir(), "logs")); + String retentionStr = manager.getProperty(cname + ".retention"); + if (retentionStr != null) { + retention = Integer.parseInt(retentionStr) * 1000L; + } else { + retention = 20 * 24 * 60 * 60 * 1000L; + } + + openFiles(getLogDirectory()); } /** @@ -99,16 +111,27 @@ public String getLogFileName() { return logFileName + ".log"; } + private File getLogDirectory() { + return new File(StaticUtils.getConfigDir(), "logs"); + } + /** * Open log file and lock. */ @SuppressWarnings("resource") private void openFiles(final File dir) throws IOException { - dir.mkdirs(); + boolean ignored = dir.mkdirs(); for (int instanceIndex = 0; instanceIndex < 100; instanceIndex++) { - String fileName = OStrings.getApplicationName() + String fileName = String.format("%s_%s_%s%s", OStrings.getApplicationName(), + DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm").format(Log.getSessionStartDateTime()), + Log.getSessionId(), // Instance index - + (instanceIndex > 0 ? ("-" + instanceIndex) : ""); + instanceIndex > 0 ? ("-" + instanceIndex) : ""); + + logFile = new File(dir, fileName + ".log"); + if (logFile.exists()) { + continue; + } lockFile = new File(dir, fileName + ".log.lck"); logFileName = fileName; @@ -116,9 +139,9 @@ private void openFiles(final File dir) throws IOException { // try to create lock file lockStream = new FileOutputStream(lockFile); if (lockStream.getChannel().tryLock() != null) { - rotate(dir, fileName); + cleanOldLogFiles(dir); setEncoding(StandardCharsets.UTF_8.name()); - setOutputStream(new FileOutputStream(new File(dir, fileName + ".log"), true)); + setOutputStream(new FileOutputStream(logFile, true)); break; } } @@ -131,48 +154,60 @@ public synchronized void close() throws SecurityException { super.close(); try { lockStream.close(); - lockFile.delete(); + boolean ignored = lockFile.delete(); } catch (Exception ex) { // shouldn't happen - ex.printStackTrace(); + Log.log(ex); } } - /** - * Rotate log files if need. - */ - private void rotate(final File dir, final String fileName) { - File logFile = new File(dir, fileName + ".log"); - if (!logFile.exists() || logFile.length() < maxSize) { - // do not need to rotate - return; + @Override + public synchronized void publish(LogRecord record) { + if (isLoggable(record)) { + super.publish(record); + flush(); } - String suffix = new SimpleDateFormat("yyyyMMdd.HHmm").format(new Date()); - File destFile = new File(dir, fileName + '.' + suffix + ".log"); - logFile.renameTo(destFile); - File[] oldLogs = dir.listFiles(new FileFilter() { - public boolean accept(File pathname) { - return pathname.getName().startsWith(fileName + '.') && pathname.getName().endsWith(".log"); - } - }); - if (oldLogs != null) { - Arrays.sort(oldLogs, new Comparator() { - public int compare(File o1, File o2) { - return o2.getName().compareToIgnoreCase(o1.getName()); - } - }); - for (int i = count; i < oldLogs.length; i++) { - oldLogs[i].delete(); + if (logFile.length() > maxSize) { + try { + close(); + openFiles(getLogDirectory()); + } catch (IOException e) { + Log.log(e); } } } - @Override - public synchronized void publish(LogRecord record) { - if (isLoggable(record)) { - super.publish(record); - flush(); + private void cleanOldLogFiles(File dir) { + if (!dir.exists() || !dir.isDirectory()) { + return; + } + + File[] files = dir.listFiles((d, name) -> name.startsWith(OStrings.getApplicationName()) + && name.endsWith(".log")); + if (files == null) { + return; + } + + long cutoffTime = System.currentTimeMillis() - retention; + + Arrays.sort(files, (o1, o2) -> o2.getName().compareToIgnoreCase(o1.getName())); + + for (int i = count; i < files.length; i++) { + final File file = files[i]; + Path filePath = Paths.get(file.getAbsolutePath()); + try { + if (retention <= 0L) { + Files.delete(filePath); + } else { + BasicFileAttributes attrs = Files.readAttributes(filePath, BasicFileAttributes.class); + if (attrs.creationTime().toMillis() < cutoffTime) { + Files.delete(filePath); + } + } + } catch (IOException e) { + Log.log("Failed to delete old log file: " + file.getAbsolutePath()); + } } } } diff --git a/src/org/omegat/util/logging/OmegaTLogFormatter.java b/src/org/omegat/util/logging/OmegaTLogFormatter.java index 222e5573ac..90931479f7 100644 --- a/src/org/omegat/util/logging/OmegaTLogFormatter.java +++ b/src/org/omegat/util/logging/OmegaTLogFormatter.java @@ -30,12 +30,12 @@ import java.io.StringWriter; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.concurrent.ThreadLocalRandom; import java.util.logging.Formatter; import java.util.logging.Level; import java.util.logging.LogManager; import java.util.logging.LogRecord; +import org.omegat.util.Log; import org.omegat.util.OStrings; import org.omegat.util.StringUtil; @@ -47,17 +47,17 @@ */ public class OmegaTLogFormatter extends Formatter { - // Line mark is a five-character random number - protected static final String LINE_MARK = String.format("%05d", ThreadLocalRandom.current().nextInt(100000)); + // Line mark is five-character random number + protected final String LINE_MARK; private String logMask; - private boolean isMaskContainsMark; - private boolean isMaskContainsThreadName; - private boolean isMaskContainsLevel; - private boolean isMaskContainsText; - private boolean isMaskContainsKey; - private boolean isMaskContainsLoggerName; - private boolean isMaskContainsTime; + private final boolean isMaskContainsMark; + private final boolean isMaskContainsThreadName; + private final boolean isMaskContainsLevel; + private final boolean isMaskContainsText; + private final boolean isMaskContainsKey; + private final boolean isMaskContainsLoggerName; + private final boolean isMaskContainsTime; private String defaultTimeFormat = "HH:mm:ss"; @@ -65,7 +65,7 @@ public class OmegaTLogFormatter extends Formatter { * We have to use ThreadLocal for formatting time because DateFormat is not * thread safe. */ - private ThreadLocal timeFormatter = new ThreadLocal() { + private final ThreadLocal timeFormatter = new ThreadLocal() { @Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(defaultTimeFormat); @@ -79,6 +79,8 @@ public OmegaTLogFormatter() { LogManager manager = LogManager.getLogManager(); String cname = getClass().getName(); + LINE_MARK = Log.getSessionId(); + logMask = manager.getProperty(cname + ".mask"); if (logMask == null) { logMask = "$mark: $level: $text $key"; diff --git a/test-acceptance/src/org/omegat/gui/main/TestMainWindowMenuHandler.java b/test-acceptance/src/org/omegat/gui/main/TestMainWindowMenuHandler.java index 2cbeb9267e..4a8d7a22a2 100644 --- a/test-acceptance/src/org/omegat/gui/main/TestMainWindowMenuHandler.java +++ b/test-acceptance/src/org/omegat/gui/main/TestMainWindowMenuHandler.java @@ -35,7 +35,7 @@ import org.omegat.core.data.SourceTextEntry; import org.omegat.core.data.TMXEntry; import org.omegat.gui.dialogs.AboutDialog; -import org.omegat.gui.dialogs.LogDialog; +import org.omegat.gui.dialogs.LogDialogController; import org.omegat.gui.editor.EditorUtils; import org.omegat.gui.editor.SegmentExportImport; import org.omegat.gui.exttrans.MachineTranslationInfo; @@ -379,7 +379,7 @@ public void optionsAccessConfigDirMenuItemActionPerformed() { * Show log */ public void helpLogMenuItemActionPerformed() { - new LogDialog(mainWindow.getApplicationFrame()).setVisible(true); + LogDialogController.show(Core.getMainWindow().getApplicationFrame()); } public void helpAboutMenuItemActionPerformed() { From 08ed32012cc50ef13965b4f1b89b44b8f87e948b Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 28 Jul 2024 10:08:14 +0900 Subject: [PATCH 34/85] refactor: PluginUtils to handle theme plugins (#1087) * refactor: PluginUtils to handle theme plugins This defines URLClassLoader class loader named THEME_CLASSLOADER that can be add URLs dynamically. It loads theme modules and plugins. Main class set the ClassLoader as UI class loader and Java Swing subsystem can find LaF classes. - Define THEME_CLASSLOADER in PluginUtils - THEME_CLASSLOADER is MainClassLoader object - Load theme plugins with THEME_CLASSLOADER Signed-off-by: Hiroshi Miura * fix: revert unintended removal Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- src/org/omegat/Main.java | 10 +---- .../omegat/filters2/master/PluginUtils.java | 42 ++++++++++++------- .../src/org/omegat/TestMainInitializer.java | 7 ++-- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/org/omegat/Main.java b/src/org/omegat/Main.java index 31886cdbaf..43a114413c 100644 --- a/src/org/omegat/Main.java +++ b/src/org/omegat/Main.java @@ -332,15 +332,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..ae235dab45 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. */ @@ -155,6 +161,12 @@ 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 THEME_CLASSLOADER; + + static { + THEME_CLASSLOADER = new MainClassLoader(PluginUtils.class.getClassLoader()); + } + /** Private constructor to disallow creation */ private PluginUtils() { } @@ -185,26 +197,28 @@ 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); + THEME_CLASSLOADER.addJarToClasspath(url); + loadFromManifest(m, THEME_CLASSLOADER, mu); } } + } else { + loadFromManifest(m, pluginsClassLoader, mu); } } catch (ClassNotFoundException e) { Log.log(e); @@ -298,8 +312,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 +398,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 +470,8 @@ public static List> getGlossaryClasses() { return GLOSSARY_CLASSES; } - public static List getThemePluginJars() { - return THEME_PLUGIN_JARS; + public static ClassLoader getThemeClassLoader() { + return THEME_CLASSLOADER; } private static final List> FILTER_CLASSES = new ArrayList<>(); @@ -474,8 +488,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/test-acceptance/src/org/omegat/TestMainInitializer.java b/test-acceptance/src/org/omegat/TestMainInitializer.java index d70ab6746e..7d7ff07fab 100644 --- a/test-acceptance/src/org/omegat/TestMainInitializer.java +++ b/test-acceptance/src/org/omegat/TestMainInitializer.java @@ -2,16 +2,15 @@ import javax.swing.UIManager; +import org.omegat.filters2.master.PluginUtils; + public final class TestMainInitializer { private TestMainInitializer() { } public static void initClassloader() { - ClassLoader cl = ClassLoader.getSystemClassLoader(); - MainClassLoader mainClassLoader = (cl instanceof MainClassLoader) ? (MainClassLoader) cl - : new MainClassLoader(cl); - UIManager.put("ClassLoader", mainClassLoader); + UIManager.put("ClassLoader", PluginUtils.getThemeClassLoader()); } } From 7506f6cab818723412a70c8d2abd3902b65ca9f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 28 Jul 2024 10:08:50 +0900 Subject: [PATCH 35/85] chore(deps): bump com.fifesoft:rsyntaxtextarea from 3.4.1 to 3.5.0 (#1084) Bumps [com.fifesoft:rsyntaxtextarea](https://github.com/bobbylight/rsyntaxtextarea) from 3.4.1 to 3.5.0. - [Release notes](https://github.com/bobbylight/rsyntaxtextarea/releases) - [Commits](https://github.com/bobbylight/rsyntaxtextarea/compare/3.4.1...3.5.0) --- updated-dependencies: - dependency-name: com.fifesoft:rsyntaxtextarea dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 92a6e276f7..17dc902b8e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -102,7 +102,7 @@ bc-pg = {group = "org.bouncycastle", name = "bcpg-jdk18on", version.ref = "bc"} bc-pkix = {group = "org.bouncycastle", name = "bcpkix-jdk18on", version.ref = "bc"} svnkit = {group = "org.tmatesoft.svnkit", name = "svnkit", version.ref = "svnkit"} nashorn-core = {group = "org.openjdk.nashorn", name = "nashorn-core", version.ref = "nashorn"} -fifesoft-rsyntaxtextarea = {group = "com.fifesoft", name = "rsyntaxtextarea", version = "3.4.1"} +fifesoft-rsyntaxtextarea = {group = "com.fifesoft", name = "rsyntaxtextarea", version = "3.5.0"} fifesoft-rstaui = {group = "com.fifesoft", name = "rstaui", version = "3.3.1"} fifesoft-languagesupport = {group = "com.fifesoft", name = "languagesupport", version = "3.3.0"} fifesoft-autocomplete = {group = "com.fifesoft", name = "autocomplete", version = "3.3.1"} From 8b559e02797d158dcc6859014926c91fa9f6706b Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 28 Jul 2024 10:10:07 +0900 Subject: [PATCH 36/85] chore(ci): upload with recursively (#1093) - Use "scp -r -s" for uploading manual contents Signed-off-by: Hiroshi Miura --- ci/azure-pipelines/publish_manual_snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/azure-pipelines/publish_manual_snapshot.yml b/ci/azure-pipelines/publish_manual_snapshot.yml index 5babe4b0d3..e357035016 100644 --- a/ci/azure-pipelines/publish_manual_snapshot.yml +++ b/ci/azure-pipelines/publish_manual_snapshot.yml @@ -13,4 +13,4 @@ steps: dest=$(SOURCEFORGE_FILE_USER)@frs.sourceforge.net destdir=/home/project-web/omegat/htdocs/manual-snapshot/ echo "mkdir $destdir" | SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e sftp -oStrictHostKeyChecking=no $dest || true - SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -s -oStrictHostKeyChecking=no $srcdir/* $dest:$destdir + SSHPASS=$(SOURCEFORGE_FILE_PASS) sshpass -e scp -r -s -oStrictHostKeyChecking=no $srcdir/* $dest:$destdir From bb7b67839942ae3122b5f2ccc5e6b571ebc96b55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:34:31 +0900 Subject: [PATCH 37/85] chore(deps): bump com.fifesoft:rsyntaxtextarea from 3.5.0 to 3.5.1 (#1095) Bumps [com.fifesoft:rsyntaxtextarea](https://github.com/bobbylight/rsyntaxtextarea) from 3.5.0 to 3.5.1. - [Release notes](https://github.com/bobbylight/rsyntaxtextarea/releases) - [Commits](https://github.com/bobbylight/rsyntaxtextarea/compare/3.5.0...3.5.1) --- updated-dependencies: - dependency-name: com.fifesoft:rsyntaxtextarea dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 17dc902b8e..b32d568d15 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -102,7 +102,7 @@ bc-pg = {group = "org.bouncycastle", name = "bcpg-jdk18on", version.ref = "bc"} bc-pkix = {group = "org.bouncycastle", name = "bcpkix-jdk18on", version.ref = "bc"} svnkit = {group = "org.tmatesoft.svnkit", name = "svnkit", version.ref = "svnkit"} nashorn-core = {group = "org.openjdk.nashorn", name = "nashorn-core", version.ref = "nashorn"} -fifesoft-rsyntaxtextarea = {group = "com.fifesoft", name = "rsyntaxtextarea", version = "3.5.0"} +fifesoft-rsyntaxtextarea = {group = "com.fifesoft", name = "rsyntaxtextarea", version = "3.5.1"} fifesoft-rstaui = {group = "com.fifesoft", name = "rstaui", version = "3.3.1"} fifesoft-languagesupport = {group = "com.fifesoft", name = "languagesupport", version = "3.3.0"} fifesoft-autocomplete = {group = "com.fifesoft", name = "autocomplete", version = "3.3.1"} From bd815b08372a2302cc7d01e6c7eb67e49ba78ae9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 13:09:53 +0900 Subject: [PATCH 38/85] chore(deps): bump org.wiremock:wiremock from 3.8.0 to 3.9.1 (#1092) Bumps [org.wiremock:wiremock](https://github.com/wiremock/wiremock) from 3.8.0 to 3.9.1. - [Release notes](https://github.com/wiremock/wiremock/releases) - [Commits](https://github.com/wiremock/wiremock/compare/3.8.0...3.9.1) --- updated-dependencies: - dependency-name: org.wiremock:wiremock dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b32d568d15..ae71e1c121 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -24,7 +24,7 @@ jackson = "2.16.1" bc = "1.78.1" nashorn = "15.4" caffeine = "3.1.8" -wiremock = "3.8.0" +wiremock = "3.9.1" vldocking = "3.0.5-2" xmlunit = "2.10.0" assertj = "3.26.0" From f10b50f5891b786c3c6e29d21cdd30adde624f78 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 10 Aug 2024 21:20:25 +0900 Subject: [PATCH 39/85] L10n: update Japanese translations (#1102) * docs: update Japanese manual translations Signed-off-by: Hiroshi Miura * docs: update Japanese UI translations Signed-off-by: Hiroshi Miura * docs: update modules UI JA translation Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- doc_src/ja/HowTo_Install.xml | 8 ++--- doc_src/ja/Menus_Edit.xml | 4 +-- doc_src/ja/Menus_Options.xml | 2 +- doc_src/ja/Menus_Project.xml | 6 ++-- doc_src/ja/OmegaT_EditorsPanes.xml | 6 ++-- doc_src/ja/OmegaT_Preferences.xml | 28 +++++++++++++--- .../hunspell/Bundle_ja.properties | 2 +- src/org/omegat/Bundle_ja.properties | 33 ++++++++++++------- 8 files changed, 59 insertions(+), 30 deletions(-) diff --git a/doc_src/ja/HowTo_Install.xml b/doc_src/ja/HowTo_Install.xml index f72a5eb795..a4c0c2ceb8 100644 --- a/doc_src/ja/HowTo_Install.xml +++ b/doc_src/ja/HowTo_Install.xml @@ -17,9 +17,9 @@ - 開発版:OmegaT Nightly + 開発版:OmegaT Weekly - この版は、新しいコードがOmegaTに追加されるたびに自動的に生成されます。テスト目的で使用されます。 + これは、現在開発が進められている OmegaT のバージョンです。毎週自動的に生成され、テスト用のベータ版として機能します。 @@ -31,9 +31,9 @@ OmeaTパッケージは、Javaにバンドルされているバージョンとバンドルされていないバージョンの両方で利用できます。Javaを含まないパッケージは、システム全体にインストールされたJava 11 Runtime Environmentに依存します。 - OmegaT 5.8.0以降では、すべてのプラットフォームでJava 11 Runtime Environmentもサポートしています。 + OmegaT 6.1.0 以降は、どのプラットフォームでも Java 17 ランタイム環境と併用して実行できます。 - OmegaTチームはEclipse FoundationのAdoptium Projectが提供するJavaランタイムEclipse Temurinを推奨していますが、Java 8互換のランタイム環境であればどれでも動作するはずです。 The Eclipse Temurin™ projectを参照。 + ライセンス上の考慮事項から、OmegaT チームは Eclipse Foundation の Adoptium Project が提供する Eclipse Temurin Java ランタイムを推奨していますが、Java 11 と互換性のあるランタイム環境であれば、どれでも動作するはずです。 The Eclipse Temurin™ projectを参照。 IBMはでLinux PowerPC 用のJREを提供しています。 diff --git a/doc_src/ja/Menus_Edit.xml b/doc_src/ja/Menus_Edit.xml index 4cda27f5fe..6bf79ba681 100644 --- a/doc_src/ja/Menus_Edit.xml +++ b/doc_src/ja/Menus_Edit.xml @@ -246,11 +246,11 @@ - 前の参考訳文を選択 A + 前の参考訳文を選択 C(AmacOSの場合) - 次の参考訳文を選択 A + 次の参考訳文を選択 C(AmacOSの場合) diff --git a/doc_src/ja/Menus_Options.xml b/doc_src/ja/Menus_Options.xml index d30b2f6b44..72d4147919 100644 --- a/doc_src/ja/Menus_Options.xml +++ b/doc_src/ja/Menus_Options.xml @@ -26,7 +26,7 @@ - 機械翻訳エンジンを有効または無効にします。 + 適切に構成された機械翻訳エンジンを有効または無効にします。 複数の変換エンジンを選択した場合は、CMを使用して変換エンジンの翻訳結果を切り替え、最後に選択した訳文候補を挿入します。詳細の環境設定を参照してください。 diff --git a/doc_src/ja/Menus_Project.xml b/doc_src/ja/Menus_Project.xml index 0e06b1ab59..1e36d51c2a 100644 --- a/doc_src/ja/Menus_Project.xml +++ b/doc_src/ja/Menus_Project.xml @@ -215,7 +215,7 @@ 現在の原文ファイルはフォルダーにあります。 - 元のアプリケーションでドキュメントを再度開きます。 + アプリケーションでドキュメントを再度開きます。メニュー項目を選択しながらAltキーを押すと、ファイルを開く代わりに、FinderやファイルエクスプローラーなどのOS標準のファイルマネージャーでファイルを含むフォルダーが開きます。 @@ -224,7 +224,7 @@ 現在の訳文ファイルはフォルダーにあります。 - アプリケーションでドキュメントを再度開きます。 + アプリケーションでドキュメントを再度開きます。メニュー項目を選択しながらAltキーを押すと、ファイルを開く代わりに、FinderやファイルエクスプローラーなどのOS標準のファイルマネージャーでファイルを含むフォルダーが開きます。 @@ -233,7 +233,7 @@ 書き込み可能な用語集はフォルダーにあります。 - アプリケーションでドキュメントを再度開きます。 + アプリケーションでドキュメントを再度開きます。メニュー項目を選択しながらAltキーを押すと、ファイルを開く代わりに、FinderやファイルエクスプローラーなどのOS標準のファイルマネージャーでファイルを含むフォルダーが開きます。 diff --git a/doc_src/ja/OmegaT_EditorsPanes.xml b/doc_src/ja/OmegaT_EditorsPanes.xml index 83276a24df..05778f8a78 100644 --- a/doc_src/ja/OmegaT_EditorsPanes.xml +++ b/doc_src/ja/OmegaT_EditorsPanes.xml @@ -555,7 +555,7 @@ 参考訳文は、プロジェクトの翻訳メモリ時にリアルタイムで作成された内部プロジェクト翻訳と、以前のプロジェクトからインポートした外部メモリまたはサードパーティから受け取った外部メモリの全てから取得されます。詳細については、 を参照してください。 - 次の分節に移動すると、最初の参考訳文(最も一致率の高いもの)が自動的に選択されます。別の参考訳文を選択するには、C2、3、4、または5を押すか、を使用します。 + 次の分節に移動すると、最初の参考訳文(最も一致率の高いもの)が自動的に選択されます。特定の参考訳文を選択するには、C2、3、4、または 5 を押すか、C↑ または ↓ (macOS では A↑ または ↓) を使用して使用する候補を切り替えることができます。または、 を使用して別の参考訳文を選択することもできます。 空の分節と最初の2つのマッチ @@ -683,7 +683,7 @@ Folder = Dossier
<guilabel>機械翻訳</guilabel> - このウィンドウを開くと、有効になっている各機械翻訳エンジンによって生成された分節の訳文候補が表示されます。複数のエンジンからの訳文の提案が利用可能な場合 + 機械翻訳エンジンを有効にして構成している場合、このウィンドウには有効にしたエンジンが生成した分節の訳文が表示されます。複数の翻訳エンジンからの提案が利用可能な場合、 @@ -880,4 +880,4 @@ Folder = Dossier
- + \ No newline at end of file diff --git a/doc_src/ja/OmegaT_Preferences.xml b/doc_src/ja/OmegaT_Preferences.xml index cf33ae1ded..52fe7a44e4 100644 --- a/doc_src/ja/OmegaT_Preferences.xml +++ b/doc_src/ja/OmegaT_Preferences.xml @@ -60,9 +60,9 @@ - - このオプションを無効にすると、 を押した場合に現在の分節の機械翻訳が取得されます。再度、キーを押すと、提案された機械翻訳結果が挿入されます。 - + + このオプションを有効にすると、有効にして構成したプロバイダーから機械翻訳が自動的にフェッチされます。このオプションを無効のままにすると、現在の分節で を使用した場合にのみ機械翻訳が取得されます。その後、その組み合わせをもう一度押して、訳文を挿入する必要があります。 + @@ -214,7 +214,21 @@ 用語集の用語に複数の定義があったときに、同じ行に一度に表示します。 - + + + + + 一部の用語集項目がソース用語テキストで類似しており、そのうちの1つに別の用語テキストが含まれている場合は、ソーステキストの長さでソートします。 + + + + + + + 用語集の項目に複数の定義がある場合は、定義テキストの長さで並べ替えます。 + + +
@@ -1194,7 +1208,11 @@ ${filePath}> プラグインは、構成フォルダーにインストールされますが、プログラムフォルダーの下のフォルダーにインストールすることもできます。 - その他のプラグインは、OmegaT開発サイトにあります。 + その他のプラグインは、OmegaT wiki サイトにあります。 + ディスクからプラグインをインストール」ボタンを使用して、プラグインをインストールまたはアップグレードします。プラグインファイルは、拡張子が.jar JARファイルです。OmegaT は、JAR プラグインファイルを含む zip アーカイブも受け付けます。サードパーティのプラグインは通常、プラグインファイル自体、READMEファイル、LICENSEファイルを含むzipアーカイブとして配布されます。 + + プラグインインストーラは、JAR プラグインを含むアーカイブのみを受け入れます。.zip拡張子で名前が変更されたプラグインファイルは認識されません。 +
diff --git a/spellchecker/hunspell/src/main/resources/org/omegat/spellchecker/hunspell/Bundle_ja.properties b/spellchecker/hunspell/src/main/resources/org/omegat/spellchecker/hunspell/Bundle_ja.properties index c7b34b3cad..ddcb5e5663 100644 --- a/spellchecker/hunspell/src/main/resources/org/omegat/spellchecker/hunspell/Bundle_ja.properties +++ b/spellchecker/hunspell/src/main/resources/org/omegat/spellchecker/hunspell/Bundle_ja.properties @@ -22,5 +22,5 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -SPELLCHECKER_HUNSPELL_INITIALIZED=\u8A00\u8A9E '{0}' \u7528\u306E LanguageTool Hunspell \u7DB4\u3044\u78BA\u8A8D\u7528\u8F9E\u66F8\u3092\u521D\u671F\u5316 {1} +SPELLCHECKER_HUNSPELL_INITIALIZED=\u8A00\u8A9E '{0}' \u8F9E\u66F8\u306E Hunspell \u30B9\u30DA\u30EB\u30C1\u30A7\u30C3\u30AB\u30FC\u3092\u521D\u671F\u5316 {1} SPELLCHECKER_HUNSPELL_EXCEPTION=hunspell\u306E\u8AAD\u307F\u8FBC\u307F\u30A8\u30E9\u30FC:{0} \ No newline at end of file diff --git a/src/org/omegat/Bundle_ja.properties b/src/org/omegat/Bundle_ja.properties index 81eb384b60..3a9eea8712 100644 --- a/src/org/omegat/Bundle_ja.properties +++ b/src/org/omegat/Bundle_ja.properties @@ -17,7 +17,7 @@ # 2015 Yu Tang, Aaron Madlon-Kay, Didier Briel, Hiroshi Miura # 2016 Alex Buloichik, Aaron Madlon-Kay, Didier Briel, Briac Pilpre # 2017 Didier Briel -# 2020-2022 Hiroshi Miura +# 2020-2024 Hiroshi Miura # Home page: https://www.omegat.org/ # Support centre: https://omegat.org/support # @@ -312,6 +312,7 @@ MW_VIEW_MENU_MARK_WHITESPACE=\u7A7A\u767D\u6587\u5B57\u3092\u8868\u793A(&H) MW_VIEW_MENU_MARK_BIDI=&Bidi\u5236\u5FA1\u6587\u5B57\u3092\u8868\u793A MW_VIEW_MENU_MARK_AUTOPOPULATED=\u81EA\u52D5\u751F\u6210\u5206\u7BC0\u3092\u8272\u3065\u3051(&J) +MW_VIEW_MENU_MARK_ALT_TRANSLATIONS=\u4EE3\u66FF\u7FFB\u8A33\u306B\u3088\u308B\u30BB\u30B0\u30E1\u30F3\u30C8\u306E\u30CF\u30A4\u30E9\u30A4\u30C8 MW_VIEW_GLOSSARY_MARK=\u7528\u8A9E\u96C6\u306E\u4E00\u81F4\u3092\u30DE\u30FC\u30AF(&G) LT_OPTIONS_MENU_ENABLED=\u8A00\u8A9E\u30C1\u30A7\u30C3\u30AB\u30FC\u306E\u6307\u6458(&C) @@ -1102,6 +1103,8 @@ FILTERMASTER_ERROR_LOADING_FILTER=\u30D5\u30A3\u30EB\u30BF\u30FC {0} \u3092 {1} FILTERMASTER_ERROR_SRC_TRG_SAME_FILE=\u8A33\u6587\u30D5\u30A1\u30A4\u30EB\u30D1\u30B9\u306F\u3001\u539F\u6587\u30D5\u30A1\u30A4\u30EB\u30D1\u30B9\u3068\u540C\u3058\u306B\u306F\u3067\u304D\u307E\u305B\u3093\u3002{0} +FILTERMASTER_ERROR_UNKNOWN_ENCODING=\u7FFB\u8A33\u30D5\u30A1\u30A4\u30EB\u3078\u306E\u51FA\u529B\u6642\u306B\u3001\u9593\u9055\u3063\u305F\u6587\u5B57\u30B3\u30FC\u30C9\u307E\u305F\u306F\u6307\u5B9A\u3057\u305F\u30A8\u30F3\u30B3\u30FC\u30C9\u306E\u9593\u9055\u3063\u305F\u6587\u5B57\u3092\u691C\u51FA\u3057\u307E\u3057\u305F\u3002\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u69CB\u6210\u3068\u7FFB\u8A33\u6587\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 + # Filters.java FILTERS_FILE_FORMAT=\u30D5\u30A1\u30A4\u30EB\u5F62\u5F0F @@ -1709,6 +1712,7 @@ GUI_GLOSSARYWINDOW_insertselection=\u9078\u629E\u7BC4\u56F2\u3092\u633F\u5165 GUI_GLOSSARYWINDOW_SETTINGS_NOTIFICATIONS=\u5206\u7BC0\u306B\u7528\u8A9E\u304C\u4E00\u81F4\u3057\u305F\u5834\u5408\u306B\u901A\u77E5\u3059\u308B GUI_GLOSSARYWINDOW_SETTINGS_OPEN_FILE=\u66F8\u304D\u8FBC\u307F\u53EF\u80FD\u306A\u7528\u8A9E\u96C6\u30D5\u30A1\u30A4\u30EB\u3092\u958B\u304F +GUI_GLOSSARYWINDOW_SETTINGS_SORT_BY_SRC_LENGTH=\u7528\u8A9E\u306E\u539F\u6587\u306E\u9577\u3055\u9806\u306B\u4E26\u3079\u66FF\u3048\u308B GUI_GLOSSARYWINDOW_SETTINGS_SORT_BY_LENGTH=Sort by Target Term Length GUI_MATCHWINDOW_SUBWINDOWTITLE_Dictionary=\u8F9E\u66F8 @@ -1779,13 +1783,10 @@ HCU_RESPONSE_ERROR=\u4E88\u671F\u3057\u306A\u3044 HTTP \u30EC\u30B9\u30DD\u30F3\ # Log LOG_LEVEL_SEVERE=\u30A8\u30E9\u30FC - LOG_LEVEL_WARNING=\u6CE8\u610F - LOG_LEVEL_INFO=\u60C5\u5831 - LOG_STARTUP_INFO=Java\uFF1A{0} \u30D0\u30FC\u30B8\u30E7\u30F3 {1} \u304C {2} \u304B\u3089\u5B9F\u884C\u3055\u308C\u307E\u3057\u305F - +LOG_RESTART_FAILED_NOT_FOUND=\u30E9\u30F3\u30C1\u30E3\u30FC\u307E\u305F\u306FJava\u5B9F\u884C\u53EF\u80FD\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u3089\u306A\u3044\u305F\u3081\u3001\u518D\u8D77\u52D5\u3092\u4E2D\u6B62\u3057\u307E\u3059\u3002 LOG_MENU_CLICK=\u30E1\u30CB\u30E5\u30FC\u9805\u76EE {0} \u3092\u30AF\u30EA\u30C3\u30AF LOG_INFO_EVENT_PROJECT_CHANGE=\u30A4\u30D9\u30F3\u30C8\uFF1A\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u5909\u66F4 - {0} @@ -1946,7 +1947,7 @@ GUI_DICTIONARY_INSTALLER_AVAILABLE=\u5229\u7528\u53EF\u80FD\u306A\u8A00\u8A9E: # org.omegat.gui.dialogs.PluginInstallerDialog GUI_PLUGIN_INSTALLER_TITLE=\u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB -GUI_PLUGIN_OPEN=\u30D7\u30E9\u30B0\u30A4\u30F3\u30D5\u30A1\u30A4\u30EB(*.jar,*.zip)\u306E\u9078\u629E +GUI_PLUGIN_OPEN=\u30D7\u30E9\u30B0\u30A4\u30F3 \u30D5\u30A1\u30A4\u30EB (*.jar) \u307E\u305F\u306F \u30D7\u30E9\u30B0\u30A4\u30F3 jar \u30D5\u30A1\u30A4\u30EB\u304C\u542B\u307E\u308C\u3066\u3044\u308BZip \u30A2\u30FC\u30AB\u30A4\u30D6 (*.zip) \u3092\u9078\u629E\u3057\u307E\u3059\u3002 GUI_PLUGIN_INSTALLER_INSTALL=\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB # matches text area popup menu @@ -2165,7 +2166,8 @@ TEAM_UPDATE_REPO_ERROR=\u30EA\u30DD\u30B8\u30C8\u30EA\u306E\u66F4\u65B0\u306B\u5 # Save options SAVE_DIALOG_TITLE=\u4FDD\u5B58\u3068\u8A33\u6587\u30D5\u30A1\u30A4\u30EB\u751F\u6210\u306E\u8A2D\u5B9A PREFS_TITLE_SAVING_AND_OUTPUT=\u4FDD\u5B58\u3068\u8A33\u6587\u30D5\u30A1\u30A4\u30EB\u751F\u6210 -SAVE_DIALOG_DESCRIPTION=\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4FDD\u5B58\u9593\u9694 +SAVE_DIALOG_INTERVAL_LABEL=\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4FDD\u5B58\u9593\u9694 +SAVE_DIALOG_DESCRIPTION=\u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u3001\u30C1\u30FC\u30E0\u30C7\u30FC\u30BF\u306E\u540C\u671F\u306B\u3082\u9069\u7528\u3055\u308C\u308B\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u30C7\u30FC\u30BF\u306E\u4FDD\u5B58\u9593\u9694\u3092\u8A2D\u5B9A\u3057\u307E\u3059\u3002 SAVE_DIALOG_MINUTES=\u5206\uFF1A SAVE_DIALOG_SECONDS=\u79D2\uFF1A SAVE_DIALOG_STATS_OUTPUT_FORMAT=\u7D71\u8A08\u51FA\u529B\u5F62\u5F0F @@ -2355,6 +2357,7 @@ COLOR_ALIGNER_NEEDSREVIEW=\u6574\u5408\u300C\u8981\u30EC\u30D3\u30E5\u30FC\u300D COLOR_ALIGNER_HIGHLIGHT=\u6574\u5408\u30CF\u30A4\u30E9\u30A4\u30C8 COLOR_ALIGNER_TABLE_ROW_HIGHLIGHT=\u6574\u5408\u30C6\u30FC\u30D6\u30EB\u884C\u306E\u5F37\u8ABF\u8868\u793A COLOR_MACHINETRANSLATE_SELECTED_HIGHLIGHT=\u6A5F\u68B0\u7FFB\u8A33\u30CF\u30A4\u30E9\u30A4\u30C8 +COLOR_MARK_ALT_TRANSLATION=\u4EE3\u66FF\u7FFB\u8A33\u306E\u30CF\u30A4\u30E9\u30A4\u30C8 GUI_COLORS_COLOR=\u9805\u76EE\uFF1A GUI_COLORS_RESET_COLOR=\u9078\u629E\u4E2D\u306E\u914D\u8272\u3092\u30EA\u30BB\u30C3\u30C8(&R) PREFS_TITLE_COLORS=\u914D\u8272 @@ -2559,6 +2562,8 @@ PREFS_GLOSSARY_STEMMING=\u30B9\u30C6\u30DF\u30F3\u30B0\uFF08\u8A9E\u5E79\u51E6\u PREFS_GLOSSARY_REPLACE_ON_INSERT=\u539F\u6587\u633F\u5165\u6642\u306B\u7528\u8A9E\u96C6\u304B\u3089\u7F6E\u63DB PREFS_GLOSSARY_REQUIRE_SIMILAR_CASE=\u5927/\u5C0F\u6587\u5B57\u304C\u7570\u306A\u308B(\u4F8B:FOO\u5BFEfoo)\u691C\u51FA\u7D50\u679C\u3092\u7121\u8996(&I) PREFS_GLOSSARY_MERGE_ALTERNATE_DEFINITIONS=\u540C\u3058\u7528\u8A9E\u306E\u4EE3\u66FF\u306E\u5B9A\u7FA9\u3092\u7D50\u5408\u3059\u308B +PREFS_GLOSSARY_SORT_BY_SRC_LENGTH=\u7528\u8A9E\u306E\u539F\u6587\u306E\u9577\u3055\u9806\u306B\u4E26\u3079\u66FF\u3048\u308B +PREFS_GLOSSARY_SORT_BY_LENGTH=Sort by Target Term Length PREFS_GLOSSARY_LAYOUT=\u30EC\u30A4\u30A2\u30A6\u30C8(&L): GLOSSARY_RENDERER_DEFAULT=\u521D\u671F\u5024 @@ -2701,11 +2706,17 @@ PREFS_PLUGINS_COL_VERSION=\u30D0\u30FC\u30B8\u30E7\u30F3 PREFS_PLUGINS_COL_AUTHOR=\u4F5C\u8005 PREFS_PLUGINS_COL_DESCRIPTION=\u8AAC\u660E PREFS_PLUGINS_INSTALL_FROM_DISK=\u30D7\u30E9\u30B0\u30A4\u30F3\u3092\u30C7\u30A3\u30B9\u30AF\u304B\u3089\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB(&I) -PREFS_PLUGINS_TITLE_CONFIRM_INSTALLATION=\u30D7\u30E9\u30B0\u30A4\u30F3\u30D5\u30A1\u30A4\u30EB\u306E\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB -PREFS_PLUGINS_CONFIRM_UPGRADE=\u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u66F4\u65B0\u30FB\u4E0A\u66F8\u304D {0}\n\u73FE\u5728: {1}\n\u66F4\u65B0: {2} -PREFS_PLUGINS_CONFIRM_INSTALL=\u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB {0} {1} +PREFS_PLUGINS_TITLE_CONFIRM_INSTALLATION=\u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB +PREFS_PLUGINS_TITLE_CONFIRM_UPGRADE=\u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u66F4\u65B0 +PREFS_PLUGINS_CONFIRM_UPGRADE={0}\u30D7\u30E9\u30B0\u30A4\u30F3\u3092\u66F4\u65B0\u3057\u307E\u3059\u304B?\n\u73FE\u5728\u306E\u30D0\u30FC\u30B8\u30E7\u30F3: {1}\n\u65B0\u30D0\u30FC\u30B8\u30E7\u30F3: {2} +PREFS_PLUGINS_CONFIRM_OVERWRITE=\u30D0\u30FC\u30B8\u30E7\u30F3 {1} \u306F\u65E2\u306B\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3055\u308C\u3066\u3044\u307E\u3059\u3002\n\u30D7\u30E9\u30B0\u30A4\u30F3{0}\u3092\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3057\u307E\u3059\u304B?\n +PREFS_PLUGINS_CONFIRM_INSTALL={0} {1}\u30D7\u30E9\u30B0\u30A4\u30F3\u3092\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3057\u307E\u3059\u304B? PREFS_PLUGINS_INSTALLATION_FAILED=\u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306B\u5931\u6557\u3002 +PREFS_PLUGINS_INSTALLATION_SUCCEED=\u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306B\u6210\u529F\u3057\u307E\u3057\u305F\u3002OmegaT \u3092\u518D\u8D77\u52D5\u3057\u3066\u6709\u52B9\u5316\u3057\u307E\u3059\u3002 PREFS_PLUGINS_UNKNOWN_ARCHIVE=\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u3001\u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u30A2\u30FC\u30AB\u30A4\u30D6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002 +PREFS_PLUGINS_TITLE_NAME=\u30D7\u30E9\u30B0\u30A4\u30F3\u540D +PREFS_PLUGINS_TITLE_CURRENT_VERSION=\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB +PREFS_PLUGINS_TITLE_TARGET_VERSION=\u9078\u629E # PREFERENCES - UPDATES VERSION_CHECK_UP_TO_DATE=\u65E2\u306B\u6700\u65B0\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u3066\u3044\u307E\u3059\u3002 @@ -2736,7 +2747,7 @@ GPG_EXTERNAL_SIGNER_NO_KEY_FOUND=\u30AD\u30FCID "{0}" \u306EGPG\u516C\u958B\u937 GPG_EXTERNAL_SIGNER_SKIP_NOT_ACCESSIBLE_PATH=PATH\u74B0\u5883\u5909\u6570\u304B\u3089\u691C\u7D22\u3057\u305FGPG\u5B9F\u884C\u30D5\u30A1\u30A4\u30EB {0}\u306F\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\u3002\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3059\u3002 GPG_EXTERNAL_SIGNER_SIGNING_CANCELED=\u30E6\u30FC\u30B6\u30FC\u304C\u7F72\u540D\u3092\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u307E\u3057\u305F(\u30D1\u30B9\u30D5\u30EC\u30FC\u30BA\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u305B\u3093) GPG_EXTERNAL_SIGNER_GPG_NOT_FOUND=GPG\u5B9F\u884C\u53EF\u80FD\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002Git\u8A2D\u5B9A\u306E"Committing"\u30BB\u30AF\u30B7\u30E7\u30F3\u3067\u6307\u5B9A\u3059\u308B\u304B git config gpg.program\u3067\u5B9A\u7FA9\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -GPG_EXTERNAL_SIGNER_NO_SIGNATURE=\u5916\u90E8 GPG \u304C\u6709\u52B9\u306A\u30B7\u30B0\u30CB\u30C1\u30E3\u30FC\u3092\u8FD4\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002{0}\u304C\u8FD4\u3055\u308C\u307E\u3057\u305F\u3002 +GPG_EXTERNAL_SIGNER_NO_SIGNATURE=\u5916\u90E8 GPG \u306F\u7121\u52B9\u306A\u7F72\u540D\u3092\u8FD4\u3057\u307E\u3057\u305F\u3002 {0} SPELLCHECKER_LANGUAGE_NOT_FOUND=\u8A00\u8A9E{0}\u306E\u30B9\u30DA\u30EB\u30C1\u30A7\u30C3\u30AB\u30FC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F SPELLCHECKER_HUNSPELL_INITIALIZED=\u8A00\u8A9E '{0}' \u8F9E\u66F8{1}\u7528\u306E LanguageTool Hunspell \u30B9\u30DA\u30EB\u30C1\u30A7\u30C3\u30AB\u30FC\u3092\u521D\u671F\u5316 From 87c2d772490c08f67c28cf5a73fd27f5373dbbb8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 02:21:09 +0900 Subject: [PATCH 40/85] chore(deps): bump org.apache.pdfbox:pdfbox from 3.0.2 to 3.0.3 (#1103) Bumps org.apache.pdfbox:pdfbox from 3.0.2 to 3.0.3. --- updated-dependencies: - dependency-name: org.apache.pdfbox:pdfbox dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ae71e1c121..223d27e830 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -36,7 +36,7 @@ htmlparser = "1.6-20230203" gnudiff = "1.15" desktopsupport = "0.6.0" protocolhandler = "0.1.4" -pdfbox = "3.0.2" +pdfbox = "3.0.3" maligna = "3.0.1" trie4j = "0.9.10_1" dsl4j = "1.0.0" From 4cb4ba6c3d746ae22b9ac93a3081a3ee04f9167c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Aug 2024 21:06:23 +0900 Subject: [PATCH 41/85] chore(deps): bump gradle/actions from 3 to 4 (#1096) * chore(deps): bump gradle/actions from 3 to 4 Bumps [gradle/actions](https://github.com/gradle/actions) from 3 to 4. - [Release notes](https://github.com/gradle/actions/releases) - [Commits](https://github.com/gradle/actions/compare/v3...v4) --- updated-dependencies: - dependency-name: gradle/actions dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * chore: deprecated "arguments" of setup-gradle task Signed-off-by: Hiroshi Miura --------- Signed-off-by: dependabot[bot] Signed-off-by: Hiroshi Miura Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Hiroshi Miura --- .github/workflows/checkstyle-annotate.yml | 6 +++--- .github/workflows/gradle-build-master.yml | 2 +- .github/workflows/spotbugs-annotate.yml | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/checkstyle-annotate.yml b/.github/workflows/checkstyle-annotate.yml index edd2e8056d..34f97f41fe 100644 --- a/.github/workflows/checkstyle-annotate.yml +++ b/.github/workflows/checkstyle-annotate.yml @@ -18,7 +18,7 @@ jobs: java-version: '11' - name: create annotation run: echo "::add-matcher::${{ github.workspace }}/ci/github/problem-matcher.json" + - name: setup gradle + uses: gradle/actions/setup-gradle@v4 - name: run checkstyle - uses: gradle/actions/setup-gradle@v3 - with: - arguments: -PenvIsCi checkstyleMain checkstyleTest + run: ./gradlew -PenvIsCi checkstyleMain checkstyleTest diff --git a/.github/workflows/gradle-build-master.yml b/.github/workflows/gradle-build-master.yml index 506609d180..3850caa14b 100644 --- a/.github/workflows/gradle-build-master.yml +++ b/.github/workflows/gradle-build-master.yml @@ -20,7 +20,7 @@ jobs: distribution: 'temurin' - uses: gradle/wrapper-validation-action@v3 name: validate gradle wrapper - - uses: gradle/actions/setup-gradle@v3 + - uses: gradle/actions/setup-gradle@v4 name: Setup Gradle id: setup-gradle - name: Run gradle build diff --git a/.github/workflows/spotbugs-annotate.yml b/.github/workflows/spotbugs-annotate.yml index dcb7fcb570..3c56597378 100644 --- a/.github/workflows/spotbugs-annotate.yml +++ b/.github/workflows/spotbugs-annotate.yml @@ -18,7 +18,7 @@ jobs: java-version: '11' - name: create annotation run: echo "::add-matcher::${{ github.workspace }}/ci/github/problem-matcher.json" + - name: setup gradle + uses: gradle/actions/setup-gradle@v4 - name: run spotbugs - uses: gradle/actions/setup-gradle@v3 - with: - arguments: --continue -PenvIsCi spotbugsMain spotbugsTest + run: ./gradlew --continue -PenvIsCi spotbugsMain spotbugsTest From 3d802991fbca86693f0c5de05c535ac40634f5b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Aug 2024 23:13:21 +0900 Subject: [PATCH 42/85] chore(deps): bump com.formdev:flatlaf from 3.5 to 3.5.1 (#1097) Bumps [com.formdev:flatlaf](https://github.com/JFormDesigner/FlatLaf) from 3.5 to 3.5.1. - [Release notes](https://github.com/JFormDesigner/FlatLaf/releases) - [Changelog](https://github.com/JFormDesigner/FlatLaf/blob/main/CHANGELOG.md) - [Commits](https://github.com/JFormDesigner/FlatLaf/compare/3.5...3.5.1) --- updated-dependencies: - dependency-name: com.formdev:flatlaf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 223d27e830..b0a66bd732 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -48,7 +48,7 @@ xjc = "2.3.4" jna = "5.13.0" jfa = "1.2.0" tipoftheday = "0.4.4" -flatlaf="3.5" +flatlaf="3.5.1" assertj_swing_junit = "4.0.0-beta-1" morfologik = "2.1.9" From 8b7195c962303ac22c448c2af76d0aefa81c7801 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Mon, 19 Aug 2024 22:02:43 +0900 Subject: [PATCH 43/85] feat: Introduce language modules with LT languages (#1094) * feat: Introduce language modules It allows modularization of each language-* LT library as a plugin module. ## Type of change - Enhancement ## What ticket is realized - #1714 Make language libraries in LanguageTools as module - https://sourceforge.net/p/omegat/feature-requests/1714/ ## What change made - Introduce LanguageDataBroker and LanguageClassBroker classes for LT libraries to access module classes and resources. - Add LanguageManager: Language plugins should register LT language with registerLTLanguage for supporting module ## Other information related to PR#1091 Signed-off-by: Hiroshi Miura * chore: update lang mod dependency - Define all LT language libraries in version catalog - Improve version catalog referencing Signed-off-by: Hiroshi Miura * chore: update lang mod destination dir - avoid using deprecated `buildDir` Signed-off-by: Hiroshi Miura * chore: remove suppress warnings for deprecation Signed-off-by: Hiroshi Miura * style: LanguageToolTest Signed-off-by: Hiroshi Miura * style: update copyright header Signed-off-by: Hiroshi Miura * refactor: register LT language class with language code Signed-off-by: Hiroshi Miura * Update build.gradle * chore: drop checkstyle exception for LanguageToolTest Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- build.gradle | 10 +- config/checkstyle/suppressions.xml | 2 +- gradle/libs.versions.toml | 27 +++ language-modules/build.gradle | 85 ++++++++ .../org/omegat/languages/ar/ArabicPlugin.java | 44 ++++ .../omegat/languages/ast/AsturianPlugin.java | 44 ++++ .../omegat/languages/be/BelarusianPlugin.java | 44 ++++ .../org/omegat/languages/br/BretonPlugin.java | 44 ++++ .../omegat/languages/ca/CatalanPlugin.java | 44 ++++ .../org/omegat/languages/da/DanishPlugin.java | 44 ++++ .../org/omegat/languages/de/GermanPlugin.java | 48 +++++ .../org/omegat/languages/el/GreekPlugin.java | 44 ++++ .../omegat/languages/en/EnglishPlugin.java | 54 +++++ .../omegat/languages/eo/EsperantoPlugin.java | 44 ++++ .../omegat/languages/es/SpanishPlugin.java | 46 ++++ .../omegat/languages/fa/PersianPlugin.java | 45 ++++ .../org/omegat/languages/fr/FrenchPlugin.java | 44 ++++ .../org/omegat/languages/ga/IrishPlugin.java | 44 ++++ .../omegat/languages/gl/GalicianPlugin.java | 44 ++++ .../omegat/languages/it/ItalianPlugin.java | 45 ++++ .../omegat/languages/ja/JapanesePlugin.java | 44 ++++ .../languages/km/CentralKhmerPlugin.java | 44 ++++ .../org/omegat/languages/nl/DutchPlugin.java | 46 ++++ .../org/omegat/languages/pl/PolishPlugin.java | 44 ++++ .../omegat/languages/pt/PortuguesePlugin.java | 52 +++++ .../omegat/languages/ro/RomanianPlugin.java | 44 ++++ .../omegat/languages/ru/RussianPlugin.java | 44 ++++ .../org/omegat/languages/sk/SlovakPlugin.java | 44 ++++ .../omegat/languages/sl/SlovenianPlugin.java | 44 ++++ .../omegat/languages/sv/SwedishPlugin.java | 45 ++++ .../org/omegat/languages/ta/TamilPlugin.java | 44 ++++ .../omegat/languages/tl/TagalogPlugin.java | 44 ++++ .../omegat/languages/uk/UkrainianPlugin.java | 45 ++++ .../omegat/languages/zh/ChinesePlugin.java | 44 ++++ languagetools/build.gradle | 89 -------- settings.gradle | 1 + src/org/omegat/Main.java | 17 +- .../omegat/filters2/master/PluginUtils.java | 22 +- .../languagetools/LanguageClassBroker.java | 47 ++++ .../languagetools/LanguageDataBroker.java | 203 ++++++++++++++++++ .../omegat/languagetools/LanguageManager.java | 93 ++++++++ .../LanguageToolNativeBridge.java | 32 +-- .../languagetools/FalseFriendsTest.java | 22 +- .../languagetools/LanguageToolTest.java | 82 +++---- 44 files changed, 1904 insertions(+), 178 deletions(-) create mode 100644 language-modules/build.gradle create mode 100644 language-modules/src/ar/java/org/omegat/languages/ar/ArabicPlugin.java create mode 100644 language-modules/src/ast/java/org/omegat/languages/ast/AsturianPlugin.java create mode 100644 language-modules/src/be/java/org/omegat/languages/be/BelarusianPlugin.java create mode 100644 language-modules/src/br/java/org/omegat/languages/br/BretonPlugin.java create mode 100644 language-modules/src/ca/java/org/omegat/languages/ca/CatalanPlugin.java create mode 100644 language-modules/src/da/java/org/omegat/languages/da/DanishPlugin.java create mode 100644 language-modules/src/de/java/org/omegat/languages/de/GermanPlugin.java create mode 100644 language-modules/src/el/java/org/omegat/languages/el/GreekPlugin.java create mode 100644 language-modules/src/en/java/org/omegat/languages/en/EnglishPlugin.java create mode 100644 language-modules/src/eo/java/org/omegat/languages/eo/EsperantoPlugin.java create mode 100644 language-modules/src/es/java/org/omegat/languages/es/SpanishPlugin.java create mode 100644 language-modules/src/fa/java/org/omegat/languages/fa/PersianPlugin.java create mode 100644 language-modules/src/fr/java/org/omegat/languages/fr/FrenchPlugin.java create mode 100644 language-modules/src/ga/java/org/omegat/languages/ga/IrishPlugin.java create mode 100644 language-modules/src/gl/java/org/omegat/languages/gl/GalicianPlugin.java create mode 100644 language-modules/src/it/java/org/omegat/languages/it/ItalianPlugin.java create mode 100644 language-modules/src/ja/java/org/omegat/languages/ja/JapanesePlugin.java create mode 100644 language-modules/src/km/java/org/omegat/languages/km/CentralKhmerPlugin.java create mode 100644 language-modules/src/nl/java/org/omegat/languages/nl/DutchPlugin.java create mode 100644 language-modules/src/pl/java/org/omegat/languages/pl/PolishPlugin.java create mode 100644 language-modules/src/pt/java/org/omegat/languages/pt/PortuguesePlugin.java create mode 100644 language-modules/src/ro/java/org/omegat/languages/ro/RomanianPlugin.java create mode 100644 language-modules/src/ru/java/org/omegat/languages/ru/RussianPlugin.java create mode 100644 language-modules/src/sk/java/org/omegat/languages/sk/SlovakPlugin.java create mode 100644 language-modules/src/sl/java/org/omegat/languages/sl/SlovenianPlugin.java create mode 100644 language-modules/src/sv/java/org/omegat/languages/sv/SwedishPlugin.java create mode 100644 language-modules/src/ta/java/org/omegat/languages/ta/TamilPlugin.java create mode 100644 language-modules/src/tl/java/org/omegat/languages/tl/TagalogPlugin.java create mode 100644 language-modules/src/uk/java/org/omegat/languages/uk/UkrainianPlugin.java create mode 100644 language-modules/src/zh/java/org/omegat/languages/zh/ChinesePlugin.java delete mode 100644 languagetools/build.gradle create mode 100644 src/org/omegat/languagetools/LanguageClassBroker.java create mode 100644 src/org/omegat/languagetools/LanguageDataBroker.java create mode 100644 src/org/omegat/languagetools/LanguageManager.java diff --git a/build.gradle b/build.gradle index 441e2976a0..61c1bc0894 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(variantOf(libs.lucene.gosen){ classifier("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/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml index b5da6b7561..668dbca372 100644 --- a/config/checkstyle/suppressions.xml +++ b/config/checkstyle/suppressions.xml @@ -37,7 +37,7 @@ - diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b0a66bd732..7a3b5a62e2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,6 +14,7 @@ woodstox = "6.5.0" languagetool = "6.1" languagedetector = "0.6-2" lucene = "5.5.5" +lucene_gosen = "5.5.1" checkstyle = "8.45.1" guava = "32.1.2-jre" annotations = "23.0.0" @@ -68,16 +69,42 @@ woodstox-core = {group = "com.fasterxml.woodstox", name = "woodstox-core", versi languagetool-all = {group = "org.languagetool", name = "language-all", version.ref = "languagetool"} languagetool-core = {group = "org.languagetool", name = "languagetool-core", version.ref = "languagetool"} languagetool-server = {group = "org.languagetool", name = "languagetool-server", version.ref = "languagetool"} +languagetool-ar = {group = "org.languagetool", name = "language-ar", version.ref = "languagetool"} +languagetool-ast = {group = "org.languagetool", name = "language-ast", version.ref = "languagetool"} languagetool-be = {group = "org.languagetool", name = "language-be", version.ref = "languagetool"} +languagetool-br = {group = "org.languagetool", name = "language-br", version.ref = "languagetool"} +languagetool-ca = {group = "org.languagetool", name = "language-ca", version.ref = "languagetool"} +languagetool-da = {group = "org.languagetool", name = "language-da", version.ref = "languagetool"} +languagetool-de = {group = "org.languagetool", name = "language-de", version.ref = "languagetool"} +languagetool-el = {group = "org.languagetool", name = "language-el", version.ref = "languagetool"} languagetool-en = {group = "org.languagetool", name = "language-en", version.ref = "languagetool"} +languagetool-eo = {group = "org.languagetool", name = "language-eo", version.ref = "languagetool"} +languagetool-es = {group = "org.languagetool", name = "language-es", version.ref = "languagetool"} +languagetool-fa = {group = "org.languagetool", name = "language-fa", version.ref = "languagetool"} languagetool-fr = {group = "org.languagetool", name = "language-fr", version.ref = "languagetool"} +languagetool-ga = {group = "org.languagetool", name = "language-ga", version.ref = "languagetool"} +languagetool-gl = {group = "org.languagetool", name = "language-gl", version.ref = "languagetool"} +languagetool-it = {group = "org.languagetool", name = "language-it", version.ref = "languagetool"} languagetool-ja = {group = "org.languagetool", name = "language-ja", version.ref = "languagetool"} +languagetool-km = {group = "org.languagetool", name = "language-km", version.ref = "languagetool"} +languagetool-nl = {group = "org.languagetool", name = "language-nl", version.ref = "languagetool"} languagetool-pl = {group = "org.languagetool", name = "language-pl", version.ref = "languagetool"} +languagetool-pt = {group = "org.languagetool", name = "language-pt", version.ref = "languagetool"} +languagetool-ro = {group = "org.languagetool", name = "language-ro", version.ref = "languagetool"} +languagetool-ru = {group = "org.languagetool", name = "language-ru", version.ref = "languagetool"} +languagetool-sk = {group = "org.languagetool", name = "language-sk", version.ref = "languagetool"} +languagetool-sl = {group = "org.languagetool", name = "language-sl", version.ref = "languagetool"} +languagetool-sv = {group = "org.languagetool", name = "language-sv", version.ref = "languagetool"} +languagetool-ta = {group = "org.languagetool", name = "language-ta", version.ref = "languagetool"} +languagetool-tl = {group = "org.languagetool", name = "language-tl", version.ref = "languagetool"} +languagetool-uk = {group = "org.languagetool", name = "language-uk", version.ref = "languagetool"} +languagetool-zh = {group = "org.languagetool", name = "language-zh", version.ref = "languagetool"} lucene-core = {group = "org.apache.lucene", name = "lucene-core", version.ref = "lucene"} lucene-analyzers-common = {group = "org.apache.lucene", name = "lucene-analyzers-common", version.ref = "lucene"} lucene-analyzers-kuromoji = {group = "org.apache.lucene", name = "lucene-analyzers-kuromoji", version.ref = "lucene"} lucene-analyzers-smartcn = {group = "org.apache.lucene", name = "lucene-analyzers-smartcn", version.ref = "lucene"} lucene-analyzers-stempel = {group = "org.apache.lucene", name = "lucene-analyzers-stempel", version.ref = "lucene"} +lucene-gosen = {group = "org.omegat.lucene", name = "lucene-gosen", version.ref = "lucene_gosen"} guava = {group = "com.google.guava", name = "guava", version.ref = "guava"} jetbrains-annotations = {group = "org.jetbrains", name = "annotations", version.ref = "annotations"} groovy-jsr223 = {group = "org.apache.groovy", name = "groovy-jsr223", version.ref = "groovy"} diff --git a/language-modules/build.gradle b/language-modules/build.gradle new file mode 100644 index 0000000000..d3a83e4195 --- /dev/null +++ b/language-modules/build.gradle @@ -0,0 +1,85 @@ +def plugins = [ + [ code: 'ar', lang: 'Arabic'], + [ code: 'ast', lang: 'Asturian'], + [ code: 'be', lang: 'Belarusian'], + [ code: 'br', lang: 'Breton'], + [ code: 'ca', lang: 'Catalan'], + [ code: 'da', lang: 'Danish'], + [ code: 'de', lang: 'German'], + [ code: 'el', lang: 'Greek'], + [ code: 'en', lang: 'English'], + [ code: 'eo', lang: 'Esperanto'], + [ code: 'es', lang: 'Spanish'], + [ code: 'fa', lang: 'Persian'], + [ code: 'fr', lang: 'French'], + [ code: 'ga', lang: 'Irish'], + [ code: 'gl', lang: 'Galician'], + [ code: 'it', lang: 'Italian'], + [ code: 'ja', lang: 'Japanese'], + [ code: 'km', lang: 'CentralKhmer'], + [ code: 'nl', lang: 'Dutch'], + [ code: 'pl', lang: 'Polish'], + [ code: 'pt', lang: 'Portuguese'], + [ code: 'ro', lang: 'Romanian'], + [ code: 'ru', lang: 'Russian',], + [ code: 'sk', lang: 'Slovak'], + [ code: 'sl', lang: 'Slovenian'], + [ code: 'sv', lang: 'Swedish'], + [ code: 'ta', lang: 'Tamil'], + [ code: 'tl', lang: 'Tagalog'], + [ code: 'uk', lang: 'Ukrainian'], + [ code: 'zh', lang: 'Chinese'] +] + +plugins.forEach { args -> + def name = args.get('code') + def lang = args.get('lang') + def pluginClass = "org.omegat.languages.${name}.${lang}Plugin" + sourceSets.create(name) + dependencies.add("${name}CompileOnly", project.rootProject) + dependencies.add("${name}CompileOnly", libs.languagetool.core) + if (name.equals("ja")) { + dependencies.jaImplementation(libs.languagetool.ja) { + // Temporary exclusion; see https://sourceforge.net/p/omegat/bugs/814/ + exclude module: 'lucene-gosen' + exclude module: 'languagetool-core' + } + dependencies.jaImplementation(dependencies.variantOf(libs.lucene.gosen){ classifier("ipadic") }) + } else { + dependencies.add("${name}Implementation", libs.languagetool.getAt(name)) { + exclude module: 'languagetool-core' + } + } + configurations.getByName("${name}RuntimeClasspath").exclude(module: 'languagetool-core') + tasks.register("${name}Jar", Jar) { + archiveFileName.set("omegat-language-${name}.${archiveExtension.get()}") + destinationDirectory.set(rootProject.layout.buildDirectory.dir("modules").get()) + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + from configurations.getByName("${name}RuntimeClasspath").collect { + it.isDirectory() ? it : zipTree(it) + } + from sourceSets.getByName("${name}").output + manifest { + attributes( + 'Plugin-Name': "OmegaT language-${lang} plugin", + 'Plugin-License': 'GNU Public License version 3 or later', + 'OmegaT-Plugins': pluginClass, + 'Plugin-Author': 'OmegaT team', + 'Plugin-Link': 'https://omegat.org', + 'Plugin-Description': "Provide languagetool rules, and spell check dictionary for language-${lang}", + 'Plugin-Category': 'language', + 'Plugin-Version': libs.versions.languagetool.get() + ) + } + group = 'build' + } + jar.dependsOn tasks.named("${name}Jar") + tasks.getByName("${name}Classes") { + group = 'build' + } + def capitalName = name.capitalize() + tasks.getByName("spotbugs${capitalName}") { + group = 'other' + } + tasks.getByName("checkstyleMain").dependsOn tasks.named("checkstyle${capitalName}") +} diff --git a/language-modules/src/ar/java/org/omegat/languages/ar/ArabicPlugin.java b/language-modules/src/ar/java/org/omegat/languages/ar/ArabicPlugin.java new file mode 100644 index 0000000000..51441829ae --- /dev/null +++ b/language-modules/src/ar/java/org/omegat/languages/ar/ArabicPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.ar; + +import org.omegat.languagetools.LanguageManager; + +public final class ArabicPlugin { + + private static final String ARABIC = "org.languagetool.language.Arabic"; + + private ArabicPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("ar-AR", ARABIC); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/ast/java/org/omegat/languages/ast/AsturianPlugin.java b/language-modules/src/ast/java/org/omegat/languages/ast/AsturianPlugin.java new file mode 100644 index 0000000000..110050c68d --- /dev/null +++ b/language-modules/src/ast/java/org/omegat/languages/ast/AsturianPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.ast; + +import org.omegat.languagetools.LanguageManager; + +public final class AsturianPlugin { + + private static final String ASTURIAN = "org.languagetool.language.Asturian"; + + private AsturianPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("ast-ES", ASTURIAN); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/be/java/org/omegat/languages/be/BelarusianPlugin.java b/language-modules/src/be/java/org/omegat/languages/be/BelarusianPlugin.java new file mode 100644 index 0000000000..a4aeb693d5 --- /dev/null +++ b/language-modules/src/be/java/org/omegat/languages/be/BelarusianPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.be; + +import org.omegat.languagetools.LanguageManager; + +public final class BelarusianPlugin { + + private static final String BELARUSIAN = "org.languagetool.language.Belarusian"; + + private BelarusianPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("be", BELARUSIAN); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/br/java/org/omegat/languages/br/BretonPlugin.java b/language-modules/src/br/java/org/omegat/languages/br/BretonPlugin.java new file mode 100644 index 0000000000..6283b9bc5d --- /dev/null +++ b/language-modules/src/br/java/org/omegat/languages/br/BretonPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.br; + +import org.omegat.languagetools.LanguageManager; + +public final class BretonPlugin { + + private static final String BRETON = "org.languagetool.language.Breton"; + + private BretonPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("br", BRETON); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/ca/java/org/omegat/languages/ca/CatalanPlugin.java b/language-modules/src/ca/java/org/omegat/languages/ca/CatalanPlugin.java new file mode 100644 index 0000000000..e47153197c --- /dev/null +++ b/language-modules/src/ca/java/org/omegat/languages/ca/CatalanPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.ca; + +import org.omegat.languagetools.LanguageManager; + +public final class CatalanPlugin { + + private static final String CATALAN = "org.languagetool.language.Catalan"; + + private CatalanPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("ca", CATALAN); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/da/java/org/omegat/languages/da/DanishPlugin.java b/language-modules/src/da/java/org/omegat/languages/da/DanishPlugin.java new file mode 100644 index 0000000000..7ec9442b35 --- /dev/null +++ b/language-modules/src/da/java/org/omegat/languages/da/DanishPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.da; + +import org.omegat.languagetools.LanguageManager; + +public final class DanishPlugin { + + private static final String DANISH = "org.languagetool.language.Danish"; + + private DanishPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("da", DANISH); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/de/java/org/omegat/languages/de/GermanPlugin.java b/language-modules/src/de/java/org/omegat/languages/de/GermanPlugin.java new file mode 100644 index 0000000000..1955d557a8 --- /dev/null +++ b/language-modules/src/de/java/org/omegat/languages/de/GermanPlugin.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) 2023-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.languages.de; + +import org.omegat.languagetools.LanguageManager; + +public final class GermanPlugin { + + private static final String AUSTRARIAN_GERMAN = "org.languagetool.language.AustrianGerman"; + private static final String GERMANY_GERMAN = "org.languagetool.language.GermanyGerman"; + private static final String SWISS_GERMAN = "org.languagetool.language.SwissGerman"; + + private GermanPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("de-AT", AUSTRARIAN_GERMAN); + LanguageManager.registerLTLanguage("de-DE", GERMANY_GERMAN); + LanguageManager.registerLTLanguage("de-CH", SWISS_GERMAN); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/el/java/org/omegat/languages/el/GreekPlugin.java b/language-modules/src/el/java/org/omegat/languages/el/GreekPlugin.java new file mode 100644 index 0000000000..73a15ed8aa --- /dev/null +++ b/language-modules/src/el/java/org/omegat/languages/el/GreekPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.el; + +import org.omegat.languagetools.LanguageManager; + +public final class GreekPlugin { + + private static final String GREEK = "org.languagetool.language.Greek"; + + private GreekPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("el-GR", GREEK); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/en/java/org/omegat/languages/en/EnglishPlugin.java b/language-modules/src/en/java/org/omegat/languages/en/EnglishPlugin.java new file mode 100644 index 0000000000..9fe003ee4e --- /dev/null +++ b/language-modules/src/en/java/org/omegat/languages/en/EnglishPlugin.java @@ -0,0 +1,54 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.en; + +import java.io.IOException; + +import org.omegat.languagetools.LanguageManager; + +public final class EnglishPlugin { + + private static final String ENGLISH = "org.languagetool.language.English"; + private static final String AMERICAN_ENGLISH = "org.languagetool.language.AmericanEnglish"; + private static final String BRITISH_ENGLISH = "org.languagetool.language.BritishEnglish"; + private static final String CANADIAN_ENGLISH = "org.languagetool.language.CanadianEnglish"; + private static final String AUSTRALIAN_ENGLISH = "org.languagetool.language.AUSTRARLANEnglish"; + + private EnglishPlugin() { + } + + public static void loadPlugins() throws IOException { + LanguageManager.registerLTLanguage("en", ENGLISH); + LanguageManager.registerLTLanguage("en-US", AMERICAN_ENGLISH); + LanguageManager.registerLTLanguage("en-GB", BRITISH_ENGLISH); + LanguageManager.registerLTLanguage("en-CA", CANADIAN_ENGLISH); + LanguageManager.registerLTLanguage("en-AU", AUSTRALIAN_ENGLISH); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/eo/java/org/omegat/languages/eo/EsperantoPlugin.java b/language-modules/src/eo/java/org/omegat/languages/eo/EsperantoPlugin.java new file mode 100644 index 0000000000..57fa6975dd --- /dev/null +++ b/language-modules/src/eo/java/org/omegat/languages/eo/EsperantoPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.eo; + +import org.omegat.languagetools.LanguageManager; + +public final class EsperantoPlugin { + + private static final String ESPERANTO = "org.languagetool.language.Esperanto"; + + private EsperantoPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("eo", ESPERANTO); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/es/java/org/omegat/languages/es/SpanishPlugin.java b/language-modules/src/es/java/org/omegat/languages/es/SpanishPlugin.java new file mode 100644 index 0000000000..71d72ab5f9 --- /dev/null +++ b/language-modules/src/es/java/org/omegat/languages/es/SpanishPlugin.java @@ -0,0 +1,46 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.es; + +import org.omegat.languagetools.LanguageManager; + +public final class SpanishPlugin { + + private static final String SPANISH = "org.languagetool.language.Spanish"; + private static final String SPANISH_VOSEO = "org.languagetool.language.SpanishVoseo"; + + private SpanishPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("es", SPANISH); + LanguageManager.registerLTLanguage("es-AR", SPANISH_VOSEO); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/fa/java/org/omegat/languages/fa/PersianPlugin.java b/language-modules/src/fa/java/org/omegat/languages/fa/PersianPlugin.java new file mode 100644 index 0000000000..964f43d053 --- /dev/null +++ b/language-modules/src/fa/java/org/omegat/languages/fa/PersianPlugin.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-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.languages.fa; + +import org.omegat.languagetools.LanguageManager; + +public final class PersianPlugin { + + private static final String PERSIAN = "org.languagetool.language.Persian"; + + private PersianPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("fa-IR", PERSIAN); + LanguageManager.registerLTLanguage("fa-AF", PERSIAN); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/fr/java/org/omegat/languages/fr/FrenchPlugin.java b/language-modules/src/fr/java/org/omegat/languages/fr/FrenchPlugin.java new file mode 100644 index 0000000000..49a094aef8 --- /dev/null +++ b/language-modules/src/fr/java/org/omegat/languages/fr/FrenchPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.fr; + +import org.omegat.languagetools.LanguageManager; + +public final class FrenchPlugin { + + private static final String FRENCH = "org.languagetool.language.French"; + + private FrenchPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("fr", FRENCH); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/ga/java/org/omegat/languages/ga/IrishPlugin.java b/language-modules/src/ga/java/org/omegat/languages/ga/IrishPlugin.java new file mode 100644 index 0000000000..7e6958fb52 --- /dev/null +++ b/language-modules/src/ga/java/org/omegat/languages/ga/IrishPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.ga; + +import org.omegat.languagetools.LanguageManager; + +public final class IrishPlugin { + + private static final String IRISH = "org.languagetool.language.Irish"; + + private IrishPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("ga-IE", IRISH); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/gl/java/org/omegat/languages/gl/GalicianPlugin.java b/language-modules/src/gl/java/org/omegat/languages/gl/GalicianPlugin.java new file mode 100644 index 0000000000..38589b7e21 --- /dev/null +++ b/language-modules/src/gl/java/org/omegat/languages/gl/GalicianPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.gl; + +import org.omegat.languagetools.LanguageManager; + +public final class GalicianPlugin { + + private static final String GALICIAN = "org.languagetool.language.Galician"; + + private GalicianPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("gl-ES", GALICIAN); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/it/java/org/omegat/languages/it/ItalianPlugin.java b/language-modules/src/it/java/org/omegat/languages/it/ItalianPlugin.java new file mode 100644 index 0000000000..d054c4c875 --- /dev/null +++ b/language-modules/src/it/java/org/omegat/languages/it/ItalianPlugin.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-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.languages.it; + +import org.omegat.languagetools.LanguageManager; + +public final class ItalianPlugin { + + private static final String ITALIAN = "org.languagetool.language.Italian"; + + private ItalianPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("it-CH", ITALIAN); + LanguageManager.registerLTLanguage("it-IT", ITALIAN); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/ja/java/org/omegat/languages/ja/JapanesePlugin.java b/language-modules/src/ja/java/org/omegat/languages/ja/JapanesePlugin.java new file mode 100644 index 0000000000..90c9c5a6c7 --- /dev/null +++ b/language-modules/src/ja/java/org/omegat/languages/ja/JapanesePlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.ja; + +import org.omegat.languagetools.LanguageManager; + +public final class JapanesePlugin { + + private static final String JAPANESE = "org.languagetool.language.Japanese"; + + private JapanesePlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("ja-JP", JAPANESE); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/km/java/org/omegat/languages/km/CentralKhmerPlugin.java b/language-modules/src/km/java/org/omegat/languages/km/CentralKhmerPlugin.java new file mode 100644 index 0000000000..f999225f40 --- /dev/null +++ b/language-modules/src/km/java/org/omegat/languages/km/CentralKhmerPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.km; + +import org.omegat.languagetools.LanguageManager; + +public final class CentralKhmerPlugin { + + private static final String KHMER = "org.languagetool.language.Khmer"; + + private CentralKhmerPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("km-KH", KHMER); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/nl/java/org/omegat/languages/nl/DutchPlugin.java b/language-modules/src/nl/java/org/omegat/languages/nl/DutchPlugin.java new file mode 100644 index 0000000000..afa7c9c251 --- /dev/null +++ b/language-modules/src/nl/java/org/omegat/languages/nl/DutchPlugin.java @@ -0,0 +1,46 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.nl; + +import org.omegat.languagetools.LanguageManager; + +public final class DutchPlugin { + + private static final String DUTCH = "org.languagetool.language.Dutch"; + private static final String BELGIAN_DUTCH = "org.languagetool.language.BelgianDutch"; + + private DutchPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("nl-NL", DUTCH); + LanguageManager.registerLTLanguage("nl-BE", BELGIAN_DUTCH); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/pl/java/org/omegat/languages/pl/PolishPlugin.java b/language-modules/src/pl/java/org/omegat/languages/pl/PolishPlugin.java new file mode 100644 index 0000000000..3a19592291 --- /dev/null +++ b/language-modules/src/pl/java/org/omegat/languages/pl/PolishPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.pl; + +import org.omegat.languagetools.LanguageManager; + +public final class PolishPlugin { + + private static final String POLISH = "org.languagetool.language.Polish"; + + private PolishPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("pl-PL", POLISH); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/pt/java/org/omegat/languages/pt/PortuguesePlugin.java b/language-modules/src/pt/java/org/omegat/languages/pt/PortuguesePlugin.java new file mode 100644 index 0000000000..fa2784c361 --- /dev/null +++ b/language-modules/src/pt/java/org/omegat/languages/pt/PortuguesePlugin.java @@ -0,0 +1,52 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.pt; + +import org.omegat.languagetools.LanguageManager; + +public final class PortuguesePlugin { + + private static final String PORTUGUESE = "org.languagetool.language.Portuguese"; + private static final String PORTUGAL_PORTUGUESE = "org.languagetool.language.PortugalPortuguese"; + private static final String BRAZILIAN_PORTUGUESE = "org.languagetool.language.BrazilianPortuguese"; + private static final String ANGOLA_PORTUGUESE = "org.languagetool.language.AngolaPortuguese"; + private static final String MOZAMBIQUE_PORTUGUESE = "org.languagetool.language.MozambiquePortuguese"; + + private PortuguesePlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("pt", PORTUGUESE); + LanguageManager.registerLTLanguage("pt-PT", PORTUGAL_PORTUGUESE); + LanguageManager.registerLTLanguage("pt-BR", BRAZILIAN_PORTUGUESE); + LanguageManager.registerLTLanguage("pt-AO", ANGOLA_PORTUGUESE); + LanguageManager.registerLTLanguage("pt-MZ", MOZAMBIQUE_PORTUGUESE); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/ro/java/org/omegat/languages/ro/RomanianPlugin.java b/language-modules/src/ro/java/org/omegat/languages/ro/RomanianPlugin.java new file mode 100644 index 0000000000..287cf8c3b7 --- /dev/null +++ b/language-modules/src/ro/java/org/omegat/languages/ro/RomanianPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.ro; + +import org.omegat.languagetools.LanguageManager; + +public final class RomanianPlugin { + + private static final String ROMANIAN = "org.languagetool.language.Romanian"; + + private RomanianPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("ro-RO", ROMANIAN); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/ru/java/org/omegat/languages/ru/RussianPlugin.java b/language-modules/src/ru/java/org/omegat/languages/ru/RussianPlugin.java new file mode 100644 index 0000000000..68a96cb333 --- /dev/null +++ b/language-modules/src/ru/java/org/omegat/languages/ru/RussianPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.ru; + +import org.omegat.languagetools.LanguageManager; + +public final class RussianPlugin { + + private static final String RUSSIAN = "org.languagetool.language.Russian"; + + private RussianPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("ru-RU", RUSSIAN); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/sk/java/org/omegat/languages/sk/SlovakPlugin.java b/language-modules/src/sk/java/org/omegat/languages/sk/SlovakPlugin.java new file mode 100644 index 0000000000..93336b11d1 --- /dev/null +++ b/language-modules/src/sk/java/org/omegat/languages/sk/SlovakPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.sk; + +import org.omegat.languagetools.LanguageManager; + +public final class SlovakPlugin { + + private static final String SLOVAK = "org.languagetool.language.Slovak"; + + private SlovakPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("sk-SK", SLOVAK); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/sl/java/org/omegat/languages/sl/SlovenianPlugin.java b/language-modules/src/sl/java/org/omegat/languages/sl/SlovenianPlugin.java new file mode 100644 index 0000000000..21b9cf1fdb --- /dev/null +++ b/language-modules/src/sl/java/org/omegat/languages/sl/SlovenianPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.sl; + +import org.omegat.languagetools.LanguageManager; + +public final class SlovenianPlugin { + + private static final String SLOVENIAN = "org.languagetool.language.Slovenian"; + + private SlovenianPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("sl-SI", SLOVENIAN); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/sv/java/org/omegat/languages/sv/SwedishPlugin.java b/language-modules/src/sv/java/org/omegat/languages/sv/SwedishPlugin.java new file mode 100644 index 0000000000..10d04440d2 --- /dev/null +++ b/language-modules/src/sv/java/org/omegat/languages/sv/SwedishPlugin.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-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.languages.sv; + +import org.omegat.languagetools.LanguageManager; + +public final class SwedishPlugin { + + private static final String SWEDISH = "org.languagetool.language.Swedish"; + + private SwedishPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("sv-SE", SWEDISH); + LanguageManager.registerLTLanguage("sv-FI", SWEDISH); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/ta/java/org/omegat/languages/ta/TamilPlugin.java b/language-modules/src/ta/java/org/omegat/languages/ta/TamilPlugin.java new file mode 100644 index 0000000000..bc707bc3aa --- /dev/null +++ b/language-modules/src/ta/java/org/omegat/languages/ta/TamilPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.ta; + +import org.omegat.languagetools.LanguageManager; + +public final class TamilPlugin { + + private static final String TAMIL = "org.languagetool.language.Tamil"; + + private TamilPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("ta-IN", TAMIL); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/tl/java/org/omegat/languages/tl/TagalogPlugin.java b/language-modules/src/tl/java/org/omegat/languages/tl/TagalogPlugin.java new file mode 100644 index 0000000000..0ba7010e43 --- /dev/null +++ b/language-modules/src/tl/java/org/omegat/languages/tl/TagalogPlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.tl; + +import org.omegat.languagetools.LanguageManager; + +public final class TagalogPlugin { + + private static final String TAGALOG = "org.languagetool.language.Tagalog"; + + private TagalogPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("tl-PH", TAGALOG); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/uk/java/org/omegat/languages/uk/UkrainianPlugin.java b/language-modules/src/uk/java/org/omegat/languages/uk/UkrainianPlugin.java new file mode 100644 index 0000000000..d419b3b0c3 --- /dev/null +++ b/language-modules/src/uk/java/org/omegat/languages/uk/UkrainianPlugin.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-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.languages.uk; + +import org.omegat.languagetools.LanguageManager; + +public final class UkrainianPlugin { + + private static final String UKRAINIAN = "org.languagetool.language.Ukrainian"; + private static final String UKRAINIAN1992 = "org.languagetool.language.Ukrainian1992"; + + private UkrainianPlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("uk-UA", UKRAINIAN); + } + + public static void unloadPlugins() { + } + +} diff --git a/language-modules/src/zh/java/org/omegat/languages/zh/ChinesePlugin.java b/language-modules/src/zh/java/org/omegat/languages/zh/ChinesePlugin.java new file mode 100644 index 0000000000..89ad5a1fe3 --- /dev/null +++ b/language-modules/src/zh/java/org/omegat/languages/zh/ChinesePlugin.java @@ -0,0 +1,44 @@ +/* + * OmegaT - Computer Assisted Translation (CAT) tool + * with fuzzy matching, translation memory, keyword search, + * glossaries, and translation leveraging into updated projects. + * + * Copyright (C) 2023-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.languages.zh; + +import org.omegat.languagetools.LanguageManager; + +public final class ChinesePlugin { + + private static final String CHINESE = "org.languagetool.language.Chinese"; + + private ChinesePlugin() { + } + + public static void loadPlugins() { + LanguageManager.registerLTLanguage("zh-CH", CHINESE); + } + + public static void unloadPlugins() { + } + +} diff --git a/languagetools/build.gradle b/languagetools/build.gradle deleted file mode 100644 index 5302ced7ce..0000000000 --- a/languagetools/build.gradle +++ /dev/null @@ -1,89 +0,0 @@ -plugins { - id 'java' -} -repositories { - mavenCentral() -} - -def plugins = [ - [ lang: 'Arabic', code: 'ar', className: 'ArabicPlugin'], - [ lang: 'Asturian', code: 'ast', className: 'AsturianPlugin'], - [ lang: 'Belarusian', code: 'be', className: 'BelarusianPlugin'], - [ lang: 'Breton', code: 'br', className: 'BretonPlugin'], - [ lang: 'Catalan', code: 'ca', className: 'CatalanPlugin'], - [ lang: 'Danish', code: 'da', className: 'DanishPlugin'], - [ lang: 'German', code: 'de', className: 'GermanPlugin'], - [ lang: 'Greek', code: 'el', className: 'GreekPlugin'], - [ lang: 'English', code: 'en', className: 'EnglishPlugin'], - [ lang: 'Esperanto', code: 'eo', className: 'EsperantoPlugin'], - [ lang: 'Spanish', code: 'es', className: 'SpanishPlugin'], - [ lang: 'Persian', code: 'fa', className: 'PersianPlugin'], - [ lang: 'French', code: 'fr', className: 'FrenchPlugin'], - [ lang: 'Irish', code: 'ga', className: 'IrishPlugin'], - [ lang: 'Galician', code: 'gl', className: 'GalicianPlugin'], - [ lang: 'Italian', code: 'it', className: 'ItalianPlugin'], - [ lang: 'Japanese', code: 'ja', className: 'JapanesePlugin'], - [ lang: 'Central Khmer', code: 'km', className: 'KhmerPlugin'], - [ lang: 'Dutch', code: 'nl', className: 'DutchPlugin'], - [ lang: 'Polish', code: 'pl', className: 'PolishPlugin'], - [ lang: 'Portuguese', code: 'pt', className: 'PortuguesePlugin'], - [ lang: 'Romanian', code: 'ro', className: 'RomanianPlugin'], - [ lang: 'Russian', code: 'ru', className: 'RussianPlugin'], - [ lang: 'Slovak', code: 'sk', className: 'SlovakPlugin'], - [ lang: 'Slovenian', code: 'sl', className: 'SlovenianPlugin'], - [ lang: 'Swedish', code: 'sv', className: 'SwedishPlugin'], - [ lang: 'Tamil', code: 'ta', className: 'TamilPlugin'], - [ lang: 'Tagalog', code: 'tl', className: 'TagalogPlugin'], - [ lang: 'Ukrainian', code: 'uk', className: 'UkrainianPlugin'], - [ lang: 'Chinese', code: 'zh', className: 'ChinesePlugin'] -] - -def pluginPackage = 'org.omegat.languagetool.language' -def languageToolVersion = libs.versions.languagetool.get() -plugins.forEach { args -> - def name = args.get('code') - def pluginClass = "${pluginPackage}." + args.get('className') - def lang = args.get('lang') - sourceSets.create(name) - if (name.equals("ja")) { - dependencies.add("jaImplementation", libs.languagetool.ja.get()) { - // Temporary exclusion; see https://sourceforge.net/p/omegat/bugs/814/ - exclude module: 'lucene-gosen' - exclude module: 'languagetool-core' - } - dependencies.add("jaImplementation", 'org.omegat.lucene:lucene-gosen:5.5.1:ipadic') - } else { - dependencies.add("${name}Implementation", "org.languagetool:language-${name}:${languageToolVersion}") { - exclude module: 'languagetool-core' - } - } - configurations.getByName("${name}RuntimeClasspath").exclude(group: 'org.languagetool', module: 'languagetool-core') - tasks.getByName("${name}Classes") { - group = 'languagetool' - } - tasks.register("${name}Jar", Jar) { - archiveFileName.set("omegat-language-${name}.${archiveExtension.get()}") - destinationDirectory.set(new File(rootProject.buildDir, "modules")) - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - from configurations.getByName("${name}RuntimeClasspath").collect { - it.isDirectory() ? it : zipTree(it) - } - from sourceSets.getByName("${name}").output - manifest { - attributes( - 'Plugin-Name': "${lang} LanguageTool", - 'Plugin-License': 'GNU Public License version 3 or later', - 'OmegaT-Plugins': pluginClass, - 'Plugin-Author': 'OmegaT team', - 'Plugin-Link': 'https://omegat.org', - 'Plugin-Description': "Provide ${lang} Languagetool library", - 'Plugin-Version': "${languageToolVersion}") - } - group = 'languagetool' - } - jar.dependsOn "${name}Jar" - def capitalName = name.capitalize() - tasks.getByName("spotbugs${capitalName}") { - group = 'other' - } -} diff --git a/settings.gradle b/settings.gradle index c3fc45b792..521f4bec9a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -18,6 +18,7 @@ include("machinetranslators:apertium", "machinetranslators:mymemory", "machinetranslators:yandex", "machinetranslators:dummy", + "language-modules", "aligner", "theme", "spellchecker:hunspell", diff --git a/src/org/omegat/Main.java b/src/org/omegat/Main.java index 43a114413c..0f7800aee6 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.LanguageClassBroker; +import org.omegat.languagetools.LanguageDataBroker; import tokyo.northside.logging.ILogger; import org.omegat.CLIParameters.PSEUDO_TRANSLATE_TYPE; @@ -188,15 +191,12 @@ public static void main(String[] args) { // initialize logging backend and loading configuration. ILogger logger = Log.getLogger(Main.class); - logger.atInfo() - .setMessage("\n{0}\n{1} (started on {2} {3}) Locale {4}") - .addArgument(StringUtils.repeat('=', 120)) - .addArgument(OStrings.getNameAndVersion()) + logger.atInfo().setMessage("\n{0}\n{1} (started on {2} {3}) Locale {4}") + .addArgument(StringUtils.repeat('=', 120)).addArgument(OStrings.getNameAndVersion()) .addArgument(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM) .withLocale(Locale.getDefault()).format(ZonedDateTime.now())) .addArgument(ZoneId.systemDefault().getDisplayName(TextStyle.SHORT, Locale.getDefault())) - .addArgument(Locale.getDefault().toLanguageTag()) - .log(); + .addArgument(Locale.getDefault().toLanguageTag()).log(); logger.atInfo().logRB("LOG_STARTUP_INFO", System.getProperty("java.vendor"), System.getProperty("java.version"), System.getProperty("java.home")); @@ -205,6 +205,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 LanguageClassBroker()); + JLanguageTool.setDataBroker(new LanguageDataBroker()); PluginUtils.loadPlugins(PARAMS); FilterMaster.setFilterClasses(PluginUtils.getFilterClasses()); Preferences.initFilters(); @@ -332,7 +335,7 @@ private static void applyConfigFile(String path) { * Execute standard GUI. */ protected static int runGUI() { - UIManager.put("ClassLoader", PluginUtils.getThemeClassLoader()); + 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 ae235dab45..eef3e66036 100644 --- a/src/org/omegat/filters2/master/PluginUtils.java +++ b/src/org/omegat/filters2/master/PluginUtils.java @@ -130,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. */ @@ -162,9 +167,12 @@ public static PluginType getTypeByValue(String str) { private static final Set PLUGIN_INFORMATIONS = new HashSet<>(); private static final MainClassLoader THEME_CLASSLOADER; + private static final MainClassLoader LANGUAGE_CLASSLOADER; static { - THEME_CLASSLOADER = new MainClassLoader(PluginUtils.class.getClassLoader()); + ClassLoader cl = PluginUtils.class.getClassLoader(); + THEME_CLASSLOADER = new MainClassLoader(cl); + LANGUAGE_CLASSLOADER = new MainClassLoader(cl); } /** Private constructor to disallow creation */ @@ -217,6 +225,14 @@ public static void loadPlugins(final Map params) { loadFromManifest(m, THEME_CLASSLOADER, mu); } } + } else if ("language".equals(m.getMainAttributes().getValue(PLUGIN_CATEGORY))) { + String target = mu.toString(); + for (URL url : urlList) { + if (target.contains(url.toString())) { + LANGUAGE_CLASSLOADER.addJarToClasspath(url); + loadFromManifest(m, LANGUAGE_CLASSLOADER, mu); + } + } } else { loadFromManifest(m, pluginsClassLoader, mu); } @@ -474,6 +490,10 @@ public static ClassLoader getThemeClassLoader() { return THEME_CLASSLOADER; } + public static ClassLoader getLanguageClassLoader() { + return LANGUAGE_CLASSLOADER; + } + private static final List> FILTER_CLASSES = new ArrayList<>(); private static final List> TOKENIZER_CLASSES = new ArrayList<>(); diff --git a/src/org/omegat/languagetools/LanguageClassBroker.java b/src/org/omegat/languagetools/LanguageClassBroker.java new file mode 100644 index 0000000000..e01be8261c --- /dev/null +++ b/src/org/omegat/languagetools/LanguageClassBroker.java @@ -0,0 +1,47 @@ +/******************************************************************************* + 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 LanguageClassBroker implements ClassBroker { + + public LanguageClassBroker() { + } + + @Override + public Class forName(String qualifiedName) throws ClassNotFoundException { + Class clazz; + ClassLoader classLoader = PluginUtils.getLanguageClassLoader(); + try { + clazz = classLoader.loadClass(qualifiedName); + } catch (ClassNotFoundException e) { + clazz = LanguageClassBroker.class.getClassLoader().loadClass(qualifiedName); + } + return clazz; + } +} diff --git a/src/org/omegat/languagetools/LanguageDataBroker.java b/src/org/omegat/languagetools/LanguageDataBroker.java new file mode 100644 index 0000000000..78986ad099 --- /dev/null +++ b/src/org/omegat/languagetools/LanguageDataBroker.java @@ -0,0 +1,203 @@ +/******************************************************************************* + 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 LanguageDataBroker implements ResourceDataBroker { + + private final String resourceDir; + private final String rulesDir; + + public LanguageDataBroker(String resourceDir, String rulesDir) { + this.resourceDir = resourceDir == null ? "" : resourceDir; + this.rulesDir = rulesDir == null ? "" : rulesDir; + } + + public LanguageDataBroker() { + 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 = LanguageManager.getLTLanguage(); + 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 = LanguageManager.getLTLanguage(); + if (lang != null) { + url = lang.getClass().getResource(path); + } + } + return url; + } + + @Override + public @NotNull List getAsURLs(String path) { + Enumeration enumeration = null; + try { + enumeration = ResourceDataBroker.class.getClassLoader().getResources(path); + } catch (IOException ignored) { + } + if (enumeration != null) { + List urls = Collections.list(enumeration); + if (!urls.isEmpty()) { + return urls; + } + } + Language lang = LanguageManager.getLTLanguage(); + if (lang == null) { + return Collections.emptyList(); + } + try { + enumeration = lang.getClass().getClassLoader().getResources(path); + } catch (IOException ignored) { + return Collections.emptyList(); + } + 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/LanguageManager.java b/src/org/omegat/languagetools/LanguageManager.java new file mode 100644 index 0000000000..9ea3185ee9 --- /dev/null +++ b/src/org/omegat/languagetools/LanguageManager.java @@ -0,0 +1,93 @@ +/******************************************************************************* + 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.util.HashMap; +import java.util.Map; + +import org.languagetool.Language; +import org.languagetool.Languages; + +import org.omegat.core.Core; +import org.omegat.core.data.ProjectProperties; + +public final class LanguageManager { + + private static final Map LT_LANGUAGE_CLASSES = new HashMap<>(); + + private LanguageManager() { + } + + public static void registerLTLanguage(String lang, String fqcn) { + LT_LANGUAGE_CLASSES.put(lang, fqcn); + } + + static Language getLTLanguage(org.omegat.util.Language lang) { + if (lang == null) { + return null; + } + String fqcn = LT_LANGUAGE_CLASSES.get(lang.getLanguage()); + if (fqcn != null) { + return Languages.getOrAddLanguageByClassName(fqcn); + } + // Search for language code + fqcn = LT_LANGUAGE_CLASSES.get(lang.getLanguageCode()); + if (fqcn != null) { + return Languages.getOrAddLanguageByClassName(fqcn); + } + // Search for just language code match but allow country difference + String languageCode; + for (Map.Entry entry : LT_LANGUAGE_CLASSES.entrySet()) { + if (entry.getKey().contains("-")) { + languageCode = entry.getKey().substring(0, entry.getKey().indexOf('-')); + } else { + languageCode = entry.getKey(); + } + if (languageCode.equals(lang.getLanguageCode())) { + return Languages.getOrAddLanguageByClassName(entry.getValue()); + } + } + return null; + } + + static Language getLTLanguage() { + if (Core.getProject() == null) { + return null; + } + ProjectProperties prop = Core.getProject().getProjectProperties(); + if (prop == null) { + return null; + } + org.omegat.util.Language omLang = prop.getTargetLanguage(); + if (omLang == null) { + return null; + } + Language lang = getLTLanguage(omLang); + if (lang == null) { + lang = getLTLanguage(new org.omegat.util.Language("en-US")); + } + return lang; + } +} diff --git a/src/org/omegat/languagetools/LanguageToolNativeBridge.java b/src/org/omegat/languagetools/LanguageToolNativeBridge.java index e12892ffb2..770590794a 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 LanguageManager.getLTLanguage(lang); } } diff --git a/test/src/org/omegat/languagetools/FalseFriendsTest.java b/test/src/org/omegat/languagetools/FalseFriendsTest.java index 71523f7d65..bf470c53f6 100644 --- a/test/src/org/omegat/languagetools/FalseFriendsTest.java +++ b/test/src/org/omegat/languagetools/FalseFriendsTest.java @@ -4,6 +4,7 @@ glossaries, and translation leveraging into updated projects. Copyright (C) 2010-2013 Alex Buloichik + 2024 Hiroshi Miura Home page: https://www.omegat.org/ Support center: https://omegat.org/support @@ -32,7 +33,10 @@ import java.util.Map; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; +import org.languagetool.JLanguageTool; + import org.omegat.core.Core; import org.omegat.core.TestCore; import org.omegat.core.data.EntryKey; @@ -54,6 +58,17 @@ * @author Alex Buloichik (alex73mail@gmail.com) */ public class FalseFriendsTest extends TestCore { + + @BeforeClass + public static void setUpClass() { + JLanguageTool.setClassBrokerBroker(new LanguageClassBroker()); + JLanguageTool.setDataBroker(new LanguageDataBroker()); + LanguageManager.registerLTLanguage("en", "org.languagetool.language.English"); + LanguageManager.registerLTLanguage("en-US", "org.languagetool.language.AmericanEnglish"); + LanguageManager.registerLTLanguage("en-CA", "org.languagetool.language.CanadianEnglish"); + LanguageManager.registerLTLanguage("pl-PL", "org.languagetool.language.Polish"); + } + @Before public final void setUp() { final ProjectProperties props = new ProjectProperties() { @@ -188,8 +203,8 @@ public void commitSourceFiles() throws Exception { } @Override - public void compileProjectAndCommit(String sourcePattern, boolean doPostProcessing, boolean commitTargetFiles) - throws Exception { + public void compileProjectAndCommit(String sourcePattern, boolean doPostProcessing, + boolean commitTargetFiles) throws Exception { } }); LanguageToolWrapper.setBridgeFromCurrentProject(); @@ -216,7 +231,8 @@ public boolean isEnabled() { }; }; - List marks = marker.getMarksForEntry(null, "This is some long text without translation.", "", true); + List marks = marker.getMarksForEntry(null, "This is some long text without translation.", "", + true); assertEquals(0, marks.size()); marks = marker.getMarksForEntry(null, "This is text with the same translation.", diff --git a/test/src/org/omegat/languagetools/LanguageToolTest.java b/test/src/org/omegat/languagetools/LanguageToolTest.java index 5f5f54851d..ec177c9301 100644 --- a/test/src/org/omegat/languagetools/LanguageToolTest.java +++ b/test/src/org/omegat/languagetools/LanguageToolTest.java @@ -4,6 +4,7 @@ glossaries, and translation leveraging into updated projects. Copyright (C) 2010-2013 Alex Buloichik + 2024 Hiroshi Miura Home page: https://www.omegat.org/ Support center: https://omegat.org/support @@ -36,6 +37,7 @@ import java.util.Locale; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.languagetool.JLanguageTool; import org.languagetool.Languages; @@ -54,19 +56,29 @@ public class LanguageToolTest { private static final Language SOURCE_LANG = new Language(Locale.FRENCH); private static final Language TARGET_LANG = new Language(Locale.ENGLISH); + @BeforeClass + public static void setUpClass() { + JLanguageTool.setClassBrokerBroker(new LanguageClassBroker()); + JLanguageTool.setDataBroker(new LanguageDataBroker()); + LanguageManager.registerLTLanguage("en", "org.languagetool.language.English"); + LanguageManager.registerLTLanguage("en-US", "org.languagetool.language.AmericanEnglish"); + LanguageManager.registerLTLanguage("en-CA", "org.languagetool.language.CanadianEnglish"); + LanguageManager.registerLTLanguage("be-BE", "org.languagetool.language.Belarusian"); + LanguageManager.registerLTLanguage("fr-FR", "org.languagetool.language.French"); + } + @Before public final void setUp() throws Exception { TestPreferencesInitializer.init(); } @Test - @SuppressWarnings("deprecation") public void testExecuteLanguageToolCheck() throws Exception { JLanguageTool lt = new JLanguageTool(Languages.getLanguageForShortCode("be")); // The test string is Belarusian; originally it was actual UTF-8, - // but that causes the test to fail when environment encodings aren't set - // correctly, so we are now using Unicode literals. + // but that causes the test to fail when environment encodings aren't + // set correctly, so we are now using Unicode literals. List matches = lt.check("\u0441\u043F\u0440\u0430\u0443\u0434\u0437\u0456\u043C."); assertEquals(1, matches.size()); assertTrue(matches.get(0).getRule() instanceof PatternRule); @@ -76,7 +88,8 @@ public void testExecuteLanguageToolCheck() throws Exception { public void testFrench() throws Exception { JLanguageTool lt = new JLanguageTool(Languages.getLanguageForShortCode("fr")); - // example from https://github.com/languagetool-org/languagetool/issues/2852 + // example from + // https://github.com/languagetool-org/languagetool/issues/2852 List matches = lt.check("Il est par cons\u00E9quent perdue."); assertEquals(1, matches.size()); assertTrue(matches.get(0).getRule() instanceof PatternRule); @@ -98,15 +111,15 @@ public void testRemoteServer() throws Exception { assertThrows("URL not specifying API actions should fail due to missing argument.", java.lang.Exception.class, - () -> new LanguageToolNetworkBridge(SOURCE_LANG, TARGET_LANG, "http://localhost:8081") - ); + () -> new LanguageToolNetworkBridge(SOURCE_LANG, TARGET_LANG, "http://localhost:8081")); ILanguageToolBridge bridge = new LanguageToolNetworkBridge(SOURCE_LANG, TARGET_LANG, "http://localhost:8081/v2/check"); - // Set some rules to prevent the server from looking at config files. - // User config files can specify languages we aren't providing at test - // runtime, in which case queries will fail. + // Set some rules to prevent the server from looking at config + // files. + // User config files can specify languages we aren't providing at + // test runtime, in which case queries will fail. bridge.applyRuleFilters(Collections.singleton("FOO"), Collections.emptySet(), Collections.emptySet()); @@ -138,44 +151,31 @@ public void testWrapperInit() throws Exception { assertTrue(bridge instanceof LanguageToolNativeBridge); // Bad URL: fall back to local implementation - Preferences.setPreference(Preferences.LANGUAGETOOL_BRIDGE_TYPE, LanguageToolWrapper.BridgeType.REMOTE_URL); + Preferences.setPreference(Preferences.LANGUAGETOOL_BRIDGE_TYPE, + LanguageToolWrapper.BridgeType.REMOTE_URL); Preferences.setPreference(Preferences.LANGUAGETOOL_REMOTE_URL, "blah"); bridge = LanguageToolWrapper.createBridgeFromPrefs(SOURCE_LANG, TARGET_LANG); assertTrue(bridge instanceof LanguageToolNativeBridge); } @Test - @SuppressWarnings("deprecation") public void testLanguageMapping() { - { - org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("en-US")); - assertEquals(Languages.getLanguageForLocale(new Locale("en", "US")).getClass(), lang.getClass()); - } - { - org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("en-CA")); - assertEquals(Languages.getLanguageForLocale(new Locale("en", "CA")).getClass(), lang.getClass()); - } - { - org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("en")); - assertEquals(Languages.getLanguageForShortCode("en").getClass(), lang.getClass()); - } - { - // Unknown region--fall back to generic class - org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("en-JA")); - assertEquals(Languages.getLanguageForShortCode("en").getClass(), lang.getClass()); - } - { - org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("be-BY")); - assertEquals(Languages.getLanguageForShortCode("be").getClass(), lang.getClass()); - } - { - // Belarusian is offered in be-BY only; ensure hit with just "be" - org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("be")); - assertEquals(Languages.getLanguageForShortCode("be").getClass(), lang.getClass()); - } - { - org.languagetool.Language lang = LanguageToolNativeBridge.getLTLanguage(new Language("xyz")); - assertNull(lang); - } + org.languagetool.Language lang; + lang = LanguageToolNativeBridge.getLTLanguage(new Language("en-US")); + assertEquals(Languages.getLanguageForLocale(new Locale("en", "US")).getClass(), lang.getClass()); + lang = LanguageToolNativeBridge.getLTLanguage(new Language("en-CA")); + assertEquals(Languages.getLanguageForLocale(new Locale("en", "CA")).getClass(), lang.getClass()); + lang = LanguageToolNativeBridge.getLTLanguage(new Language("en")); + assertEquals(Languages.getLanguageForShortCode("en").getClass(), lang.getClass()); + // Unknown region--fall back to generic class + lang = LanguageToolNativeBridge.getLTLanguage(new Language("en-JA")); + assertEquals(Languages.getLanguageForShortCode("en").getClass(), lang.getClass()); + lang = LanguageToolNativeBridge.getLTLanguage(new Language("be-BY")); + assertEquals(Languages.getLanguageForShortCode("be").getClass(), lang.getClass()); + // Belarusian is offered in be-BY only; ensure hit with just "be" + lang = LanguageToolNativeBridge.getLTLanguage(new Language("be")); + assertEquals(Languages.getLanguageForShortCode("be").getClass(), lang.getClass()); + lang = LanguageToolNativeBridge.getLTLanguage(new Language("xyz")); + assertNull(lang); } } From 30a33a1cf962c004989fcfecd03b4e11044302b9 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 24 Aug 2024 09:29:03 +0900 Subject: [PATCH 44/85] [BUGS#1264] fix: ResourceBundleFilter force Unicode encoding when target encoding is US-ASCII (#1115) * fix: ResourceBundleFilter force Unicode encoding when target encoding is US-ASCII - Fix BUGS#1264 when charsert configuration is US_ASCII, force unicode escape - Refactoring ResourceBundleFilter#toAscii accept charsetEncoder and forceTargetEscape boolean Signed-off-by: Hiroshi Miura * docs: update changes.txt Signed-off-by: Hiroshi Miura * feat: add test case Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- release/changes.txt | 5 ++- .../text/bundles/ResourceBundleFilter.java | 30 +++++++------ ...urceBundleFilter-UnicodeEscaped.properties | 2 + ...esourceBundleFilter-UnicodeUTF8.properties | 2 + .../filters/ResourceBundleFilterTest.java | 42 +++++++++++++++++++ 5 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 test/data/filters/resourceBundle/file-ResourceBundleFilter-UnicodeEscaped.properties create mode 100644 test/data/filters/resourceBundle/file-ResourceBundleFilter-UnicodeUTF8.properties diff --git a/release/changes.txt b/release/changes.txt index f4349365a3..d0ed5e8bff 100644 --- a/release/changes.txt +++ b/release/changes.txt @@ -2,7 +2,7 @@ OmegaT 6.1.0 ---------------------------------------------------------------------- 45 Enhancement - 69 Bug fixes + 70 Bug fixes 5 Localisation updates ---------------------------------------------------------------------- 6.1.0 vs 6.0.0 @@ -139,6 +139,9 @@ Bug fixes: + - filter: bundle: when charsert configuration is US_ASCII, force unicode escape + https://sourceforge.net/p/omegat/bugs/1264/ + - OmegaT does not show entreis of stardict-JMDict dictionary https://sourceforge.net/p/omegat/bugs/1255/ diff --git a/src/org/omegat/filters2/text/bundles/ResourceBundleFilter.java b/src/org/omegat/filters2/text/bundles/ResourceBundleFilter.java index 5668f2a460..29e53b9cf7 100644 --- a/src/org/omegat/filters2/text/bundles/ResourceBundleFilter.java +++ b/src/org/omegat/filters2/text/bundles/ResourceBundleFilter.java @@ -9,7 +9,7 @@ 2013-2014 Enrique Estevez, Didier Briel 2015 Aaron Madlon-Kay, Enrique Estevez 2016 Aaron Madlon-Kay - 2023 Hiroshi Miura + 2023-2024 Hiroshi Miura Home page: https://www.omegat.org/ Support center: https://omegat.org/support @@ -100,9 +100,6 @@ public class ResourceBundleFilter extends AbstractFilter { protected Map align; - private String targetEncoding = DEFAULT_TARGET_ENCODING; - private Boolean forceTargetEscape = true; - /** * If true, will not convert characters into \\uXXXX notation */ @@ -248,8 +245,8 @@ private enum EscapeMode { * Is the string part of a key, a value or a comment? * @return The ascii string */ - private String toAscii(String text, EscapeMode mode) { - CharsetEncoder charsetEncoder = Charset.forName(targetEncoding).newEncoder(); + private String toAscii(String text, EscapeMode mode, CharsetEncoder charsetEncoder, + boolean forceTargetEscape) { StringBuilder result = new StringBuilder(); @@ -282,7 +279,8 @@ private String toAscii(String text, EscapeMode mode) { char[] chars = Character.toChars(cp); // optimized for speed for (int j = 0, charsLength = chars.length; j < charsLength; j++) { String code = Integer.toString(chars[j], 16).toUpperCase(); - result.append("\\u").append("0".repeat(Math.max(0, 4 - code.codePointCount(0, code.length())))) + result.append("\\u") + .append("0".repeat(Math.max(0, 4 - code.codePointCount(0, code.length())))) .append(code); } } @@ -359,10 +357,10 @@ public void processFile(BufferedReader reader, BufferedWriter outfile, FilterCon dontUnescapeULiterals = processOptions != null && "true".equalsIgnoreCase(processOptions.get(OPTION_DONT_UNESCAPE_U_LITERALS)); - if (processOptions != null) { - forceTargetEscape = "true" - .equalsIgnoreCase(processOptions.get(OPTION_FORCE_JAVA8_LITERALS_ESCAPE)); - } + // BUGS#1264 + boolean forceTargetEscape = processOptions != null + && "true".equalsIgnoreCase(processOptions.get(OPTION_FORCE_JAVA8_LITERALS_ESCAPE)); + CharsetEncoder charsetEncoder = Charset.forName(getOutputEncoding(fc)).newEncoder(); boolean dontTranslateComment = processOptions != null && !"false".equalsIgnoreCase(processOptions.get(OPTION_DONT_TRANSLATE_COMMENT)); @@ -398,7 +396,7 @@ public void processFile(BufferedReader reader, BufferedWriter outfile, FilterCon // skipping comments int firstCp = trimmed.codePointAt(0); if (firstCp == '#' || firstCp == '!') { - outfile.write(toAscii(raw, EscapeMode.COMMENT)); + outfile.write(toAscii(raw, EscapeMode.COMMENT, charsetEncoder, forceTargetEscape)); outfile.write(lbpr.getLinebreak()); // Save the comments comments = (comments == null ? processed : comments + "\n" + processed); @@ -456,9 +454,9 @@ public void processFile(BufferedReader reader, BufferedWriter outfile, FilterCon if (noi18n && dontTranslateComment) { // if we don't need to internationalize - outfile.write(toAscii(key, EscapeMode.KEY)); + outfile.write(toAscii(key, EscapeMode.KEY, charsetEncoder, forceTargetEscape)); outfile.write(equals); - outfile.write(toAscii(value, EscapeMode.VALUE)); + outfile.write(toAscii(value, EscapeMode.VALUE, charsetEncoder, forceTargetEscape)); outfile.write(lbpr.getLinebreak()); noi18n = false; } else { @@ -474,14 +472,14 @@ public void processFile(BufferedReader reader, BufferedWriter outfile, FilterCon trans = value; } trans = trans.replaceAll("\\n\\s\\n", "\n\n"); - trans = toAscii(trans, EscapeMode.VALUE); + trans = toAscii(trans, EscapeMode.VALUE, charsetEncoder, forceTargetEscape); if (!trans.isEmpty() && trans.codePointAt(0) == ' ') { trans = '\\' + trans; } // Non-translated segments are written based on the // filter options if (translatedSegment || !removeStringsUntranslated) { - outfile.write(toAscii(key, EscapeMode.KEY)); + outfile.write(toAscii(key, EscapeMode.KEY, charsetEncoder, forceTargetEscape)); outfile.write(equals); outfile.write(trans); outfile.write(lbpr.getLinebreak()); // fix for bug diff --git a/test/data/filters/resourceBundle/file-ResourceBundleFilter-UnicodeEscaped.properties b/test/data/filters/resourceBundle/file-ResourceBundleFilter-UnicodeEscaped.properties new file mode 100644 index 0000000000..760a9f7285 --- /dev/null +++ b/test/data/filters/resourceBundle/file-ResourceBundleFilter-UnicodeEscaped.properties @@ -0,0 +1,2 @@ +# +Unicode=\u30E6\u30CB\u30B3\u30FC\u30C9 diff --git a/test/data/filters/resourceBundle/file-ResourceBundleFilter-UnicodeUTF8.properties b/test/data/filters/resourceBundle/file-ResourceBundleFilter-UnicodeUTF8.properties new file mode 100644 index 0000000000..a40ac93d5f --- /dev/null +++ b/test/data/filters/resourceBundle/file-ResourceBundleFilter-UnicodeUTF8.properties @@ -0,0 +1,2 @@ +# +Unicode=ユニコード diff --git a/test/src/org/omegat/filters/ResourceBundleFilterTest.java b/test/src/org/omegat/filters/ResourceBundleFilterTest.java index f6a16ad779..2d9f14b587 100644 --- a/test/src/org/omegat/filters/ResourceBundleFilterTest.java +++ b/test/src/org/omegat/filters/ResourceBundleFilterTest.java @@ -113,6 +113,48 @@ public void testDoNotEscapeUnicodeLiterals() throws Exception { translateText(filter, f, options); } + /** + * Test Unicode case. + * @throws Exception when error occurred. + */ + @Test + public void testNonEscapeUnicode() throws Exception { + String f = "test/data/filters/resourceBundle/file-ResourceBundleFilter-UnicodeUTF8.properties"; + ResourceBundleFilter filter = new ResourceBundleFilter(); + context.setOutEncoding("UTF-8"); + IProject.FileInfo fi = loadSourceFiles(filter, f); + + checkMultiStart(fi, f); + checkMulti("\u30E6\u30CB\u30B3\u30FC\u30C9", "Unicode", null, null, null, "#"); + checkMultiEnd(); + + translateText(filter, f); + } + + /** + * Test Unicode case, when the filter configured not to force escape + * and output encoding context is US-ASCII. + * Check loaded Unicode literals are in code points out of ASCII, + * then check the output file is escaped. + * @throws Exception when error occurred. + */ + @Test + public void testEscapeUnicodeWhenASCII() throws Exception { + String f = "test/data/filters/resourceBundle/file-ResourceBundleFilter-UnicodeEscaped.properties"; + ResourceBundleFilter filter = new ResourceBundleFilter(); + context.setOutEncoding("US-ASCII"); + Map options = new HashMap<>(); + options.put(ResourceBundleFilter.OPTION_DONT_UNESCAPE_U_LITERALS, "false"); + options.put(ResourceBundleFilter.OPTION_FORCE_JAVA8_LITERALS_ESCAPE, "false"); + IProject.FileInfo fi = loadSourceFiles(filter, f, options); + + checkMultiStart(fi, f); + checkMulti("\u30E6\u30CB\u30B3\u30FC\u30C9", "Unicode", null, null, null, "#"); + checkMultiEnd(); + + translateText(filter, f, options); + } + @Test public void testBadUnicodeLiterals() throws Exception { String base = "test/data/filters/resourceBundle/"; From 217a21a708326b6f9f39f244a2187d1f0eee3ead Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 24 Aug 2024 09:35:34 +0900 Subject: [PATCH 45/85] chore(deps): bump com.gradle.develocity from 3.17.6 to 3.18 (#1113) Bumps com.gradle.develocity from 3.17.6 to 3.18. --- updated-dependencies: - dependency-name: com.gradle.develocity dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 521f4bec9a..e39286362b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,6 @@ plugins { id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' - id 'com.gradle.develocity' version '3.17.6' + id 'com.gradle.develocity' version '3.18' } develocity { buildScan { From 7b20cce7ea040e33408642974ef98839fe5c3688 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 25 Aug 2024 22:51:19 +0900 Subject: [PATCH 46/85] chore: fix buid from source distribution (#1123) * chore: fix buid from source distribution - Fix a Build failure from sourceDistZip - It is because missing dependency from `lib/provided` - Also update removal of unused dependency - Fix test dependency for spellcheckers Signed-off-by: Hiroshi Miura * chore: fix missing modules in source dist Signed-off-by: Hiroshi Miura * chore: split srcDist lib/provided Source distribution has two provided libraries. One is for core and another is for modules. Signed-off-by: Hiroshi Miura * chore: tweak dependencies Signed-off-by: Hiroshi Miura * chore: tweak dependencies Signed-off-by: Hiroshi Miura * chore: fix sourceZip content - Add missing theme module Signed-off-by: Hiroshi Miura * chore: fix aligner dependency Signed-off-by: Hiroshi Miura * chore: tweak dependency Signed-off-by: Hiroshi Miura * chore: support language-module built from lib/provided libraries Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- aligner/build.gradle | 15 ++++-- build.gradle | 48 +++++++++-------- gradle/libs.versions.toml | 11 ++-- language-modules/build.gradle | 65 +++++++++++++++++++---- machinetranslators/apertium/build.gradle | 5 +- machinetranslators/belazar/build.gradle | 5 +- machinetranslators/deepl/build.gradle | 5 +- machinetranslators/google/build.gradle | 5 +- machinetranslators/ibmwatson/build.gradle | 5 +- machinetranslators/mymemory/build.gradle | 5 +- machinetranslators/yandex/build.gradle | 5 +- spellchecker/hunspell/build.gradle | 16 +++--- spellchecker/morfologik/build.gradle | 19 ++++--- theme/build.gradle | 4 +- tipoftheday/build.gradle | 16 ++++-- 15 files changed, 157 insertions(+), 72 deletions(-) diff --git a/aligner/build.gradle b/aligner/build.gradle index 5bc4a85ed7..4b41df8883 100644 --- a/aligner/build.gradle +++ b/aligner/build.gradle @@ -4,13 +4,18 @@ plugins { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, includes: ['**/commons-*.jar', '**/lib-mnemonics*.jar', - '**/maligna-*.jar', '**/supertmxmerge-*.jar', - '**/slf4j*']) + if (providedModuleLibsDir.directory) { + compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/commons-*.jar', '**/lib-mnemonics*.jar', + '**/slf4j*.jar', '**/supertmxmerge-*.jar', '**/jaxb-api*.jar']) + compileOnly fileTree(dir: providedModuleLibsDir, includes: ['**/maligna-*.jar']) } else { // Aligner - implementation(libs.loomchild.maligna) + implementation(libs.loomchild.maligna) { + exclude module: 'jaxb-api' + exclude module: 'jaxb-core' + exclude module: 'jaxb-runtime' + } + compileOnly(libs.jaxb.api) compileOnly(libs.madlonkay.supertmxmerge) compileOnly(libs.omegat.mnemonics) compileOnly(libs.commons.io) diff --git a/build.gradle b/build.gradle index 61c1bc0894..eebf926a62 100644 --- a/build.gradle +++ b/build.gradle @@ -49,7 +49,8 @@ ext { } } } - providedLibsDir = file('lib/provided') + providedCoreLibsDir = file('lib/provided/core') + providedModuleLibsDir = file('lib/provided/module') } def omtFlavor = omtVersion.beta.empty ? 'standard' : 'latest' def omtWebsite = 'https://omegat.org' @@ -223,14 +224,16 @@ configurations { genMac } -ext { - providedLibsDir = file('lib/provided') -} dependencies { // Libs are provided in the "source" distribution only - if (providedLibsDir.directory) { - implementation fileTree(dir: providedLibsDir, include: '**/*.jar', excludes: ['**/slf4j-api-1.*.jar']) + if (providedCoreLibsDir.directory) { + api fileTree(dir: providedCoreLibsDir, includes: ['**/slf4j-api-*.jar', '**/jaxb-api-*.jar']) + implementation fileTree(dir: providedCoreLibsDir, include: '**/*.jar', excludes: ['**/slf4j-api-*.jar', + '**/slf4j-jdk14-*.jar', 'language-detector-*.jar', '**/hunspell-*.jar', + '**/groovy*.jar', '**/jaxb-runtime-*.jar']) + runtimeOnly fileTree(dir: providedCoreLibsDir, includes: ['**/slf4j-jdk14-*.jar', + '**/language-detector-*.jar', '**/hunspell-*.jar', '**/groovy*.jar', '**/jaxb-runtime-*.jar']) } else { implementation(libs.commons.io) implementation(libs.commons.lang3) @@ -239,12 +242,17 @@ dependencies { implementation(libs.slf4j.format.jdk14) runtimeOnly(libs.slf4j.jdk14) + // jaxb gen compilation + implementation(libs.jaxb.api) + runtimeOnly(libs.jaxb.core) + runtimeOnly(libs.jaxb.runtime) + // macOS integration implementation(libs.madlonkay.desktopsupport) // stax implementation(libs.stax2.api) - runtimeOnly(libs.woodstox.core) + implementation(libs.woodstox.core) // Data: inline data URL handler implementation(libs.url.protocol.handler) @@ -269,15 +277,10 @@ dependencies { exclude module: 'guava' exclude module: 'language-detector' exclude group: 'com.google.android' + exclude module: 'hunspell' } - implementation(libs.language.detector) - - runtimeOnly(libs.languagetool.all) { - // Temporary exclusion; see https://sourceforge.net/p/omegat/bugs/814/ - exclude module: 'lucene-gosen' - exclude module: 'language-detector' - } - runtimeOnly 'org.omegat.lucene:lucene-gosen:5.5.1:ipadic' + runtimeOnly(libs.language.detector) + runtimeOnly(libs.dumont.hunspell) // Lucene for tokenizers implementation(libs.bundles.lucene) @@ -732,18 +735,21 @@ distributions { contents { from(rootDir) { include 'config/**', 'ci/iscc', 'ci/osslsigncode', 'images/**', 'lib/**', 'release/**', - 'src/**/*.java', 'test/**', 'test-integration/**', 'doc_src/**', 'docs_devel/**', 'scripts/**', - 'gradle/**', 'gradle*', 'build.gradle', 'settings.gradle', 'README.md', '*.properties', - 'tipoftheday/**', 'machinetranslators/**', 'scriptengine/**', 'LICENSE', 'compose.yml', - '.checkstyle' + 'src/**/*.java', 'test/**','test-acceptance/**', 'test-integration/**', 'doc_src/**', + 'docs_devel/**', 'scripts/**', + 'gradle/**', 'gradle*', 'build.gradle', 'settings.gradle', 'README.md', '*.properties', + 'tipoftheday/**', 'machinetranslators/**', 'scriptengine/**', 'LICENSE', 'compose.yml', + 'aligner/**', 'language-modules/**', 'spellchecker/**', 'theme/**', '.checkstyle' exclude '**/build/**', 'doc_src/**/pdf/**', 'doc_src/**/xhtml5/**', 'local.properties', '**/out/**' } from(processResources) { into('src') } - into('lib/provided') { - // collect project runtime dependencies in all subprojects and sourceSets + into('lib/provided/core') { from configurations.runtimeClasspath + } + into('lib/provided/module') { + // collect project runtime dependencies in all subprojects and sourceSets from {subprojects.findAll { it.getSubprojects().isEmpty()} .collect { it.configurations.matching { it.name.endsWith('untimeClasspath') && !it.name.startsWith('test') && !it.name.startsWith('jaxb') diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7a3b5a62e2..d2fc2f1401 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -45,13 +45,14 @@ stardict4j = "1.1.0" juniversalchardet = "2.5.0" mnemonics = "1.2" hunspell = "2.1.2" -xjc = "2.3.4" +xjc = "2.3.9" jna = "5.13.0" jfa = "1.2.0" tipoftheday = "0.4.4" flatlaf="3.5.1" assertj_swing_junit = "4.0.0-beta-1" morfologik = "2.1.9" +jaxb = "2.3.0" [libraries] slf4j-api = {group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j"} @@ -156,14 +157,17 @@ stardict4j = {group = "tokyo.northside", name = "stardict4j", version.ref = "sta juniversal-chardet = {group = "com.github.albfernandez", name = "juniversalchardet", version.ref = "juniversalchardet"} omegat-mnemonics = {group = "org.omegat", name = "lib-mnemonics", version.ref = "mnemonics"} dumont-hunspell = {group = "com.gitlab.dumonts", name = "hunspell", version.ref = "hunspell"} -jaxb-xjc = {group = "org.grassfish.jaxb", name = "jaxb-xjc", version.ref = "xjc"} +jaxb-api = {group = "javax.xml.bind", name = "jaxb-api", version.ref = "jaxb"} +jaxb-xjc = {group = "org.glassfish.jaxb", name = "jaxb-xjc", version.ref = "xjc"} +jaxb-core = {group = "org.glassfish.jaxb", name = "jaxb-core", version.ref = "jaxb"} +jaxb-runtime = {group = "org.glassfish.jaxb", name = "jaxb-runtime", version.ref = "jaxb"} tipoftheday = {group = "tokyo.northside", name = "tipoftheday", version.ref = "tipoftheday"} jna = {group = "net.java.dev.jna", name = "jna-platform", version.ref = "jna"} jfa = {group = "de.jangassen", name = "jfa", version.ref = "jfa"} flatlaf = {group = "com.formdev", name = "flatlaf", version.ref = "flatlaf"} language-detector = {group = "org.omegat", name = "language-detector", version.ref = "languagedetector"} assertj_swing_junit = {group = "tokyo.northside", name = "assertj-swing-junit", version.ref = "assertj_swing_junit"} -morfologik = { group = "org.carrot2", name = "morfologik-stemming", version.ref = "morfologik" } +morfologik-stemming = { group = "org.carrot2", name = "morfologik-stemming", version.ref = "morfologik" } morfologik-speller = { group = "org.carrot2", name = "morfologik-speller", version.ref = "morfologik" } [bundles] @@ -178,7 +182,6 @@ lucene = ["lucene-core", "lucene-analyzers-common", "lucene-analyzers-kuromoji", jgit = ["jgit", "jgit-agent", "jgit-http", "jgit-ssh"] dictionary = ["trie4j", "dsl4j", "stardict4j", "jsoup"] xmlunit = ["xmlunit-core", "xmlunit-assertj", "assertj"] -morfologik = ['morfologik', 'morfologik-speller'] [plugins] spotbugs = {id = "com.github.spotbugs", version = "6.0.19"} diff --git a/language-modules/build.gradle b/language-modules/build.gradle index d3a83e4195..b077f2a33c 100644 --- a/language-modules/build.gradle +++ b/language-modules/build.gradle @@ -37,17 +37,64 @@ plugins.forEach { args -> def pluginClass = "org.omegat.languages.${name}.${lang}Plugin" sourceSets.create(name) dependencies.add("${name}CompileOnly", project.rootProject) - dependencies.add("${name}CompileOnly", libs.languagetool.core) - if (name.equals("ja")) { - dependencies.jaImplementation(libs.languagetool.ja) { - // Temporary exclusion; see https://sourceforge.net/p/omegat/bugs/814/ - exclude module: 'lucene-gosen' - exclude module: 'languagetool-core' + dependencies.add("${name}CompileOnly", libs.languagetool.core) { + exclude module: "hunspell" + } + // when build from sourceZip + if (providedModuleLibsDir.directory) { + dependencies.add("${name}Implementation", fileTree(dir: providedModuleLibsDir, + include: "**/language-${name}-*.jar")) + if (name.equals("ja")) { + dependencies.jaImplementation(fileTree(dir: providedModuleLibsDir, + includes: ['**/lucene-gosen-*.jar', '**/icu4j-*.jar'])) + } else if (name.equals("en")) { + dependencies.add("enRuntimeOnly", fileTree(dir: providedModuleLibsDir, + includes: ['**/opennlp-*.jar'])) + } else if (name.equals("ca")) { + dependencies.add("caRuntimeOnly", fileTree(dir: providedModuleLibsDir, + include: '**/catalan-pos-dict-*.jar')) + } else if (name.equals("de")) { + dependencies.add("deRuntimeOnly", fileTree(dir: providedModuleLibsDir, + includes: ['**/commons-lang3-*.jar', '**/jwordsplitter-*.jar', '**/german-*.jar', '**/openregex-*.jar'])) + } else if (name.equals("el")) { + dependencies.add("elRuntimeOnly", fileTree(dir: providedModuleLibsDir, + include: '**/morphology-el-*.jar')) + } else if (name.equals("es")) { + dependencies.add("esRuntimeOnly", fileTree(dir: providedModuleLibsDir, + include: '**/spanish-pos-dict-*.jar')) + } else if (name.equals("fr")) { + dependencies.add("frRuntimeOnly", fileTree(dir: providedModuleLibsDir, include: '**/french-*.jar')) + } else if (name.equals("ga")) { + dependencies.add("gaRuntimeOnly", fileTree(dir: providedModuleLibsDir, + include: '**/languagetool-ga-dicts-*.jar')) + } else if (name.equals('pt')) { + dependencies.add("ptRuntimeOnly", fileTree(dir: providedModuleLibsDir, + include: '**/portuguese-pos-dict-*.jar')) + } else if (name.equals("ru")) { + dependencies.add("ruRuntimeOnly", fileTree(dir: providedModuleLibsDir, + include: '**/openregex-*.jar')) + } else if (name.equals("uk")) { + dependencies.add("ukRuntimeOnly", fileTree(dir: providedModuleLibsDir, + include: '**/morfologik-ukrainian-*.jar')) + } else if (name.equals("zh")) { + dependencies.add("zhRuntimeOnly", fileTree(dir: providedModuleLibsDir, + include: '**/hanlp-portable-*.jar')) } - dependencies.jaImplementation(dependencies.variantOf(libs.lucene.gosen){ classifier("ipadic") }) } else { - dependencies.add("${name}Implementation", libs.languagetool.getAt(name)) { - exclude module: 'languagetool-core' + // build from project git repository + if (name.equals("ja")) { + dependencies.jaImplementation(libs.languagetool.ja) { + // Temporary exclusion; see https://sourceforge.net/p/omegat/bugs/814/ + exclude module: 'lucene-gosen' + exclude module: 'languagetool-core' + exclude module: 'icu4j' + } + dependencies.jaImplementation(dependencies.variantOf(libs.lucene.gosen) { classifier("ipadic") }) + dependencies.jaImplementation(libs.icj4j) + } else { + dependencies.add("${name}Implementation", libs.languagetool.getAt(name)) { + exclude module: 'languagetool-core' + } } } configurations.getByName("${name}RuntimeClasspath").exclude(module: 'languagetool-core') diff --git a/machinetranslators/apertium/build.gradle b/machinetranslators/apertium/build.gradle index 88c275d7c6..a24feb2af5 100644 --- a/machinetranslators/apertium/build.gradle +++ b/machinetranslators/apertium/build.gradle @@ -8,8 +8,9 @@ plugins { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, includes: ['**/*commons-*.jar', '**/jackson*.jar']) + if (providedCoreLibsDir.directory) { + compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/*commons-*.jar', '**/slf4j*.jar', + '**/jackson*.jar']) } else { compileOnly(libs.commons.io) compileOnly(libs.commons.text) diff --git a/machinetranslators/belazar/build.gradle b/machinetranslators/belazar/build.gradle index c500cd7c32..f2863ac962 100644 --- a/machinetranslators/belazar/build.gradle +++ b/machinetranslators/belazar/build.gradle @@ -8,8 +8,9 @@ plugins { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, includes: ['**/*commons-*.jar', '**/jackson*.jar']) + if (providedCoreLibsDir.directory) { + compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/*commons-*.jar', '**/slf4j*.jar', + '**/jackson*.jar']) } else { compileOnly(libs.commons.io) compileOnly(libs.commons.text) diff --git a/machinetranslators/deepl/build.gradle b/machinetranslators/deepl/build.gradle index 4e91837dda..301cdee739 100644 --- a/machinetranslators/deepl/build.gradle +++ b/machinetranslators/deepl/build.gradle @@ -8,8 +8,9 @@ plugins { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, includes: ['**/*commons-*.jar', '**/jackson*.jar']) + if (providedCoreLibsDir.directory) { + compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/*commons-*.jar', '**/slf4j*.jar', + '**/jackson*.jar']) } else { compileOnly(libs.commons.io) compileOnly(libs.commons.text) diff --git a/machinetranslators/google/build.gradle b/machinetranslators/google/build.gradle index db1b910f3c..d726044ea7 100644 --- a/machinetranslators/google/build.gradle +++ b/machinetranslators/google/build.gradle @@ -8,8 +8,9 @@ plugins { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, includes: ['**/*commons-*.jar', '**/jackson*.jar']) + if (providedCoreLibsDir.directory) { + compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/*commons-*.jar', '**/slf4j*.jar', + '**/jackson*.jar']) } else { compileOnly(libs.commons.io) compileOnly(libs.commons.text) diff --git a/machinetranslators/ibmwatson/build.gradle b/machinetranslators/ibmwatson/build.gradle index 3b2832409a..141dc45e16 100644 --- a/machinetranslators/ibmwatson/build.gradle +++ b/machinetranslators/ibmwatson/build.gradle @@ -8,8 +8,9 @@ plugins { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, includes: ['**/*commons-*.jar', '**/jackson*.jar']) + if (providedCoreLibsDir.directory) { + compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/*commons-*.jar', '**/slf4j*.jar', + '**/jackson*.jar']) } else { compileOnly(libs.commons.io) compileOnly(libs.commons.text) diff --git a/machinetranslators/mymemory/build.gradle b/machinetranslators/mymemory/build.gradle index 58a9c16a1c..a93f5a0666 100644 --- a/machinetranslators/mymemory/build.gradle +++ b/machinetranslators/mymemory/build.gradle @@ -8,8 +8,9 @@ plugins { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, includes: ['**/*commons-*.jar', '**/jackson*.jar']) + if (providedCoreLibsDir.directory) { + compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/*commons-*.jar', '**/slf4j*.jar', + '**/jackson*.jar']) } else { compileOnly(libs.commons.io) compileOnly(libs.commons.text) diff --git a/machinetranslators/yandex/build.gradle b/machinetranslators/yandex/build.gradle index 464035bf65..5602e48f2f 100644 --- a/machinetranslators/yandex/build.gradle +++ b/machinetranslators/yandex/build.gradle @@ -8,8 +8,9 @@ plugins { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, includes: ['**/*commons-*.jar', '**/jackson*.jar']) + if (providedCoreLibsDir.directory) { + compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/*commons-*.jar', '**/slf4j*.jar', + '**/jackson*.jar']) } else { compileOnly(libs.commons.io) compileOnly(libs.commons.text) diff --git a/spellchecker/hunspell/build.gradle b/spellchecker/hunspell/build.gradle index 3404bd1ab4..604f536c1a 100644 --- a/spellchecker/hunspell/build.gradle +++ b/spellchecker/hunspell/build.gradle @@ -4,27 +4,31 @@ plugins { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, includes: ['**/commons-io-*.jar', - '**/lib-mnemonics-*.jar', - '**/slf4j-format-jdk14-*.jar']) - implementation fileTree(dir: providedLibsDir, includes: ['**/hunspell-*.jar']) + if (providedCoreLibsDir.directory) { + compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/languagetool-core-*.jar', + '**/commons-io-*.jar', '**/lib-mnemonics-*.jar', '**/slf4j-format-jdk14-*.jar', + '**/hunspell-*.jar']) } else { compileOnly(libs.commons.io) compileOnly(libs.omegat.mnemonics) compileOnly(libs.slf4j.format.jdk14) - implementation(libs.dumont.hunspell) compileOnly(libs.languagetool.core) { exclude module: 'guava' + exclude module: 'language-detector' + exclude group: 'com.google.android' exclude module: 'jackson-databind' exclude group: 'org.jetbrains' } + // hunspell is in dependency of languagetool-core + // and usable in OmegaT-core libraries + // implementation(libs.dumont.hunspell) } testImplementation(libs.junit4) testImplementation(libs.assertj) testImplementation(testFixtures(project.rootProject)) testImplementation(libs.commons.io) testRuntimeOnly(libs.languagetool.en) + testRuntimeOnly(libs.languagetool.de) } jar { diff --git a/spellchecker/morfologik/build.gradle b/spellchecker/morfologik/build.gradle index d354a490fd..f4ff3acf4b 100644 --- a/spellchecker/morfologik/build.gradle +++ b/spellchecker/morfologik/build.gradle @@ -4,26 +4,33 @@ plugins { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, includes: ['**/commons-io-*.jar', - '**/lib-mnemonics-*.jar', - '**/slf4j-format-jdk14-*.jar']) - implementation fileTree(dir: providedLibsDir, includes: ['**/morfologik-*.jar']) + if (providedModuleLibsDir.directory) { + compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/commons-*.jar', '**/languagetool-core-*.jar', + '**/lib-mnemonics-*.jar', '**/slf4j-format-jdk14-*.jar', '**/morfologik-*.jar']) + implementation fileTree(dir: providedModuleLibsDir, includes: ['**/morfologik-*.jar']) } else { + // morfologik stemming and speller are dependency of languagetool-core + compileOnly(libs.morfologik.stemming) + compileOnly(libs.morfologik.speller) compileOnly(libs.commons.io) compileOnly(libs.omegat.mnemonics) compileOnly(libs.slf4j.format.jdk14) compileOnly(libs.languagetool.core) { exclude module: 'guava' exclude module: 'jackson-databind' + exclude module: 'language-detector' + exclude module: 'hunspell' + exclude group: 'com.google.android' exclude group: 'org.jetbrains' + exclude module: 'morfologik-fsa' } - implementation(libs.bundles.morfologik) } testImplementation(libs.junit4) testImplementation(libs.assertj) testImplementation(testFixtures(project.rootProject)) testImplementation(libs.commons.io) + testRuntimeOnly(libs.languagetool.en) + testRuntimeOnly(libs.languagetool.de) } jar { diff --git a/theme/build.gradle b/theme/build.gradle index 2657312fda..bbe1d6de77 100644 --- a/theme/build.gradle +++ b/theme/build.gradle @@ -4,8 +4,8 @@ plugins { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, include: '**/flatlaf*.jar') + if (providedModuleLibsDir.directory) { + compileOnly fileTree(dir: providedModuleLibsDir, include: '**/flatlaf*.jar') } else { // platform independent dark theme implementation(libs.flatlaf) diff --git a/tipoftheday/build.gradle b/tipoftheday/build.gradle index 92cc07dd1d..b2159b1927 100644 --- a/tipoftheday/build.gradle +++ b/tipoftheday/build.gradle @@ -18,16 +18,22 @@ sourceSets { dependencies { compileOnly(project.rootProject) - if (providedLibsDir.directory) { - compileOnly fileTree(dir: providedLibsDir, includes: ['**/jackson*.jar']) - implementation fileTree(dir: providedLibsDir, includes: ['**/tipoftheday-*.jar']) + if (providedCoreLibsDir.directory) { + compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/commons-lang3-*.jar', '**/jackson*.jar', + '**/icu4j-*.jar']) + implementation fileTree(dir: providedModuleLibsDir, includes: ['**/tipoftheday-*.jar']) } else { // runtime dependencies should be in main project - implementation(libs.tipoftheday) + implementation(libs.tipoftheday) { + exclude module: 'commons-lang3' + exclude module: 'commons-io' + } + compileOnly(libs.commons.lang3) constraints { implementation(libs.icj4j) } - implementation(libs.jackson.yaml) + // jackson-databind-yaml is dependency of languagetool-core + compileOnly(libs.jackson.yaml) } testImplementation(testFixtures(project.rootProject)) testImplementation(libs.commons.io) From 2f0086d3d6f66f2795aa42d224c7dbb9e9023c8c Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 25 Aug 2024 22:51:59 +0900 Subject: [PATCH 47/85] chore: add unescape diff tool (#1106) Developers can use the unescaped diff tool by configurating git like ```bash git config difftool.udiff.cmd 'config/git/udiff.sh $LOCAL $REMOTE' git config alias.udiff 'difftool --tool=udiff' ``` then developers can run like ```bash git udiff src/org/omegat/Bundle_(lang).properties ``` Developers and localizers happily see a diff with native languages. Signed-off-by: Hiroshi Miura --- config/git/udiff.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 config/git/udiff.sh diff --git a/config/git/udiff.sh b/config/git/udiff.sh new file mode 100755 index 0000000000..9cd47664b2 --- /dev/null +++ b/config/git/udiff.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Unescape Unicode sequences in a properties file +unescape() { + perl -CSD -Mopen=':std,:utf8' -pe 's/\\u([0-9a-fA-F]{4})/chr(hex($1))/eg' "$1" +} + +# Create temporary files for the unescaped content +LOCAL=$(mktemp) +REMOTE=$(mktemp) + +# Perform the unescaping +unescape "$1" > "$LOCAL" +unescape "$2" > "$REMOTE" + +# Run diff with unescaped content +diff --unified=3 --ignore-case --color=always "$LOCAL" "$REMOTE" | less --raw-control-chars + +# Clean up temporary files +rm -f "$LOCAL" "$REMOTE" + From f511072df0eb3475a6f2d88c4b29c5a6d7e7844a Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Mon, 26 Aug 2024 12:25:04 +0900 Subject: [PATCH 48/85] fix: LTmod: typo of en-AU class name Signed-off-by: Hiroshi Miura --- .../src/en/java/org/omegat/languages/en/EnglishPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language-modules/src/en/java/org/omegat/languages/en/EnglishPlugin.java b/language-modules/src/en/java/org/omegat/languages/en/EnglishPlugin.java index 9fe003ee4e..f994a485ce 100644 --- a/language-modules/src/en/java/org/omegat/languages/en/EnglishPlugin.java +++ b/language-modules/src/en/java/org/omegat/languages/en/EnglishPlugin.java @@ -35,7 +35,7 @@ public final class EnglishPlugin { private static final String AMERICAN_ENGLISH = "org.languagetool.language.AmericanEnglish"; private static final String BRITISH_ENGLISH = "org.languagetool.language.BritishEnglish"; private static final String CANADIAN_ENGLISH = "org.languagetool.language.CanadianEnglish"; - private static final String AUSTRALIAN_ENGLISH = "org.languagetool.language.AUSTRARLANEnglish"; + private static final String AUSTRALIAN_ENGLISH = "org.languagetool.language.AustralianEnglish"; private EnglishPlugin() { } From 95b02ff3534e902175d71b4478c99e492714817c Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Tue, 27 Aug 2024 16:55:11 +0900 Subject: [PATCH 49/85] fix: LTmod's IllegalArgument on en-AU (#1125) * fix: LTmod's IllegalArgument on en-AU - When loading "en-AU" LT language, it failed with IllegalArgumentException because of missing "en-US". - Fix BUG#1265 Failed to load "en-AU" LT language by IllegalArgumentException Signed-off-by: Hiroshi Miura * refactor: move language-ja specific test in language-modules subproject Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- build.gradle | 13 ++----- language-modules/build.gradle | 23 ++++++++++-- .../test}/LuceneGosenCompatibilityTest.java | 23 +++++++++--- .../omegat/languagetools/LanguageManager.java | 35 ++++++++++++++++--- 4 files changed, 72 insertions(+), 22 deletions(-) rename {test/src/org/omegat/languagetools => language-modules/src/test/java/org/omegat/languages/test}/LuceneGosenCompatibilityTest.java (76%) diff --git a/build.gradle b/build.gradle index eebf926a62..bc07f29200 100644 --- a/build.gradle +++ b/build.gradle @@ -353,16 +353,9 @@ dependencies { testImplementation(libs.assertj) testImplementation(libs.bundles.xmlunit) - // LanguageTool unit tests exercise these languages - testImplementation(libs.bundles.languagetool.tests) { - exclude group: 'org.slf4j' - exclude module: 'guava' - exclude module: 'language-detector' - exclude group: 'ch.qos.logback' - // Temporary exclusion; see https://sourceforge.net/p/omegat/bugs/814/ - exclude module: 'lucene-gosen' - } - testImplementation(variantOf(libs.lucene.gosen){ classifier("ipadic") }) + + testImplementation(project(":language-modules")) + testImplementation(libs.languagetool.server) testRuntimeOnly(libs.slf4j.jdk14) // JAXB codegen only diff --git a/language-modules/build.gradle b/language-modules/build.gradle index b077f2a33c..4459dcdb3a 100644 --- a/language-modules/build.gradle +++ b/language-modules/build.gradle @@ -1,4 +1,4 @@ -def plugins = [ +def moduleList = [ [ code: 'ar', lang: 'Arabic'], [ code: 'ast', lang: 'Asturian'], [ code: 'be', lang: 'Belarusian'], @@ -31,7 +31,7 @@ def plugins = [ [ code: 'zh', lang: 'Chinese'] ] -plugins.forEach { args -> +moduleList.forEach { args -> def name = args.get('code') def lang = args.get('lang') def pluginClass = "org.omegat.languages.${name}.${lang}Plugin" @@ -130,3 +130,22 @@ plugins.forEach { args -> } tasks.getByName("checkstyleMain").dependsOn tasks.named("checkstyle${capitalName}") } + +dependencies { + testImplementation(libs.junit4) + testRuntimeOnly(libs.slf4j.jdk14) + testImplementation(project.rootProject) + + testCompileOnly(dependencies.variantOf(libs.lucene.gosen) { classifier("ipadic") }) + testImplementation(libs.languagetool.core) { + exclude module: 'language-all' + } + testRuntimeOnly(libs.languagetool.ja) { + // Temporary exclusion; see https://sourceforge.net/p/omegat/bugs/814/ + exclude module: 'lucene-gosen' + exclude module: 'languagetool-core' + exclude module: 'icu4j' + } + testRuntimeOnly(dependencies.variantOf(libs.lucene.gosen) { classifier("ipadic") }) + testRuntimeOnly(libs.icj4j) +} diff --git a/test/src/org/omegat/languagetools/LuceneGosenCompatibilityTest.java b/language-modules/src/test/java/org/omegat/languages/test/LuceneGosenCompatibilityTest.java similarity index 76% rename from test/src/org/omegat/languagetools/LuceneGosenCompatibilityTest.java rename to language-modules/src/test/java/org/omegat/languages/test/LuceneGosenCompatibilityTest.java index 7ed786f92f..2d35ea2cbf 100644 --- a/test/src/org/omegat/languagetools/LuceneGosenCompatibilityTest.java +++ b/language-modules/src/test/java/org/omegat/languages/test/LuceneGosenCompatibilityTest.java @@ -23,7 +23,7 @@ * along with this program. If not, see . */ -package org.omegat.languagetools; +package org.omegat.languages.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -34,16 +34,28 @@ import net.java.sen.SenFactory; import net.java.sen.StringTagger; - +import org.junit.BeforeClass; import org.junit.Test; - import org.languagetool.JLanguageTool; -import org.languagetool.Languages; +import org.languagetool.Language; import org.languagetool.rules.RuleMatch; import org.languagetool.rules.patterns.PatternRule; +import org.omegat.languagetools.LanguageDataBroker; +import org.omegat.languagetools.LanguageManager; + public class LuceneGosenCompatibilityTest { + private static final String JAPANESE = "org.languagetool.language.Japanese"; + + @BeforeClass + public static void setUpClass() { + // We don't use plugin loader in a test context + // JLanguageTool.setClassBrokerBroker(new LanguageClassBroker()); + JLanguageTool.setDataBroker(new LanguageDataBroker()); + LanguageManager.registerLTLanguage("ja-JP", JAPANESE); + } + /** * Regression test for bugs#1204. * @@ -57,7 +69,8 @@ public void testLuceneGosenGetStringTagger6() { @Test public void testJapanese() throws Exception { - JLanguageTool lt = new JLanguageTool(Objects.requireNonNull(Languages.getLanguageForName("Japanese"))); + Language lang = LanguageManager.getLTLanguage(new org.omegat.util.Language("ja-JP")); + JLanguageTool lt = new JLanguageTool(Objects.requireNonNull(lang)); List matches = lt.check("そんじゃそこらのやつらとは違う"); assertEquals(1, matches.size()); assertTrue(matches.get(0).getRule() instanceof PatternRule); diff --git a/src/org/omegat/languagetools/LanguageManager.java b/src/org/omegat/languagetools/LanguageManager.java index 9ea3185ee9..fb008773ff 100644 --- a/src/org/omegat/languagetools/LanguageManager.java +++ b/src/org/omegat/languagetools/LanguageManager.java @@ -44,18 +44,39 @@ public static void registerLTLanguage(String lang, String fqcn) { LT_LANGUAGE_CLASSES.put(lang, fqcn); } - static Language getLTLanguage(org.omegat.util.Language lang) { + /** + * Get LanguageTool language. + *

+ * This code made side effect to load LT modules eventually. + * It loads a specified language-country. + * It also loads a variant of countries, such as "en-US" for "en-AU". + * And also it loads language code module such as "en". + * It is because some language definition depends on another language, + * for example, en-AU depends on en-US. + * When loading only en-AU language module class, it failed to load + * with an error, not-found "en-US". + *

+ * @param lang OmegaT language code. + * @return LanguageTool's Language object. + */ + public static Language getLTLanguage(org.omegat.util.Language lang) { + Language result = null; if (lang == null) { return null; } + // search for language-country code. String fqcn = LT_LANGUAGE_CLASSES.get(lang.getLanguage()); if (fqcn != null) { - return Languages.getOrAddLanguageByClassName(fqcn); + result = Languages.getOrAddLanguageByClassName(fqcn); } // Search for language code fqcn = LT_LANGUAGE_CLASSES.get(lang.getLanguageCode()); if (fqcn != null) { - return Languages.getOrAddLanguageByClassName(fqcn); + // when exists, load it. + Language language = Languages.getOrAddLanguageByClassName(fqcn); + if (result == null) { + result = language; + } } // Search for just language code match but allow country difference String languageCode; @@ -66,10 +87,14 @@ static Language getLTLanguage(org.omegat.util.Language lang) { languageCode = entry.getKey(); } if (languageCode.equals(lang.getLanguageCode())) { - return Languages.getOrAddLanguageByClassName(entry.getValue()); + // when exists, load it. + Language language = Languages.getOrAddLanguageByClassName(entry.getValue()); + if (result == null) { + result = language; + } } } - return null; + return result; } static Language getLTLanguage() { From 16251e379a0083d7eee149854941727607a99601 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:38:14 +0900 Subject: [PATCH 50/85] chore(deps): bump com.github.spotbugs from 6.0.19 to 6.0.21 (#1130) Bumps com.github.spotbugs from 6.0.19 to 6.0.21. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d2fc2f1401..6795e352d2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -184,7 +184,7 @@ dictionary = ["trie4j", "dsl4j", "stardict4j", "jsoup"] xmlunit = ["xmlunit-core", "xmlunit-assertj", "assertj"] [plugins] -spotbugs = {id = "com.github.spotbugs", version = "6.0.19"} +spotbugs = {id = "com.github.spotbugs", version = "6.0.21"} spotless = {id = "com.diffplug.spotless", version = "6.25.0"} launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.6"} versions = {id = "com.github.ben-manes.versions", version = "0.51.0"} From 0934ed1e3a578d233cc5d43b2c0c1f1bb6c11297 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 31 Aug 2024 19:34:40 +0900 Subject: [PATCH 51/85] Removal of MED package feature (#1131) - resolve BUGS#1266 Removal of MED package save/load feature Signed-off-by: Hiroshi Miura --- .../omegat/gui/main/BaseMainWindowMenu.java | 10 +- .../gui/main/MainWindowMenuHandler.java | 14 -- .../omegat/gui/main/ProjectUICommands.java | 132 ------------------ src/org/omegat/util/gui/MenuExtender.java | 2 +- 4 files changed, 2 insertions(+), 156 deletions(-) diff --git a/src/org/omegat/gui/main/BaseMainWindowMenu.java b/src/org/omegat/gui/main/BaseMainWindowMenu.java index 5048808df5..02ff13faeb 100644 --- a/src/org/omegat/gui/main/BaseMainWindowMenu.java +++ b/src/org/omegat/gui/main/BaseMainWindowMenu.java @@ -224,8 +224,6 @@ protected void createComponents() { projectCommitTargetFiles = createMenuItem("TF_MENU_FILE_TARGET"); projectCompileMenuItem = createMenuItem("TF_MENU_FILE_COMPILE"); projectSingleCompileMenuItem = createMenuItem("TF_MENU_FILE_SINGLE_COMPILE"); - projectMedOpenMenuItem = createMenuItem("TF_MENU_FILE_MED_OPEN"); - projectMedCreateMenuItem = createMenuItem("TF_MENU_FILE_MED_CREATE"); projectEditMenuItem = createMenuItem("MW_PROJECTMENU_EDIT"); viewFileListMenuItem = createMenuItem("TF_MENU_FILE_PROJWIN"); @@ -446,9 +444,6 @@ protected void constructMenu() { projectMenu.add(projectCompileMenuItem); projectMenu.add(projectSingleCompileMenuItem); projectMenu.addSeparator(); - projectMenu.add(projectMedOpenMenuItem); - projectMenu.add(projectMedCreateMenuItem); - projectMenu.addSeparator(); projectMenu.add(projectEditMenuItem); projectMenu.add(viewFileListMenuItem); projectMenu.add(projectAccessProjectFilesMenu); @@ -827,12 +822,11 @@ protected void setActionCommands() { protected void onProjectStatusChanged(final boolean isProjectOpened) { JMenuItem[] itemsToSwitchOff = new JMenuItem[] { projectNewMenuItem, projectTeamNewMenuItem, - projectOpenMenuItem, projectMedOpenMenuItem }; + projectOpenMenuItem }; JMenuItem[] itemsToSwitchOn = new JMenuItem[] { projectImportMenuItem, projectWikiImportMenuItem, projectReloadMenuItem, projectCloseMenuItem, projectSaveMenuItem, projectEditMenuItem, projectCompileMenuItem, projectSingleCompileMenuItem, projectAccessProjectFilesMenu, - projectMedCreateMenuItem, editMenu, editFindInProjectMenuItem, editReplaceInProjectMenuItem, editInsertSourceMenuItem, editInsertTranslationMenuItem, editTagPainterMenuItem, editOverwriteSourceMenuItem, @@ -1081,8 +1075,6 @@ public JMenu getMenu(MenuExtender.MenuKey marker) { JMenuItem projectCommitTargetFiles; JMenuItem projectCompileMenuItem; JMenuItem projectSingleCompileMenuItem; - JMenuItem projectMedOpenMenuItem; - JMenuItem projectMedCreateMenuItem; JMenuItem projectEditMenuItem; JMenuItem projectExitMenuItem; JMenuItem projectRestartMenuItem; diff --git a/src/org/omegat/gui/main/MainWindowMenuHandler.java b/src/org/omegat/gui/main/MainWindowMenuHandler.java index 400e209760..c61e3c0722 100644 --- a/src/org/omegat/gui/main/MainWindowMenuHandler.java +++ b/src/org/omegat/gui/main/MainWindowMenuHandler.java @@ -129,20 +129,6 @@ public void projectClearRecentMenuItemActionPerformed() { RecentProjects.clear(); } - /** - * Open MED project. - */ - public void projectMedOpenMenuItemActionPerformed() { - ProjectUICommands.projectOpenMED(); - } - - /** - * Create MED project. - */ - public void projectMedCreateMenuItemActionPerformed() { - ProjectUICommands.projectCreateMED(); - } - /** * Imports the file/files/folder into project's source files. */ diff --git a/src/org/omegat/gui/main/ProjectUICommands.java b/src/org/omegat/gui/main/ProjectUICommands.java index 69ac9eb506..bf86afcaaa 100644 --- a/src/org/omegat/gui/main/ProjectUICommands.java +++ b/src/org/omegat/gui/main/ProjectUICommands.java @@ -41,7 +41,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import java.util.Locale; import java.util.concurrent.ExecutionException; import javax.swing.JFileChooser; @@ -69,7 +68,6 @@ import org.omegat.core.team2.RemoteRepositoryProvider; import org.omegat.filters2.master.FilterMaster; import org.omegat.filters2.master.PluginUtils; -import org.omegat.gui.dialogs.ChooseMedProject; import org.omegat.gui.dialogs.FileCollisionDialog; import org.omegat.gui.dialogs.NewProjectFileChooser; import org.omegat.gui.dialogs.NewTeamProjectController; @@ -173,136 +171,6 @@ protected Void doInBackground() throws Exception { }.execute(); } - public static void projectOpenMED() { - UIThreadsUtil.mustBeSwingThread(); - - if (Core.getProject().isProjectLoaded()) { - return; - } - - // ask for MED file - ChooseMedProject ndm = new ChooseMedProject(); - int ndmResult = ndm.showOpenDialog(Core.getMainWindow().getApplicationFrame()); - if (ndmResult != OmegaTFileChooser.APPROVE_OPTION) { - // user press 'Cancel' in project creation dialog - return; - } - final File med = ndm.getSelectedFile(); - - // ask for new project dir - NewProjectFileChooser ndc = new NewProjectFileChooser(); - int ndcResult = ndc.showSaveDialog(Core.getMainWindow().getApplicationFrame()); - if (ndcResult != OmegaTFileChooser.APPROVE_OPTION) { - // user press 'Cancel' in project creation dialog - return; - } - final File dir = ndc.getSelectedFile(); - if (!ensureProjectDir(dir)) { - return; - } - - new SwingWorker() { - protected Void doInBackground() throws Exception { - - final ProjectProperties newProps = new ProjectProperties(dir); - ProjectMedProcessing.extractFromMed(med, newProps); - // create project - try { - ProjectFactory.createProject(newProps); - RecentProjects.add(dir.getAbsolutePath()); - } catch (Exception ex) { - Log.logErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"); - Core.getMainWindow().displayErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"); - } - - return null; - } - - protected void done() { - try { - get(); - SwingUtilities.invokeLater(Core.getEditor()::requestFocus); - } catch (Exception ex) { - Log.logErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"); - Core.getMainWindow().displayErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"); - } - } - }.execute(); - } - - public static void projectCreateMED() { - UIThreadsUtil.mustBeSwingThread(); - - if (!Core.getProject().isProjectLoaded()) { - return; - } - - // commit the current entry first - Core.getEditor().commitAndLeave(); - - // ask for new MED file - ChooseMedProject ndm = new ChooseMedProject(); - // default name - String zipName = null; - try { - File origin = ProjectMedProcessing.getOriginMedFile(Core.getProject().getProjectProperties()); - if (origin != null) { - zipName = origin.getName(); - } - } catch (Exception ignored) { - } - if (zipName == null) { - zipName = Core.getProject().getProjectProperties().getProjectName() + "-MED.zip"; - } - ndm.setSelectedFile(new File( - Core.getProject().getProjectProperties().getProjectRootDir().getParentFile(), zipName)); - int ndmResult = ndm.showSaveDialog(Core.getMainWindow().getApplicationFrame()); - if (ndmResult != OmegaTFileChooser.APPROVE_OPTION) { - // user press 'Cancel' in project creation dialog - return; - } - // add .zip extension if there is no - final File med = ndm.getSelectedFile().getName().toLowerCase(Locale.ENGLISH).endsWith(".zip") - ? ndm.getSelectedFile() - : new File(ndm.getSelectedFile().getAbsolutePath() + ".zip"); - - new SwingWorker() { - protected Void doInBackground() throws Exception { - IMainWindow mainWindow = Core.getMainWindow(); - Cursor hourglassCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); - Cursor oldCursor = mainWindow.getCursor(); - mainWindow.setCursor(hourglassCursor); - - mainWindow.showStatusMessageRB("MW_STATUS_SAVING"); - - Core.executeExclusively(true, () -> { - Core.getProject().saveProject(true); - try { - Core.getProject().compileProject(".*"); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - }); - - ProjectMedProcessing.createMed(med, Core.getProject().getProjectProperties()); - - mainWindow.showStatusMessageRB("MW_STATUS_SAVED"); - mainWindow.setCursor(oldCursor); - return null; - } - - protected void done() { - try { - get(); - SwingUtilities.invokeLater(Core.getEditor()::requestFocus); - } catch (Exception ex) { - Log.logErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"); - Core.getMainWindow().displayErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE"); - } - } - }.execute(); - } - public static void projectTeamCreate() { UIThreadsUtil.mustBeSwingThread(); diff --git a/src/org/omegat/util/gui/MenuExtender.java b/src/org/omegat/util/gui/MenuExtender.java index 97d6f79df9..3e83b05884 100644 --- a/src/org/omegat/util/gui/MenuExtender.java +++ b/src/org/omegat/util/gui/MenuExtender.java @@ -42,7 +42,7 @@ public enum MenuKey { /** * Project menu. */ - PROJECT("project", 21), + PROJECT("project", 18), /** * Edit menu. */ From f934c9052e4096f354db69cbf82503fdb1baa303 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 1 Sep 2024 15:32:21 +0900 Subject: [PATCH 52/85] docs: update changes.txt Signed-off-by: Hiroshi Miura --- release/changes.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/release/changes.txt b/release/changes.txt index d0ed5e8bff..31aa6da7ba 100644 --- a/release/changes.txt +++ b/release/changes.txt @@ -2,7 +2,7 @@ OmegaT 6.1.0 ---------------------------------------------------------------------- 45 Enhancement - 70 Bug fixes + 72 Bug fixes 5 Localisation updates ---------------------------------------------------------------------- 6.1.0 vs 6.0.0 @@ -166,12 +166,18 @@ - Windows launcher does not launch when witout_JRE installer used https://sourceforge.net/p/omegat/bugs/1240/ + - Glossary popups behavior changed unintended way + https://sourceforge.net/p/omegat/bugs/1239/ + - OmegaT does not use cached MT result for translated segments https://sourceforge.net/p/omegat/bugs/1238/ - Match statistics are affected by fuzzy match threshold https://sourceforge.net/p/omegat/bugs/1236/ + - PluginInstaller throws NPE in certain condition + https://sourceforge.net/p/omegat/bugs/1235/ + - Issue window cause exception https://sourceforge.net/p/omegat/bugs/1234/ From 50ff299ad6961c12c9c9b310c509882244b376ef Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 1 Sep 2024 15:34:41 +0900 Subject: [PATCH 53/85] docs: update changes.txt Signed-off-by: Hiroshi Miura --- release/changes.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/release/changes.txt b/release/changes.txt index 31aa6da7ba..9a24463989 100644 --- a/release/changes.txt +++ b/release/changes.txt @@ -2,7 +2,7 @@ OmegaT 6.1.0 ---------------------------------------------------------------------- 45 Enhancement - 72 Bug fixes + 73 Bug fixes 5 Localisation updates ---------------------------------------------------------------------- 6.1.0 vs 6.0.0 @@ -139,6 +139,9 @@ Bug fixes: + - Removal of MED package save/load feature + https://sourceforge.net/p/omegat/bugs/1266/ + - filter: bundle: when charsert configuration is US_ASCII, force unicode escape https://sourceforge.net/p/omegat/bugs/1264/ From 223517c730ae1a879efd7918b92a7e0e5c2487a0 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 5 Sep 2024 22:11:36 +0900 Subject: [PATCH 54/85] docs: update developer manual (#1116) * docs: update developer manual Update release procedure to reflect recent CI/CD updates Signed-off-by: Hiroshi Miura * Revise English in Update 90.ReleaseProcedure.md I've made a few changes to the phrasing that stood out the most. Let me know if anything doesn't match the intended meaning. * chore: move JRE bundle definition on the start of build.gradle Signed-off-by: Hiroshi Miura * docs: fix JRE reference in release procedure Signed-off-by: Hiroshi Miura * Minor phrasing tweaks to Update 90.ReleaseProcedure.md Just one or two more small things that caught my eye. --------- Signed-off-by: Hiroshi Miura Co-authored-by: kazephil --- build.gradle | 31 +++-- docs_devel/docs/90.ReleaseProcedure.md | 150 +++++++++++++++---------- 2 files changed, 110 insertions(+), 71 deletions(-) diff --git a/build.gradle b/build.gradle index bc07f29200..9bd5ecdd6e 100644 --- a/build.gradle +++ b/build.gradle @@ -28,17 +28,23 @@ application { mainClass = 'org.omegat.Main' } +// Force Java runtime for Gradle on Java 17 +def gradleOnJava17OrLater = JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17) tasks.named('updateDaemonJvm') { jvmVersion = JavaVersion.VERSION_17 } +// Define target Java version to compatible. +def javaVersion = 11; + +// OmegaT distribution package meta data. def shortDescription = 'The free translation memory tool' def distDescription = 'OmegaT is a free and open source multiplatform Computer Assisted Translation tool with' + ' fuzzy matching, translation memory, keyword search, glossaries, and translation leveraging into updated' + ' projects.' def distAppVendor = 'The OmegaT project' -def gradleOnJava17OrLater = JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17) -def javaVersion = 11; + +// Definition of OmegaT versioning def localPropsFile = file('local.properties') ext { omtVersion = loadProperties(file('src/org/omegat/Version.properties')) @@ -54,10 +60,21 @@ ext { } def omtFlavor = omtVersion.beta.empty ? 'standard' : 'latest' def omtWebsite = 'https://omegat.org' -def envIsCi = project.hasProperty('envIsCi') as Boolean version = omtVersion.version + getUpdateSuffix(omtVersion.update) +// Flag to detect CI/CD environment +def envIsCi = project.hasProperty('envIsCi') as Boolean + +// Definition of bundled JRE file names +def assetDir = findProperty('assetDir') ?: '../' +def macJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_mac_*.tar.gz') +def armMacJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_aarch64_mac_*.tar.gz') +def linux64JRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_linux_*.tar.gz') +def linuxArm64JRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_aarch64_linux_*.tar.gz') +def windowsJRE32 = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x86-32_windows_*.zip') +def windowsJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_windows_*.zip') + java { withSourcesJar() withJavadocJar() @@ -431,14 +448,6 @@ def omegatJarFilename = jar.archiveFileName.get() project(":machinetranslators") {jar.enabled = false} project(":spellchecker") {jar.enabled = false} -def assetDir = findProperty('assetDir') ?: '../' -def macJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_mac_*.tar.gz') -def armMacJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_aarch64_mac_*.tar.gz') -def linux64JRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_linux_*.tar.gz') -def linuxArm64JRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_aarch64_linux_*.tar.gz') -def windowsJRE32 = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x86-32_windows_*.zip') -def windowsJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_windows_*.zip') - /* * Configuration of launch4j java launcher. * OmegaT uses it as launcher for windows. diff --git a/docs_devel/docs/90.ReleaseProcedure.md b/docs_devel/docs/90.ReleaseProcedure.md index 3233a92342..60da5ebfc3 100644 --- a/docs_devel/docs/90.ReleaseProcedure.md +++ b/docs_devel/docs/90.ReleaseProcedure.md @@ -7,30 +7,85 @@ See [Versioning](05.Versioning.md) for details about a versioning scheme. ## 1. Pre-announce on an omegat-dev mailing list Especially if there is new translatable material, give the L10N team some lead -time to update translations. +time to update translations. It is better to announce the due date +at the start of the release engineering, Step 3, instead of the planned +release date. -## 2. Decide bundled JREs versions +email template: + +```text +Subject: release plan for OmegaT 6.x + +Hi all. + +The planed changes for releasing 6.x are now all merged, +and latest weekly release looks good for the general release. + +We are now starting the release process. +Please check a latest release procedure at +https://omegat.readthedocs.io/en/latest/90.ReleaseProcedure/ + +Due dates will be as follows: + +- Feature freeze: today + +- Documentation updating phase + - Manual content freeze: 14, Dec. + - UI Localisation freeze: 20, Dec. + - Manual localisation freeze: 20, Dec. + +- Update JRE versions to up-to-date: 20, Dec. + +- Last weekly release for the candidate: 21, Dec. + +- Check and confirmation + - Ask confirmation for the latest weekly as the genral release + +- Release build and announce: 24, Dec. + - git tag the source + - trigger CI/CD for the release + - Update web site download links + - Send announce to users ML. + +``` + +## 2. Choose the bundled JREs and update their major versions See if an update is available for the bundled JREs, and update `ci/azure-pipelines/release_steps.yml` if necessary. +If you change a bundled JREs version, you must also change `build.gradle` +which contain the corresponding file names. + +For example + +```groovy +// Definition of bundled JRE file names +def assetDir = findProperty('assetDir') ?: '../' +def macJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_mac_*.tar.gz') +def armMacJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_aarch64_mac_*.tar.gz') +def linux64JRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_linux_*.tar.gz') +def linuxArm64JRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_aarch64_linux_*.tar.gz') +def windowsJRE32 = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x86-32_windows_*.zip') +def windowsJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_windows_*.zip') +``` + +If you want to bundle the Java 21 Long Term Support JRE, you need to change +`OpenJDK11U` to `OpenJDK21U`. + ## 3. Check manual versions There is a version definition in `doc_src/(lang)/version_(lang).properties` files in each language folder. -See it is as same as `vernb` variable in `doc_src/(lang)/manualvariables.mod` +Check whether it matches the `vernb` variable in `doc_src/(lang)/manualvariables.mod`. -Currently, it has not been unified and unchecked its parity. -Please be caution of it. +Exercise caution, because it is currently not unified and its parity is not checked. -## 3. Test +## 4. Test and integration test Ensure that `./gradlew check` completes successfully. - -## 4. Integration test - -Ensure integration test completes successfully. See [34.IntegrationTest] for details. +Also ensure integration test completes successfully. See [34.IntegrationTest] for details. ```console docker-compose -f docker-compose.yml build @@ -38,19 +93,10 @@ docker-compose -f docker-compose.yml up --abort-on-container-exit docker-compose down ``` -## 5. Update bundled JREs' major version - -If you change a bundled JREs version, you also change `build.gradle` line 276-282 -which is a file name match accordingly. +These tests are done in Weekly Release build CI/CD scripts. +Please check the latest weekly build succeed. -For example - -``` - macJRE = fileTree(dir: assetDir, include: 'OpenJDK8U-jre_x64_mac_*.tar.gz') -``` -When you want to bundle Java 11 JRE, you need to change `OpenJDK8U` to `OpenJDK11U`. - -## 6. Update files with the release version +## 5. Update files with the release version ### `/src/org/omegat/Version.properties` @@ -75,13 +121,13 @@ git add release/changes.txt git commit -sm 'Release version x.x' ``` -## 7. Tag release revision +## 6. Tag release revision ```sh git tag vX.Y.Z ``` -## 8. push commits and tags +## 7. push commits and tags When you are working on a release process of version 6.0 and later versions, the release pipeline will be automatically run on Azure DevOps when you push @@ -91,21 +137,7 @@ tag on GitHub. git push origin vX.Y.Z ``` -### 9. (optional) Run Release task on Azure Pipelines (version 5.8) - -When you are working on a release process of version 5.8 series, you should -run a release job manually. - -1. Go to [OmegaT Builds](https://dev.azure.com/omegat-org/OmegaT/_build) -2. Queue a Release Build, specifying for Branch the tag created earlier, - e.g. `refs/tags/vX.Y.Z`. - -After building, the dist-files will be deployed automatically to the [SourceForge -"Files" area](https://sourceforge.net/projects/omegat/files/). - -This will publish all distfiles except for Signed Mac and WebStart. - -## 10. Add signature to Windows distribution files locally, publish. +## 8. Add signature to Windows distribution files locally, and publish. First, you should download published non-signed windows binaries from source forge. @@ -116,9 +148,10 @@ CA company, such as Comodo, and Certum. There are two ways to sign the executable depends on what OS you use. Please select A or B. + ### A. Signing code on linux -Insert your HSM: hardware security module USB dongle into PC. +Insert your hardware security module (HSM) USB dongle into the PC. Prepare the shell script to sign executables that will be like as follows; ```bash @@ -138,24 +171,23 @@ certs=cert/25044ce4fc92c7b98fcafdd60f46c724.pem $toolexe sign -pkcs11engine $engine -pkcs11module $module -h sha256 -t http://time.certum.pl -certs $certs -askpass -n "${signer}" -in $infile -out $outfile ``` -You will need to change a `module` line. -You should download a driver SO file from CA provider and update to its path. -You also need to change a `certs` line. -You should update it with your PEM file path. +You will need to change the `module` line to use the path of +the driver SO file you have downloaded from the CA provider. +Similarly, update the `certs` line with the path to your PEM file. -And then you should run like as follows; +After that, run the following command: ```bash sign.sh OmegaT_6.1.0_Beta_Windows_Without_JRE.exe OmegaT_6.1.0_Beta_Windows_Without_JRE_Signed.exe ``` -There will be three files to be signed, `_Without_JRE`, `_Windows` and `_Windows_64` flavours. +There are three files to sign, the `_Without_JRE`, `_Windows` and `_Windows_64` variants. ### B. Signing code on Windows -First, you need to install Windows SDK from [Windows Dev center](https://developer.microsoft. -com/en-us/windows/downloads/windows-sdk/). And all operations performed with Code Signing require a connected reader -together with a card on which there is a Code Signing certificate. +First, install Windows SDK from [Windows Dev center](https://developer.microsoft. +com/en-us/windows/downloads/windows-sdk/). All operations performed with Code Signing require a connected reader +together with a card that contains a Code Signing certificate. To sign the file, use the following command on the command line (cmd.exe): ```commandline @@ -171,7 +203,7 @@ which can be checked in the system tool certmg.msc A file is updated with signature. You should keep an original file for backup. -## 11. Build notarized Mac distfile locally, publish +## 9. Build a notarized Mac distribution file locally, and publish First, make sure the local JRE is up-to-date. @@ -190,9 +222,7 @@ When the confirmation email arrives, do: Publish to SourceForge Files. -## 12. Set default downloads - -Only if a Standard release: +## 10. Set default downloads 1. Go to [SourceForge Files](https://sourceforge.net/projects/omegat/files/) 2. Navigate to the directory for this release @@ -202,7 +232,7 @@ Only if a Standard release: 5. Click Save -## 13. Publish the manual and Javadoc +## 11. Publish the manual and Javadoc ```sh ./gradlew publishManual publishJavadoc @@ -218,18 +248,18 @@ Only if a Standard release: Then log onto [Sonatype Nexus](https://s01.oss.sonatype.org/) and publish the release. -## 15. Modify website +## 12. Modify the website Some releases will impact the website structure. Make sure the website is up to date. -## 16. Verify all the user facing links +## 13. Verify all the user facing links - Official site: [omegat.org](https://omegat.org) - Documentation site: [omegat-standard](https://omegat.sourceforge.io/manual-standard/) - JavaDoc site: [OmegaT API](https://omegat.sourceforge.io/javadoc-standard/) - Sourceforge site: [files section](https://sourceforge.net/projects/omegat/files/) -## 17. Announce to News, user group +## 14. Announce to News, user group - [OmegaT News](https://sourceforge.net/p/omegat/news/) - [Example](https://sourceforge.net/p/omegat/news/2019/11/omegat-latest-version-510-released/) @@ -237,7 +267,7 @@ Some releases will impact the website structure. Make sure the website is up to - [Example](https://sourceforge.net/p/omegat/mailman/omegat-users/thread/CAHvKJZsm4ZSOmvCOpfbtss0z9uo0z7q--bDowRkyAQ5e2zNJJg%40.../#msg36855627) -## 18. Push a new version for version check +## 15. Push a new version for version check If no catastrophic problems are reported with the new version, once the [website](https://github.com/omegat-org/omegat-website/) has been updated, bump @@ -249,11 +279,11 @@ the version check master file: Consider opening a ticket on the website to coordinate timing. -## 19. Cleanup +## 16. Cleanup - Bump version in `Version.properties`, `changes.txt` - Set fixed bug tickets and implemented RFEs to `closed-fixed` - Update ticket milestones if necessary Note: Don't "clean up" old releases by moving them out of the way. It is -important that distfile URLs remain stable. +important that the distfile URLs remain stable. From a992ad3c2ff1c50a5ff2ee5e08d0409720358769 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 7 Sep 2024 14:36:01 +0900 Subject: [PATCH 55/85] chore(deps): bump com.github.spotbugs from 6.0.21 to 6.0.22 (#1136) Bumps com.github.spotbugs from 6.0.21 to 6.0.22. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6795e352d2..2ecb9457f7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -184,7 +184,7 @@ dictionary = ["trie4j", "dsl4j", "stardict4j", "jsoup"] xmlunit = ["xmlunit-core", "xmlunit-assertj", "assertj"] [plugins] -spotbugs = {id = "com.github.spotbugs", version = "6.0.21"} +spotbugs = {id = "com.github.spotbugs", version = "6.0.22"} spotless = {id = "com.diffplug.spotless", version = "6.25.0"} launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.6"} versions = {id = "com.github.ben-manes.versions", version = "0.51.0"} From 7986fbd8e4e9226dff99e4cab6b0fe2341a2ba2f Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Wed, 11 Sep 2024 19:52:32 +0900 Subject: [PATCH 56/85] chore: always update test results Signed-off-by: Hiroshi Miura --- ci/azure-pipelines/check_steps.yml | 5 +++++ ci/azure-pipelines/test_steps.yml | 1 + 2 files changed, 6 insertions(+) diff --git a/ci/azure-pipelines/check_steps.yml b/ci/azure-pipelines/check_steps.yml index 34aacaf359..c4cbc45d3e 100644 --- a/ci/azure-pipelines/check_steps.yml +++ b/ci/azure-pipelines/check_steps.yml @@ -13,3 +13,8 @@ steps: tasks: check options: '-PenvIsCi --no-daemon --scan' jdkVersionOption: '1.17' + - task: PublishTestResults@2 + displayName: 'Publish Test Results build/reports/**/*.xml' + condition: always() + inputs: + testResultsFiles: 'build/reports/**/*.xml' \ No newline at end of file diff --git a/ci/azure-pipelines/test_steps.yml b/ci/azure-pipelines/test_steps.yml index 3dc2e9b063..85b54d6e21 100644 --- a/ci/azure-pipelines/test_steps.yml +++ b/ci/azure-pipelines/test_steps.yml @@ -12,5 +12,6 @@ steps: displayName: 'Run Gradle clean, test and test on Java17' - task: PublishTestResults@2 displayName: 'Publish Test Results build/test-results/**/TEST-*.xml' + condition: always() inputs: testResultsFiles: 'build/test-results/**/TEST-*.xml' From 439bc3e053220c94231409a9427d726bec36a071 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 08:50:53 +0900 Subject: [PATCH 57/85] chore(deps): bump com.gradle.develocity from 3.18 to 3.18.1 (#1138) Bumps com.gradle.develocity from 3.18 to 3.18.1. --- updated-dependencies: - dependency-name: com.gradle.develocity dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index e39286362b..40870d0d2f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,6 @@ plugins { id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' - id 'com.gradle.develocity' version '3.18' + id 'com.gradle.develocity' version '3.18.1' } develocity { buildScan { From e1999c1c9e5bc09dd7087d5861fba57df4269f51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Sep 2024 21:33:15 +0900 Subject: [PATCH 58/85] chore(deps): bump com.github.spotbugs from 6.0.22 to 6.0.23 (#1146) Bumps com.github.spotbugs from 6.0.22 to 6.0.23. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2ecb9457f7..b26fcefdd2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -184,7 +184,7 @@ dictionary = ["trie4j", "dsl4j", "stardict4j", "jsoup"] xmlunit = ["xmlunit-core", "xmlunit-assertj", "assertj"] [plugins] -spotbugs = {id = "com.github.spotbugs", version = "6.0.22"} +spotbugs = {id = "com.github.spotbugs", version = "6.0.23"} spotless = {id = "com.diffplug.spotless", version = "6.25.0"} launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.6"} versions = {id = "com.github.ben-manes.versions", version = "0.51.0"} From d82741a59e7bcf89e86b4e52c83fa4a2cfe62df3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 09:41:23 +0900 Subject: [PATCH 59/85] chore(deps): bump tokyo.northside:assertj-swing-junit (#1151) Bumps [tokyo.northside:assertj-swing-junit](https://github.com/omegat-org/assertj-swing) from 4.0.0-beta-1 to 4.0.0-beta-2. - [Commits](https://github.com/omegat-org/assertj-swing/commits) --- updated-dependencies: - dependency-name: tokyo.northside:assertj-swing-junit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b26fcefdd2..fcdce344fb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -50,7 +50,7 @@ jna = "5.13.0" jfa = "1.2.0" tipoftheday = "0.4.4" flatlaf="3.5.1" -assertj_swing_junit = "4.0.0-beta-1" +assertj_swing_junit = "4.0.0-beta-2" morfologik = "2.1.9" jaxb = "2.3.0" From fbd0d2d10e3f2b3fcef19c6e21ba0c3c874d3bb8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 09:41:57 +0900 Subject: [PATCH 60/85] chore(deps): bump com.github.spotbugs from 6.0.23 to 6.0.24 (#1153) Bumps com.github.spotbugs from 6.0.23 to 6.0.24. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fcdce344fb..c5ad7f4885 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -184,7 +184,7 @@ dictionary = ["trie4j", "dsl4j", "stardict4j", "jsoup"] xmlunit = ["xmlunit-core", "xmlunit-assertj", "assertj"] [plugins] -spotbugs = {id = "com.github.spotbugs", version = "6.0.23"} +spotbugs = {id = "com.github.spotbugs", version = "6.0.24"} spotless = {id = "com.diffplug.spotless", version = "6.25.0"} launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.6"} versions = {id = "com.github.ben-manes.versions", version = "0.51.0"} From 6a2b43a86c48063f6ce43deedc191e19a5078ffe Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Fri, 4 Oct 2024 09:44:45 +0900 Subject: [PATCH 61/85] bump vldocking@3.1.1 (#1148) * feat: bump vldocking@3.1.0 - update VLDocking customization with new UIDefaults API which is LaF friendly. Signed-off-by: Hiroshi Miura * chore: bump vldocking@3.1.1 Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- gradle/libs.versions.toml | 2 +- .../omegat/gui/theme/DefaultClassicTheme.java | 63 ++++----- .../omegat/gui/theme/DefaultFlatTheme.java | 128 +++++++++--------- .../util/gui/CustomDockingUISettings.java | 125 +++++++++++++++++ src/org/omegat/util/gui/UIDesignManager.java | 65 +-------- 5 files changed, 219 insertions(+), 164 deletions(-) create mode 100644 src/org/omegat/util/gui/CustomDockingUISettings.java diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c5ad7f4885..6cb2d2a743 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -26,7 +26,7 @@ bc = "1.78.1" nashorn = "15.4" caffeine = "3.1.8" wiremock = "3.9.1" -vldocking = "3.0.5-2" +vldocking = "3.1.1" xmlunit = "2.10.0" assertj = "3.26.0" appbundler = "1.2.1" diff --git a/src/org/omegat/gui/theme/DefaultClassicTheme.java b/src/org/omegat/gui/theme/DefaultClassicTheme.java index 1c88172f17..740f4c8112 100644 --- a/src/org/omegat/gui/theme/DefaultClassicTheme.java +++ b/src/org/omegat/gui/theme/DefaultClassicTheme.java @@ -95,39 +95,36 @@ public static UIDefaults setDefaults(UIDefaults defaults) { } catch (IOException e) { Log.log(e); } - // FIXME: VLDocking values have to be set to the "developer defaults" - // not the "LAF defaults" because that's where - // DockingUISettings#installUI puts them - UIManager.put("DockViewTitleBar.hide", getIcon("minimize.gif")); - UIManager.put("DockViewTitleBar.hide.rollover", getIcon("minimize.rollover.gif")); - UIManager.put("DockViewTitleBar.hide.pressed", getIcon("minimize.pressed.gif")); - UIManager.put("DockViewTitleBar.maximize", getIcon("maximize.gif")); - UIManager.put("DockViewTitleBar.maximize.rollover", getIcon("maximize.rollover.gif")); - UIManager.put("DockViewTitleBar.maximize.pressed", getIcon("maximize.pressed.gif")); - UIManager.put("DockViewTitleBar.restore", getIcon("restore.gif")); - UIManager.put("DockViewTitleBar.restore.rollover", getIcon("restore.rollover.gif")); - UIManager.put("DockViewTitleBar.restore.pressed", getIcon("restore.pressed.gif")); - UIManager.put("DockViewTitleBar.dock", getIcon("restore.gif")); - UIManager.put("DockViewTitleBar.dock.rollover", getIcon("restore.rollover.gif")); - UIManager.put("DockViewTitleBar.dock.pressed", getIcon("restore.pressed.gif")); - UIManager.put("DockViewTitleBar.float", getIcon("undock.gif")); - UIManager.put("DockViewTitleBar.float.rollover", getIcon("undock.rollover.gif")); - UIManager.put("DockViewTitleBar.float.pressed", getIcon("undock.pressed.gif")); - UIManager.put("DockViewTitleBar.attach", getIcon("dock.gif")); - UIManager.put("DockViewTitleBar.attach.rollover", getIcon("dock.rollover.gif")); - UIManager.put("DockViewTitleBar.attach.pressed", getIcon("dock.pressed.gif")); - UIManager.put("DockViewTitleBar.menu.hide", getIcon("minimize.gif")); - UIManager.put("DockViewTitleBar.menu.maximize", getIcon("maximize.gif")); - UIManager.put("DockViewTitleBar.menu.restore", getIcon("restore.gif")); - UIManager.put("DockViewTitleBar.menu.dock", getIcon("restore.gif")); - UIManager.put("DockViewTitleBar.menu.float", getIcon("undock.gif")); - UIManager.put("DockViewTitleBar.menu.attach", getIcon("dock.gif")); - UIManager.put("DockTabbedPane.menu.hide", getIcon("empty.gif")); - UIManager.put("DockTabbedPane.menu.maximize", getIcon("empty.gif")); - UIManager.put("DockTabbedPane.menu.float", getIcon("empty.gif")); - UIManager.put("DockTabbedPane.menu.closeAll", getIcon("empty.gif")); - UIManager.put("DockTabbedPane.menu.closeAllOther", getIcon("empty.gif")); - UIManager.put("DragControler.detachCursor", getIcon("undock.gif").getImage()); + defaults.put("DockViewTitleBar.hide", getIcon("minimize.gif")); + defaults.put("DockViewTitleBar.hide.rollover", getIcon("minimize.rollover.gif")); + defaults.put("DockViewTitleBar.hide.pressed", getIcon("minimize.pressed.gif")); + defaults.put("DockViewTitleBar.maximize", getIcon("maximize.gif")); + defaults.put("DockViewTitleBar.maximize.rollover", getIcon("maximize.rollover.gif")); + defaults.put("DockViewTitleBar.maximize.pressed", getIcon("maximize.pressed.gif")); + defaults.put("DockViewTitleBar.restore", getIcon("restore.gif")); + defaults.put("DockViewTitleBar.restore.rollover", getIcon("restore.rollover.gif")); + defaults.put("DockViewTitleBar.restore.pressed", getIcon("restore.pressed.gif")); + defaults.put("DockViewTitleBar.dock", getIcon("restore.gif")); + defaults.put("DockViewTitleBar.dock.rollover", getIcon("restore.rollover.gif")); + defaults.put("DockViewTitleBar.dock.pressed", getIcon("restore.pressed.gif")); + defaults.put("DockViewTitleBar.float", getIcon("undock.gif")); + defaults.put("DockViewTitleBar.float.rollover", getIcon("undock.rollover.gif")); + defaults.put("DockViewTitleBar.float.pressed", getIcon("undock.pressed.gif")); + defaults.put("DockViewTitleBar.attach", getIcon("dock.gif")); + defaults.put("DockViewTitleBar.attach.rollover", getIcon("dock.rollover.gif")); + defaults.put("DockViewTitleBar.attach.pressed", getIcon("dock.pressed.gif")); + defaults.put("DockViewTitleBar.menu.hide", getIcon("minimize.gif")); + defaults.put("DockViewTitleBar.menu.maximize", getIcon("maximize.gif")); + defaults.put("DockViewTitleBar.menu.restore", getIcon("restore.gif")); + defaults.put("DockViewTitleBar.menu.dock", getIcon("restore.gif")); + defaults.put("DockViewTitleBar.menu.float", getIcon("undock.gif")); + defaults.put("DockViewTitleBar.menu.attach", getIcon("dock.gif")); + defaults.put("DockTabbedPane.menu.hide", getIcon("empty.gif")); + defaults.put("DockTabbedPane.menu.maximize", getIcon("empty.gif")); + defaults.put("DockTabbedPane.menu.float", getIcon("empty.gif")); + defaults.put("DockTabbedPane.menu.closeAll", getIcon("empty.gif")); + defaults.put("DockTabbedPane.menu.closeAllOther", getIcon("empty.gif")); + defaults.put("DragControler.detachCursor", getIcon("undock.gif").getImage()); return defaults; } } diff --git a/src/org/omegat/gui/theme/DefaultFlatTheme.java b/src/org/omegat/gui/theme/DefaultFlatTheme.java index ced001a307..966a88a968 100644 --- a/src/org/omegat/gui/theme/DefaultFlatTheme.java +++ b/src/org/omegat/gui/theme/DefaultFlatTheme.java @@ -119,23 +119,19 @@ public static UIDefaults setDefaults(UIDefaults defaults, String lafId) { } // General highlight & shadow used in a lot of places - // - // FIXME: VLDocking values have to be set to the "developer defaults" - // not the "LAF defaults" because that's where - // DockingUISettings#installUI puts them - UIManager.put("VLDocking.highlight", activeTitleBgColor); - UIManager.put("VLDocking.shadow", statusAreaColor); + defaults.put("VLDocking.highlight", activeTitleBgColor); + defaults.put("VLDocking.shadow", statusAreaColor); // Main window main area int outside = 5; - UIManager.put("DockingDesktop.border", new EmptyBorder(outside, outside, outside, outside)); + defaults.put("DockingDesktop.border", new EmptyBorder(outside, outside, outside, outside)); // Docked, visible panels get two borders if we're not careful: // 1. Drawn by VLDocking. Surrounds panel content AND header. Set this to empty margin instead. int panel = 2; - UIManager.put("DockView.singleDockableBorder", new EmptyBorder(panel, panel, panel, panel)); + defaults.put("DockView.singleDockableBorder", new EmptyBorder(panel, panel, panel, panel)); int maxPanel = outside + panel; - UIManager.put("DockView.maximizedDockableBorder", new EmptyBorder(maxPanel, maxPanel, maxPanel, maxPanel)); + defaults.put("DockView.maximizedDockableBorder", new EmptyBorder(maxPanel, maxPanel, maxPanel, maxPanel)); // 2. Drawn by OmegaT-defined Dockables. Make this a 1px line. defaults.put("OmegaTDockablePanel.border", new MatteBorder(1, 1, 1, 1, borderColor)); @@ -148,11 +144,11 @@ public static UIDefaults setDefaults(UIDefaults defaults, String lafId) { // Tabbed docked, visible panels are surrounded by LAF-specific chrome, but the surrounding // colors don't appear to be available through the API. These values are from visual inspection. if (Platform.isMacOSX()) { - UIManager.put("DockView.tabbedDockableBorder", new MatteBorder(0, 5, 5, 5, new Color(0xE6E6E6))); + defaults.put("DockView.tabbedDockableBorder", new MatteBorder(0, 5, 5, 5, new Color(0xE6E6E6))); } else if (isWindowsLAF(lafId) && !isWindowsClassicLAF(lafId)) { - UIManager.put("DockView.tabbedDockableBorder", new MatteBorder(2, 5, 5, 5, Color.WHITE)); + defaults.put("DockView.tabbedDockableBorder", new MatteBorder(2, 5, 5, 5, Color.WHITE)); } else { - UIManager.put("DockView.tabbedDockableBorder", new MatteBorder(5, 5, 5, 5, standardBgColor)); + defaults.put("DockView.tabbedDockableBorder", new MatteBorder(5, 5, 5, 5, standardBgColor)); } // Windows 8+ is very square. @@ -162,7 +158,7 @@ public static UIDefaults setDefaults(UIDefaults defaults, String lafId) { Color activeTitleText = defaults.getColor("Label.foreground"); // #000000 -> #808080; GTK+ has Color.WHITE for Label.disabledForeground Color inactiveTitleText = adjustRGB(activeTitleText, 0x80); - UIManager.put("DockViewTitleBar.border", + defaults.put("DockViewTitleBar.border", new RoundedCornerBorder(cornerRadius, borderColor, RoundedCornerBorder.SIDE_TOP)); // Windows 7 "Classic" has Color.WHITE for this defaults.put("InternalFrame.activeTitleForeground", activeTitleText); @@ -170,18 +166,18 @@ public static UIDefaults setDefaults(UIDefaults defaults, String lafId) { defaults.put("InternalFrame.inactiveTitleForeground", inactiveTitleText); defaults.put("InternalFrame.inactiveTitleBackground", standardBgColor); // Disable gradient on pane title bars - UIManager.put("DockViewTitleBar.disableCustomPaint", true); + defaults.put("DockViewTitleBar.disableCustomPaint", true); // Main window bottom area // AutoHideButtonPanel is where minimized panel tabs go. Use compound border to give left/right margins. - UIManager.put("AutoHideButtonPanel.bottomBorder", new CompoundBorder( + defaults.put("AutoHideButtonPanel.bottomBorder", new CompoundBorder( new MatteBorder(1, 0, 0, 0, borderColor), new EmptyBorder(0, 2 * outside, 0, 2 * outside))); - UIManager.put("AutoHideButtonPanel.background", bottomAreaBgColor); - UIManager.put("AutoHideButton.expandBorderBottom", + defaults.put("AutoHideButtonPanel.background", bottomAreaBgColor); + defaults.put("AutoHideButton.expandBorderBottom", new RoundedCornerBorder(cornerRadius, borderColor, RoundedCornerBorder.SIDE_BOTTOM)); - UIManager.put("AutoHideButton.background", standardBgColor); + defaults.put("AutoHideButton.background", standardBgColor); // OmegaT-defined status box in lower right defaults.put("OmegaTStatusArea.border", new MatteBorder(1, 1, 1, 1, statusAreaColor)); // Lowermost section margins @@ -196,60 +192,60 @@ public static UIDefaults setDefaults(UIDefaults defaults, String lafId) { defaults.put("inactiveCaptionBorder", borderColor); // Icons - UIManager.put("DockViewTitleBar.maximize", getIcon("appbar.app.tall.inactive.png")); - UIManager.put("DockViewTitleBar.maximize.rollover", getIcon("appbar.app.tall.png")); - UIManager.put("DockViewTitleBar.maximize.pressed", getIcon("appbar.app.tall.pressed.png")); - UIManager.put("DockViewTitleBar.restore", getIcon("appbar.window.restore.inactive.png")); - UIManager.put("DockViewTitleBar.restore.rollover", getIcon("appbar.window.restore.png")); - UIManager.put("DockViewTitleBar.restore.pressed", getIcon("appbar.window.restore.pressed.png")); - UIManager.put("DockViewTitleBar.hide", getIcon("appbar.hide.inactive.png")); - UIManager.put("DockViewTitleBar.hide.rollover", getIcon("appbar.hide.png")); - UIManager.put("DockViewTitleBar.hide.pressed", getIcon("appbar.hide.pressed.png")); - UIManager.put("DockViewTitleBar.float", getIcon("appbar.fullscreen.inactive.png")); - UIManager.put("DockViewTitleBar.float.rollover", getIcon("appbar.fullscreen.png")); - UIManager.put("DockViewTitleBar.float.pressed", getIcon("appbar.fullscreen.pressed.png")); - UIManager.put("DockViewTitleBar.dock", getIcon("appbar.window.restore.inactive.png")); - UIManager.put("DockViewTitleBar.dock.rollover", getIcon("appbar.window.restore.png")); - UIManager.put("DockViewTitleBar.dock.pressed", getIcon("appbar.window.restore.pressed.png")); - UIManager.put("DockViewTitleBar.attach", getIcon("appbar.dock.window.inactive.png")); - UIManager.put("DockViewTitleBar.attach.rollover", getIcon("appbar.dock.window.png")); - UIManager.put("DockViewTitleBar.attach.pressed", getIcon("appbar.dock.window.pressed.png")); - - UIManager.put("DockViewTitleBar.menu.hide", getIcon("appbar.hide.png")); - UIManager.put("DockViewTitleBar.menu.maximize", getIcon("appbar.app.tall.png")); - UIManager.put("DockViewTitleBar.menu.restore", getIcon("appbar.window.restore.png")); - UIManager.put("DockViewTitleBar.menu.dock", getIcon("appbar.window.restore.png")); - UIManager.put("DockViewTitleBar.menu.float", getIcon("appbar.fullscreen.png")); - UIManager.put("DockViewTitleBar.menu.attach", getIcon("appbar.dock.window.png")); - - UIManager.put("DockTabbedPane.menu.hide", getIcon("appbar.hide.png")); - UIManager.put("DockTabbedPane.menu.maximize", getIcon("appbar.app.tall.png")); - UIManager.put("DockTabbedPane.menu.float", getIcon("appbar.fullscreen.png")); + defaults.put("DockViewTitleBar.maximize", getIcon("appbar.app.tall.inactive.png")); + defaults.put("DockViewTitleBar.maximize.rollover", getIcon("appbar.app.tall.png")); + defaults.put("DockViewTitleBar.maximize.pressed", getIcon("appbar.app.tall.pressed.png")); + defaults.put("DockViewTitleBar.restore", getIcon("appbar.window.restore.inactive.png")); + defaults.put("DockViewTitleBar.restore.rollover", getIcon("appbar.window.restore.png")); + defaults.put("DockViewTitleBar.restore.pressed", getIcon("appbar.window.restore.pressed.png")); + defaults.put("DockViewTitleBar.hide", getIcon("appbar.hide.inactive.png")); + defaults.put("DockViewTitleBar.hide.rollover", getIcon("appbar.hide.png")); + defaults.put("DockViewTitleBar.hide.pressed", getIcon("appbar.hide.pressed.png")); + defaults.put("DockViewTitleBar.float", getIcon("appbar.fullscreen.inactive.png")); + defaults.put("DockViewTitleBar.float.rollover", getIcon("appbar.fullscreen.png")); + defaults.put("DockViewTitleBar.float.pressed", getIcon("appbar.fullscreen.pressed.png")); + defaults.put("DockViewTitleBar.dock", getIcon("appbar.window.restore.inactive.png")); + defaults.put("DockViewTitleBar.dock.rollover", getIcon("appbar.window.restore.png")); + defaults.put("DockViewTitleBar.dock.pressed", getIcon("appbar.window.restore.pressed.png")); + defaults.put("DockViewTitleBar.attach", getIcon("appbar.dock.window.inactive.png")); + defaults.put("DockViewTitleBar.attach.rollover", getIcon("appbar.dock.window.png")); + defaults.put("DockViewTitleBar.attach.pressed", getIcon("appbar.dock.window.pressed.png")); + + defaults.put("DockViewTitleBar.menu.hide", getIcon("appbar.hide.png")); + defaults.put("DockViewTitleBar.menu.maximize", getIcon("appbar.app.tall.png")); + defaults.put("DockViewTitleBar.menu.restore", getIcon("appbar.window.restore.png")); + defaults.put("DockViewTitleBar.menu.dock", getIcon("appbar.window.restore.png")); + defaults.put("DockViewTitleBar.menu.float", getIcon("appbar.fullscreen.png")); + defaults.put("DockViewTitleBar.menu.attach", getIcon("appbar.dock.window.png")); + + defaults.put("DockTabbedPane.menu.hide", getIcon("appbar.hide.png")); + defaults.put("DockTabbedPane.menu.maximize", getIcon("appbar.app.tall.png")); + defaults.put("DockTabbedPane.menu.float", getIcon("appbar.fullscreen.png")); // Windows only accepts a 32x32 cursor image with no semitransparency, so you basically // need a special image just for that. - UIManager.put("DragControler.detachCursor", ResourcesUtil.getBundledImage("appbar.fullscreen.cursor32x32.png")); + defaults.put("DragControler.detachCursor", ResourcesUtil.getBundledImage("appbar.fullscreen.cursor32x32.png")); // Use more native-looking icons on OS X if (Platform.isMacOSX()) { - UIManager.put("DockViewTitleBar.maximize", getIcon("appbar.fullscreen.corners.inactive.png")); - UIManager.put("DockViewTitleBar.maximize.rollover", getIcon("appbar.fullscreen.corners.png")); - UIManager.put("DockViewTitleBar.maximize.pressed", getIcon("appbar.fullscreen.corners.pressed.png")); - UIManager.put("DockViewTitleBar.restore", getIcon("appbar.restore.corners.inactive.png")); - UIManager.put("DockViewTitleBar.restore.rollover", getIcon("appbar.restore.corners.png")); - UIManager.put("DockViewTitleBar.restore.pressed", getIcon("appbar.restore.corners.pressed.png")); - UIManager.put("DockViewTitleBar.hide", getIcon("appbar.minus.inactive.png")); - UIManager.put("DockViewTitleBar.hide.rollover", getIcon("appbar.minus.png")); - UIManager.put("DockViewTitleBar.hide.pressed", getIcon("appbar.minus.pressed.png")); - - UIManager.put("DockViewTitleBar.menu.hide", getIcon("appbar.minus.png")); - UIManager.put("DockViewTitleBar.menu.maximize", getIcon("appbar.fullscreen.corners.png")); - UIManager.put("DockViewTitleBar.menu.restore", getIcon("appbar.restore.corners.png")); - - UIManager.put("DockTabbedPane.menu.hide", getIcon("appbar.minus.png")); - UIManager.put("DockTabbedPane.menu.maximize", getIcon("appbar.fullscreen.corners.png")); - - UIManager.put("DragControler.detachCursor", ResourcesUtil.getBundledImage("appbar.fullscreen.png")); + defaults.put("DockViewTitleBar.maximize", getIcon("appbar.fullscreen.corners.inactive.png")); + defaults.put("DockViewTitleBar.maximize.rollover", getIcon("appbar.fullscreen.corners.png")); + defaults.put("DockViewTitleBar.maximize.pressed", getIcon("appbar.fullscreen.corners.pressed.png")); + defaults.put("DockViewTitleBar.restore", getIcon("appbar.restore.corners.inactive.png")); + defaults.put("DockViewTitleBar.restore.rollover", getIcon("appbar.restore.corners.png")); + defaults.put("DockViewTitleBar.restore.pressed", getIcon("appbar.restore.corners.pressed.png")); + defaults.put("DockViewTitleBar.hide", getIcon("appbar.minus.inactive.png")); + defaults.put("DockViewTitleBar.hide.rollover", getIcon("appbar.minus.png")); + defaults.put("DockViewTitleBar.hide.pressed", getIcon("appbar.minus.pressed.png")); + + defaults.put("DockViewTitleBar.menu.hide", getIcon("appbar.minus.png")); + defaults.put("DockViewTitleBar.menu.maximize", getIcon("appbar.fullscreen.corners.png")); + defaults.put("DockViewTitleBar.menu.restore", getIcon("appbar.restore.corners.png")); + + defaults.put("DockTabbedPane.menu.hide", getIcon("appbar.minus.png")); + defaults.put("DockTabbedPane.menu.maximize", getIcon("appbar.fullscreen.corners.png")); + + defaults.put("DragControler.detachCursor", ResourcesUtil.getBundledImage("appbar.fullscreen.png")); } // Main window newUI icons diff --git a/src/org/omegat/util/gui/CustomDockingUISettings.java b/src/org/omegat/util/gui/CustomDockingUISettings.java new file mode 100644 index 0000000000..1295c8e2eb --- /dev/null +++ b/src/org/omegat/util/gui/CustomDockingUISettings.java @@ -0,0 +1,125 @@ +/************************************************************************** + 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.util.gui; + +import java.awt.Color; +import java.awt.Image; + +import javax.swing.ImageIcon; +import javax.swing.UIDefaults; +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; + +import org.omegat.util.OStrings; + +import com.vlsolutions.swing.docking.ui.DockingUISettings; + +public class CustomDockingUISettings extends DockingUISettings { + + public CustomDockingUISettings() { + super(); + } + + @Override + protected UIDefaults getDefaults(UIDefaults config) { + // UI strings + config.put("DockViewTitleBar.minimizeButtonText", OStrings.getString("DOCKING_HINT_MINIMIZE")); + config.put("DockViewTitleBar.maximizeButtonText", OStrings.getString("DOCKING_HINT_MAXIMIZE")); + config.put("DockViewTitleBar.restoreButtonText", OStrings.getString("DOCKING_HINT_RESTORE")); + config.put("DockViewTitleBar.attachButtonText", OStrings.getString("DOCKING_HINT_DOCK")); + config.put("DockViewTitleBar.floatButtonText", OStrings.getString("DOCKING_HINT_UNDOCK")); + config.put("DockViewTitleBar.closeButtonText", ""); + config.put("DockTabbedPane.minimizeButtonText", OStrings.getString("DOCKING_HINT_MINIMIZE")); + config.put("DockTabbedPane.maximizeButtonText", OStrings.getString("DOCKING_HINT_MAXIMIZE")); + config.put("DockTabbedPane.restoreButtonText", OStrings.getString("DOCKING_HINT_RESTORE")); + config.put("DockTabbedPane.floatButtonText", OStrings.getString("DOCKING_HINT_UNDOCK")); + config.put("DockTabbedPane.closeButtonText", ""); + + // Fonts + config.put("DockViewTitleBar.titleFont", UIManager.getFont("Label.font")); + + config.put("DockViewTitleBar.isCloseButtonDisplayed", false); + + // Disused icons + config.put("DockViewTitleBar.menu.close", getIcon("empty.gif")); + config.put("DockTabbedPane.close", getIcon("empty.gif")); + config.put("DockTabbedPane.close.rollover", getIcon("empty.gif")); + config.put("DockTabbedPane.close.pressed", getIcon("empty.gif")); + config.put("DockTabbedPane.menu.close", getIcon("empty.gif")); + + // Panel notification (blinking tabs/headers) settings + config.put("DockingDesktop.notificationBlinkCount", 2); + config.put("DockingDesktop.notificationColor", + Styles.EditorColor.COLOR_NOTIFICATION_MAX.getColor()); + + // to ensure DockViewTitleBar title readability + Color textColor = UIManager.getColor("InternalFrame.inactiveTitleForeground"); + Color backColor = UIManager.getColor("Panel.background"); + // One of these could be null + if (textColor != null && backColor != null) { + if (textColor.equals(backColor)) { + float[] hsb = Color.RGBtoHSB(textColor.getRed(), textColor.getGreen(), textColor.getBlue(), + null); + float brightness = hsb[2]; // darkest 0.0f <--> 1.0f brightest + if (brightness >= 0.5f) { + brightness -= 0.5f; // to darker + } else { + brightness += 0.5f; // to brighter + } + int rgb = Color.HSBtoRGB(hsb[0], hsb[1], brightness); + ColorUIResource res = new ColorUIResource(rgb); + config.put("InternalFrame.inactiveTitleForeground", res); + } + } + + config.put("DockingDesktop.notificationBlinkCount", 2); + config.put("DockingDesktop.notificationColor", + Styles.EditorColor.COLOR_NOTIFICATION_MAX.getColor()); + + super.getDefaults(config); + + // Override by null for accelerators to disable + // This should be placed after `super.getDefaults` call. + config.put("DockingDesktop.closeActionAccelerator", null); + config.put("DockingDesktop.maximizeActionAccelerator", null); + config.put("DockingDesktop.dockActionAccelerator", null); + config.put("DockingDesktop.floatActionAccelerator", null); + + return config; + } + + /** + * Load icon from classpath. + * + * @param iconName + * icon file name + * @return icon instance + */ + private ImageIcon getIcon(String iconName) { + Image image = ResourcesUtil.getBundledImage(iconName); + return image == null ? null : new ImageIcon(image); + } +} diff --git a/src/org/omegat/util/gui/UIDesignManager.java b/src/org/omegat/util/gui/UIDesignManager.java index 281f24d921..14610e641e 100644 --- a/src/org/omegat/util/gui/UIDesignManager.java +++ b/src/org/omegat/util/gui/UIDesignManager.java @@ -45,12 +45,10 @@ import javax.swing.LookAndFeel; import javax.swing.UIDefaults; import javax.swing.UIManager; -import javax.swing.plaf.ColorUIResource; import org.omegat.gui.main.BaseMainWindowMenu; import org.omegat.gui.preferences.IMenuPreferece; import org.omegat.util.Log; -import org.omegat.util.OStrings; import org.omegat.util.Platform; import org.omegat.util.Preferences; import org.omegat.util.StringUtil; @@ -177,7 +175,7 @@ private static ClassLoader getClassLoader() { */ public static void initialize() throws IOException { // Install VLDocking defaults - DockingUISettings.getInstance().installUI(); + DockingUISettings.setInstance(new CustomDockingUISettings()); DockableContainerFactory.setFactory(new CustomContainerFactory()); // Set Look And Feel @@ -211,71 +209,10 @@ public static void initialize() throws IOException { // Enable animated popup when mousing over minimized tab AutoHidePolicy.getPolicy().setExpandMode(ExpandMode.EXPAND_ON_ROLLOVER); - // UI strings - UIManager.put("DockViewTitleBar.minimizeButtonText", OStrings.getString("DOCKING_HINT_MINIMIZE")); - UIManager.put("DockViewTitleBar.maximizeButtonText", OStrings.getString("DOCKING_HINT_MAXIMIZE")); - UIManager.put("DockViewTitleBar.restoreButtonText", OStrings.getString("DOCKING_HINT_RESTORE")); - UIManager.put("DockViewTitleBar.attachButtonText", OStrings.getString("DOCKING_HINT_DOCK")); - UIManager.put("DockViewTitleBar.floatButtonText", OStrings.getString("DOCKING_HINT_UNDOCK")); - UIManager.put("DockViewTitleBar.closeButtonText", ""); - UIManager.put("DockTabbedPane.minimizeButtonText", OStrings.getString("DOCKING_HINT_MINIMIZE")); - UIManager.put("DockTabbedPane.maximizeButtonText", OStrings.getString("DOCKING_HINT_MAXIMIZE")); - UIManager.put("DockTabbedPane.restoreButtonText", OStrings.getString("DOCKING_HINT_RESTORE")); - UIManager.put("DockTabbedPane.floatButtonText", OStrings.getString("DOCKING_HINT_UNDOCK")); - UIManager.put("DockTabbedPane.closeButtonText", ""); - // Fonts Font defaultFont = UIManager.getFont("Label.font"); - UIManager.put("DockViewTitleBar.titleFont", defaultFont); UIManager.put("JTabbedPaneSmartIcon.font", defaultFont); UIManager.put("AutoHideButton.font", defaultFont); - - // UI settings - UIManager.put("DockViewTitleBar.isCloseButtonDisplayed", false); - UIManager.put("DockingDesktop.closeActionAccelerator", null); - UIManager.put("DockingDesktop.maximizeActionAccelerator", null); - UIManager.put("DockingDesktop.dockActionAccelerator", null); - UIManager.put("DockingDesktop.floatActionAccelerator", null); - - // Disused icons - UIManager.put("DockViewTitleBar.menu.close", getIcon("empty.gif")); - UIManager.put("DockTabbedPane.close", getIcon("empty.gif")); - UIManager.put("DockTabbedPane.close.rollover", getIcon("empty.gif")); - UIManager.put("DockTabbedPane.close.pressed", getIcon("empty.gif")); - UIManager.put("DockTabbedPane.menu.close", getIcon("empty.gif")); - - // Panel notification (blinking tabs/headers) settings - UIManager.put("DockingDesktop.notificationBlinkCount", 2); - UIManager.put("DockingDesktop.notificationColor", - Styles.EditorColor.COLOR_NOTIFICATION_MAX.getColor()); - - ensureTitlebarReadability(); - } - - private static void ensureTitlebarReadability() { - // to ensure DockViewTitleBar title readability - Color textColor = UIManager.getColor("InternalFrame.inactiveTitleForeground"); - Color backColor = UIManager.getColor("Panel.background"); - // One of these could be null - if (textColor != null && backColor != null) { - if (textColor.equals(backColor)) { - float[] hsb = Color.RGBtoHSB(textColor.getRed(), textColor.getGreen(), textColor.getBlue(), - null); - float brightness = hsb[2]; // darkest 0.0f <--> 1.0f brightest - if (brightness >= 0.5f) { - brightness -= 0.5f; // to darker - } else { - brightness += 0.5f; // to brighter - } - int rgb = Color.HSBtoRGB(hsb[0], hsb[1], brightness); - ColorUIResource res = new ColorUIResource(rgb); - UIManager.put("InternalFrame.inactiveTitleForeground", res); - } - } - - UIManager.put("DockingDesktop.notificationBlinkCount", 2); - UIManager.put("DockingDesktop.notificationColor", - Styles.EditorColor.COLOR_NOTIFICATION_MAX.getColor()); } /** From 005c4a009e992bb885baa57f828986b67351641f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 10:47:56 +0900 Subject: [PATCH 62/85] chore(deps): bump groovy from 4.0.22 to 4.0.23 (#1140) Bumps `groovy` from 4.0.22 to 4.0.23. Updates `org.apache.groovy:groovy-jsr223` from 4.0.22 to 4.0.23 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy-dateutil` from 4.0.22 to 4.0.23 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy-json` from 4.0.22 to 4.0.23 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy-xml` from 4.0.22 to 4.0.23 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy-swing` from 4.0.22 to 4.0.23 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy-templates` from 4.0.22 to 4.0.23 - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-jsr223 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy-dateutil dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy-json dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy-xml dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy-swing dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy-templates dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6cb2d2a743..8b5261c4d3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] slf4j = { strictly = "[2.0.7, 2.1[", prefer = "2.0.7" } slf4j-format = "0.5.1" -groovy = "4.0.22" +groovy = "4.0.23" junit = "4.13.2" commons_lang3 = "3.14.0" commons_io = "2.16.1" From 1b661f0e976f1bad45f6b5e5567f54ac2bf5c799 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Fri, 4 Oct 2024 10:55:08 +0900 Subject: [PATCH 63/85] fix: Change Editor color customizer label (#1051) * fix: Change Editor color customizer label - Introduce color definition: COLOR_MARK_COMES_FROM_TM_MT - Define it in ColorScheme - Add custom color editor row name in Bundle - Add unit test Signed-off-by: Hiroshi Miura * tweak the come_from_tm_mt order Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- src/org/omegat/Bundle.properties | 2 +- src/org/omegat/Bundle_ja.properties | 2 +- src/org/omegat/ColorScheme_dark.properties | 2 +- src/org/omegat/ColorScheme_light.properties | 2 +- .../gui/editor/mark/ComesFromMTMarker.java | 4 +- src/org/omegat/util/gui/Styles.java | 2 +- test/data/tmx/mt/mt1.tmx | 15 ++ .../editor/mark/ComesFromMTMarkerTest.java | 161 ++++++++++++++++++ 8 files changed, 183 insertions(+), 7 deletions(-) create mode 100644 test/data/tmx/mt/mt1.tmx create mode 100644 test/src/org/omegat/gui/editor/mark/ComesFromMTMarkerTest.java diff --git a/src/org/omegat/Bundle.properties b/src/org/omegat/Bundle.properties index e4fffd5370..136ce39815 100644 --- a/src/org/omegat/Bundle.properties +++ b/src/org/omegat/Bundle.properties @@ -2533,7 +2533,7 @@ COLOR_REMOVETEXT_TARGET=Flagged text COLOR_NBSP=Non-breakable spaces COLOR_WHITESPACE=Whitespaces COLOR_BIDIMARKERS=Bidirectional control characters -COLOR_MARK_COMES_FROM_TM=From memory +COLOR_MARK_COMES_FROM_TM_MT=From MT memory COLOR_MARK_COMES_FROM_TM_XICE=From ICE memory COLOR_MARK_COMES_FROM_TM_X100PC=From 100% memory COLOR_MARK_COMES_FROM_TM_XAUTO=From auto memory diff --git a/src/org/omegat/Bundle_ja.properties b/src/org/omegat/Bundle_ja.properties index 3a9eea8712..8770f18605 100644 --- a/src/org/omegat/Bundle_ja.properties +++ b/src/org/omegat/Bundle_ja.properties @@ -2327,7 +2327,7 @@ COLOR_REMOVETEXT_TARGET=\u30D5\u30E9\u30B0\u4ED8\u304D\u6587\u5B57\u5217 COLOR_NBSP=\u30CE\u30FC\u30D6\u30EC\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9 COLOR_WHITESPACE=\u7A7A\u767D\u6587\u5B57 COLOR_BIDIMARKERS=\u53CC\u65B9\u5411\u30A2\u30EB\u30B4\u30EA\u30BA\u30E0\u5236\u5FA1\u6587\u5B57 -COLOR_MARK_COMES_FROM_TM=\u5185\u90E8\u30E1\u30E2\u30EA\u7531\u6765\u306E\u5206\u7BC0 +COLOR_MARK_COMES_FROM_TM_MT=MT\u30E1\u30E2\u30EA\u7531\u6765\u306E\u5206\u7BC0 COLOR_MARK_COMES_FROM_TM_XICE=ICE \u30E1\u30E2\u30EA\u7531\u6765\u306E\u5206\u7BC0 COLOR_MARK_COMES_FROM_TM_X100PC=100% \u30E1\u30E2\u30EA\u7531\u6765\u306E\u5206\u7BC0 COLOR_MARK_COMES_FROM_TM_XAUTO=auto \u30E1\u30E2\u30EA\u7531\u6765\u306E\u5206\u7BC0 diff --git a/src/org/omegat/ColorScheme_dark.properties b/src/org/omegat/ColorScheme_dark.properties index e64e38d876..80ef322b45 100644 --- a/src/org/omegat/ColorScheme_dark.properties +++ b/src/org/omegat/ColorScheme_dark.properties @@ -13,7 +13,7 @@ OmegaT.nbsp=#c8c8c8 OmegaT.whiteSpace=#808080 OmegaT.bidiMarkers=#c80000 OmegaT.paragraphStart=#aeaeae -OmegaT.markComesFromTm=#fa8072 +OmegaT.markComesFromTmMt=#fa8072 OmegaT.markComesFromTmXice=#af76df OmegaT.markComesFromTmX100pc=#ff9408 OmegaT.markComesFromTmXauto=#ffd596 diff --git a/src/org/omegat/ColorScheme_light.properties b/src/org/omegat/ColorScheme_light.properties index 8bcb13fc62..2e6474fd5e 100644 --- a/src/org/omegat/ColorScheme_light.properties +++ b/src/org/omegat/ColorScheme_light.properties @@ -13,7 +13,7 @@ OmegaT.nbsp=#c8c8c8 OmegaT.whiteSpace=#808080 OmegaT.bidiMarkers=#c80000 OmegaT.paragraphStart=#aeaeae -OmegaT.markComesFromTm=#fa8072 +OmegaT.markComesFromTmMt=#fa8072 OmegaT.markComesFromTmXice=#af76df OmegaT.markComesFromTmX100pc=#ff9408 OmegaT.markComesFromTmXauto=#ffd596 diff --git a/src/org/omegat/gui/editor/mark/ComesFromMTMarker.java b/src/org/omegat/gui/editor/mark/ComesFromMTMarker.java index 3f12e4e85d..f7ee13111b 100644 --- a/src/org/omegat/gui/editor/mark/ComesFromMTMarker.java +++ b/src/org/omegat/gui/editor/mark/ComesFromMTMarker.java @@ -59,7 +59,7 @@ public void onEntryActivated(SourceTextEntry newEntry) { } }); highlightPainter = new TransparentHighlightPainter( - Styles.EditorColor.COLOR_MARK_COMES_FROM_TM.getColor(), 0.5F); + Styles.EditorColor.COLOR_MARK_COMES_FROM_TM_MT.getColor(), 0.5F); } public void setMark(SourceTextEntry ste, String text) { @@ -73,7 +73,7 @@ public void setMark(SourceTextEntry ste, String text) { public synchronized List getMarksForEntry(SourceTextEntry ste, String sourceText, String translationText, boolean isActive) { synchronized (this) { - if (!isActive || ste != markedSte || !translationText.equals(markedText)) { + if (!isActive || ste != markedSte || translationText == null || !translationText.equals(markedText)) { return null; } } diff --git a/src/org/omegat/util/gui/Styles.java b/src/org/omegat/util/gui/Styles.java index 2937971fd2..c7635dbcae 100644 --- a/src/org/omegat/util/gui/Styles.java +++ b/src/org/omegat/util/gui/Styles.java @@ -110,7 +110,7 @@ public enum EditorColor { COLOR_PARAGRAPH_START(UIManager.getColor("OmegaT.paragraphStart")), - COLOR_MARK_COMES_FROM_TM(UIManager.getColor("OmegaT.markComesFromTm")), + COLOR_MARK_COMES_FROM_TM_MT(UIManager.getColor("OmegaT.markComesFromTmMt")), COLOR_MARK_COMES_FROM_TM_XICE(UIManager.getColor("OmegaT.markComesFromTmXice")), diff --git a/test/data/tmx/mt/mt1.tmx b/test/data/tmx/mt/mt1.tmx new file mode 100644 index 0000000000..cbea88002f --- /dev/null +++ b/test/data/tmx/mt/mt1.tmx @@ -0,0 +1,15 @@ + + + +
+ + + + source + + + target + + + + diff --git a/test/src/org/omegat/gui/editor/mark/ComesFromMTMarkerTest.java b/test/src/org/omegat/gui/editor/mark/ComesFromMTMarkerTest.java new file mode 100644 index 0000000000..62b9e286be --- /dev/null +++ b/test/src/org/omegat/gui/editor/mark/ComesFromMTMarkerTest.java @@ -0,0 +1,161 @@ +/* + * 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.gui.editor.mark; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; + +import org.omegat.core.Core; +import org.omegat.core.TestCoreInitializer; +import org.omegat.core.data.DataUtils; +import org.omegat.core.data.EntryKey; +import org.omegat.core.data.NotLoadedProject; +import org.omegat.core.data.ProjectProperties; +import org.omegat.core.data.ProjectTMX; +import org.omegat.core.data.SourceTextEntry; +import org.omegat.core.data.TMXEntry; +import org.omegat.core.matching.NearString; +import org.omegat.core.segmentation.SRX; +import org.omegat.core.segmentation.Segmenter; +import org.omegat.util.Language; + +public class ComesFromMTMarkerTest extends MarkerTestBase { + + private ProjectTMX projectTMX; + private Path tmroot; + private Path project; + + @Before + public void preUp() throws Exception { + tmroot = Paths.get("test/data/tmx/"); + project = tmroot.resolve("mt/mt1.tmx"); // should under 'mt' + TestCoreInitializer.initEditor(editor); + Core.setSegmenter(new Segmenter(SRX.getDefault())); + projectTMX = new ProjectTMX(new Language("en"), new Language("fr"), true, + project.toFile(), null); + Core.setProject(new NotLoadedProject() { + @Override + public boolean isProjectLoaded() { + return true; + } + + @Override + public ProjectProperties getProjectProperties() { + return new ProjectProperties() { + @Override + public Language getSourceLanguage() { + return new Language("en"); + } + + @Override + public Language getTargetLanguage() { + return new Language("fr"); + } + + @Override + public String getTMRoot() { + return tmroot.toString(); + } + + }; + } + + @Override + public TMXEntry getTranslationInfo(SourceTextEntry ste) { + if (ste == null || projectTMX == null) { + return EMPTY_TRANSLATION; + } + TMXEntry r = projectTMX.getMultipleTranslation(ste.getKey()); + if (r == null) { + r = projectTMX.getDefaultTranslation(ste.getSrcText()); + } + if (r == null) { + r = EMPTY_TRANSLATION; + } + return r; + } + + }); + } + + @Test + public void testMarkersDisabled() throws Exception { + IMarker marker = new ComesFromMTMarker(); + assertThat(marker.getMarksForEntry(null, null, null, true)) + .describedAs("marker should return null when ste, sourceText and translationText is null") + .isNull(); + } + + @Test + public void testMarkersNotActive() throws Exception { + IMarker marker = new ComesFromMTMarker(); + final String sourceText = "source"; + final String targetText = "target"; + EntryKey key = new EntryKey("file", sourceText, "id", "prev", "next", "path"); + SourceTextEntry ste = new SourceTextEntry(key, 1, new String[0], sourceText, Collections.emptyList()); + assertThat(marker.getMarksForEntry(ste, sourceText, targetText, false)) + .describedAs("marker should return null when ste is not active") + .isNull(); + } + + @Test + public void testMarkersMT() { + ComesFromMTMarker marker = new ComesFromMTMarker(); + final String sourceText = "source"; + final String targetText = "target"; + EntryKey key = new EntryKey("file", sourceText, "id", "prev", "next", "path"); + SourceTextEntry ste = new SourceTextEntry(key, 1, new String[0], sourceText, Collections.emptyList()); + marker.setMark(ste, targetText); + List result = marker.getMarksForEntry(ste, sourceText, targetText, true); + assertNotNull(result); + assertEquals(1, result.size()); + assertEquals(0, result.get(0).startOffset); + assertEquals(6, result.get(0).endOffset); + assertEquals("TRANSLATION", result.get(0).entryPart.toString()); + } + + @Test + public void testNearString() { + final String sourceText = "source"; + final String targetText = "target"; + final String user = "translator"; + final int score = 75; + final byte[] nearData = null; + final long date = 10000L; + EntryKey key = new EntryKey("file", sourceText, "id", "prev", "next", "path"); + NearString near = new NearString(key, sourceText, targetText, NearString.MATCH_SOURCE.TM, false, + score, score, score, nearData, project.toString(), user, date, user, date, Collections.emptyList()); + assertThat(DataUtils.isFromMTMemory(near)).isTrue(); + } +} From a580d98812f13f9ab53cfacbf89985da68a6d59e Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 5 Oct 2024 10:26:05 +0900 Subject: [PATCH 64/85] fix(test): avoid NPE when aborting long running thread (#1156) Signed-off-by: Hiroshi Miura --- .../org/omegat/core/statistics/CalcMatchStatisticsTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/src/org/omegat/core/statistics/CalcMatchStatisticsTest.java b/test/src/org/omegat/core/statistics/CalcMatchStatisticsTest.java index 647a5a0479..34c7bfbaf6 100644 --- a/test/src/org/omegat/core/statistics/CalcMatchStatisticsTest.java +++ b/test/src/org/omegat/core/statistics/CalcMatchStatisticsTest.java @@ -375,18 +375,24 @@ static class CalcMatchStatisticsMock extends CalcMatchStatistics { "RowMatch85", "RowMatch75", "RowMatch50", "RowNoMatch", "Total" }; private MatchStatCounts result; + private final IStatsConsumer callback; CalcMatchStatisticsMock(IStatsConsumer callback) { super(callback, false); + this.callback = callback; } @Override public void run() { entriesToProcess = Core.getProject().getAllEntries().size(); result = calcTotal(false); + callback.finishData(); } public String[][] getTable() { + if (result == null) { + return null; + } return result.calcTable(rowsTotal, i -> i != 1); } } From 92cdcdaf65aae6fc82e825924d798d687567452c Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 5 Oct 2024 10:27:49 +0900 Subject: [PATCH 65/85] improve test robustness against network reachability (#1155) * chore(test): allow XML comparison on offline environment Java JAXB XML library access remote network to validate DTD. This change allows test cases not to validate with DTD. Signed-off-by: Hiroshi Miura * fix: LanguageToolTest#testRemoteServer - Check free port for the test server Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- .../org/omegat/filters/TestFilterBase.java | 15 +++++++++-- .../languagetools/LanguageToolTest.java | 27 ++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/test/src/org/omegat/filters/TestFilterBase.java b/test/src/org/omegat/filters/TestFilterBase.java index e2c4df32ef..e8af4a8043 100644 --- a/test/src/org/omegat/filters/TestFilterBase.java +++ b/test/src/org/omegat/filters/TestFilterBase.java @@ -50,6 +50,8 @@ import org.junit.Rule; import org.junit.rules.TestName; import org.w3c.dom.Document; +import org.xmlunit.diff.DefaultNodeMatcher; +import org.xmlunit.diff.ElementSelectors; import org.omegat.core.Core; import org.omegat.core.TestCore; @@ -72,8 +74,6 @@ import org.omegat.tokenizer.DefaultTokenizer; import org.omegat.util.Language; import org.omegat.util.TMXReader2; -import org.xmlunit.diff.DefaultNodeMatcher; -import org.xmlunit.diff.ElementSelectors; /** * Base class for testing filter parsing. @@ -421,6 +421,11 @@ public static void compareBinary(File f1, File f2) throws Exception { protected void compareTMX(File f1, File f2) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); + factory.setValidating(false); + factory.setFeature("http://xml.org/sax/features/namespaces", true); + factory.setFeature("http://xml.org/sax/features/validation", false); + factory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); + factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); DocumentBuilder builder = factory.newDocumentBuilder(); builder.setEntityResolver(TMXReader2.TMX_DTD_RESOLVER); @@ -440,6 +445,12 @@ protected void compareXML(File f1, File f2) throws Exception { protected void compareXML(URL f1, URL f2) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(false); + factory.setValidating(false); + factory.setFeature("http://xml.org/sax/features/namespaces", false); + factory.setFeature("http://xml.org/sax/features/validation", false); + factory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); + factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); DocumentBuilder builder = factory.newDocumentBuilder(); var doc1 = builder.parse(f1.toExternalForm()); var doc2 = builder.parse(f2.toExternalForm()); diff --git a/test/src/org/omegat/languagetools/LanguageToolTest.java b/test/src/org/omegat/languagetools/LanguageToolTest.java index ec177c9301..212627089e 100644 --- a/test/src/org/omegat/languagetools/LanguageToolTest.java +++ b/test/src/org/omegat/languagetools/LanguageToolTest.java @@ -28,10 +28,13 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; +import java.io.IOException; +import java.net.ServerSocket; import java.util.Collections; import java.util.List; import java.util.Locale; @@ -44,6 +47,7 @@ import org.languagetool.rules.RuleMatch; import org.languagetool.rules.patterns.PatternRule; import org.languagetool.server.HTTPServer; +import org.languagetool.server.HTTPServerConfig; import org.omegat.util.Language; import org.omegat.util.Preferences; @@ -103,18 +107,35 @@ public void testEnglish() throws Exception { assertEquals(0, matches.size()); } + private static final int[] FREE_PORT_RANGE = {8081, 10080, 10081, 10082, 10083, 10084, 10085, 10086}; + + private int getFreePort() { + for (int p : FREE_PORT_RANGE) { + try (ServerSocket serverSocket = new ServerSocket(p)) { + return serverSocket.getLocalPort(); + } catch (IOException ignored) { + } + } + return -1; + } + @Test public void testRemoteServer() throws Exception { - HTTPServer server = new HTTPServer(); + int port = getFreePort(); + assertNotEquals("Port has been already used.", -1, port); + HTTPServerConfig config = new HTTPServerConfig(port); + HTTPServer server = new HTTPServer(config); try { server.run(); + String urlBase = "http://localhost:" + port; + assertThrows("URL not specifying API actions should fail due to missing argument.", java.lang.Exception.class, - () -> new LanguageToolNetworkBridge(SOURCE_LANG, TARGET_LANG, "http://localhost:8081")); + () -> new LanguageToolNetworkBridge(SOURCE_LANG, TARGET_LANG, urlBase)); ILanguageToolBridge bridge = new LanguageToolNetworkBridge(SOURCE_LANG, TARGET_LANG, - "http://localhost:8081/v2/check"); + urlBase + "/v2/check"); // Set some rules to prevent the server from looking at config // files. From 5587a9c74883aaded5893bc1d3163af02fa19f8e Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 5 Oct 2024 19:09:22 +0900 Subject: [PATCH 66/85] fix: isGUI detect properly (#1133) * fix: isGUI detect properly - resolve BUGS#1267 Console-stats command failed with error Signed-off-by: Hiroshi Miura * refactor: StaticUIUtils#isGUI - Move util method to StaticUIUtils class - Add unit Signed-off-by: Hiroshi Miura * refactor: StaticUIUtils - Add javadoc - Use lambda for Action object creation Signed-off-by: Hiroshi Miura --------- Signed-off-by: Hiroshi Miura --- .../team2/impl/GITCredentialsProvider.java | 9 +- src/org/omegat/gui/main/ConsoleWindow.java | 2 +- src/org/omegat/util/FunctionalAction.java | 54 ++++++++++++ src/org/omegat/util/gui/StaticUIUtils.java | 83 ++++++++++--------- .../omegat/util/gui/StaticUIUtilsTest.java | 17 ++++ 5 files changed, 121 insertions(+), 44 deletions(-) create mode 100644 src/org/omegat/util/FunctionalAction.java diff --git a/src/org/omegat/core/team2/impl/GITCredentialsProvider.java b/src/org/omegat/core/team2/impl/GITCredentialsProvider.java index 06e8d50603..e92364caf5 100644 --- a/src/org/omegat/core/team2/impl/GITCredentialsProvider.java +++ b/src/org/omegat/core/team2/impl/GITCredentialsProvider.java @@ -52,6 +52,7 @@ import org.omegat.gui.main.IMainWindow; import org.omegat.util.Log; import org.omegat.util.OStrings; +import org.omegat.util.gui.StaticUIUtils; /** * Git repository credentials provider. One credential provider created for all @@ -279,10 +280,6 @@ public boolean supports(CredentialItem... items) { return true; } - private boolean isGUI() { - return Core.getMainWindow() != null; - } - private void askYesNoGUI(CredentialItem item, String promptText, URIish uri, String promptedFingerprint) { IMainWindow mw = Core.getMainWindow(); int choice = mw.showConfirmDialog(promptText, null, JOptionPane.YES_NO_OPTION, @@ -305,7 +302,7 @@ private void askYesNoCUI(CredentialItem item, String promptText, URIish uri, Str } private void askYesNo(CredentialItem item, String promptText, URIish uri, String promptedFingerprint) { - if (isGUI()) { + if (StaticUIUtils.isGUI()) { askYesNoGUI(item, promptText, uri, promptedFingerprint); } else { askYesNoCUI(item, promptText, uri, promptedFingerprint); @@ -403,7 +400,7 @@ private Credentials askCredentialsCUI(URIish uri, Credentials credentials, boole private Credentials askCredentials(URIish uri, Credentials credentials, boolean passwordOnly, String msg) { Credentials result; - if (isGUI()) { + if (StaticUIUtils.isGUI()) { result = askCredentialsGUI(uri, credentials, passwordOnly, msg); } else { result = askCredentialsCUI(uri, credentials, passwordOnly, msg); diff --git a/src/org/omegat/gui/main/ConsoleWindow.java b/src/org/omegat/gui/main/ConsoleWindow.java index ee144ea017..62d4554286 100644 --- a/src/org/omegat/gui/main/ConsoleWindow.java +++ b/src/org/omegat/gui/main/ConsoleWindow.java @@ -115,7 +115,7 @@ public Font getApplicationFont() { } public JFrame getApplicationFrame() { - throw new NoSuchMethodError("Invalid call of ConsoleWindow"); + return null; } public void lockUI() { diff --git a/src/org/omegat/util/FunctionalAction.java b/src/org/omegat/util/FunctionalAction.java new file mode 100644 index 0000000000..fb3d175f0c --- /dev/null +++ b/src/org/omegat/util/FunctionalAction.java @@ -0,0 +1,54 @@ +/************************************************************************** + 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.util; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.AbstractAction; + +public class FunctionalAction extends AbstractAction { + private static final long serialVersionUID = 1L; + + ActionListener action; + + public FunctionalAction(ActionListener action) { + this.action = action; + } + + @Override + public void actionPerformed(ActionEvent e) { + action.actionPerformed(e); + } + + public ActionListener getAction() { + return action; + } + + public void setAction(ActionListener newAction) { + this.action = newAction; + } +} diff --git a/src/org/omegat/util/gui/StaticUIUtils.java b/src/org/omegat/util/gui/StaticUIUtils.java index df31fca87a..8a382d6f89 100644 --- a/src/org/omegat/util/gui/StaticUIUtils.java +++ b/src/org/omegat/util/gui/StaticUIUtils.java @@ -6,6 +6,7 @@ Copyright (C) 2006 Henry Pijffers 2013 Yu Tang 2014-2015 Aaron Madlon-Kay + 2024 Hiroshi Miura Home page: https://www.omegat.org/ Support center: https://omegat.org/support @@ -36,7 +37,6 @@ import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.Window; -import java.awt.event.ActionEvent; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.FocusAdapter; @@ -47,12 +47,12 @@ import java.awt.event.WindowEvent; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import java.util.function.Predicate; -import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JComponent; import javax.swing.JDialog; @@ -67,7 +67,8 @@ import org.omegat.core.Core; import org.omegat.gui.main.DockableScrollPane; -import org.omegat.util.Java8Compat; +import org.omegat.gui.main.IMainWindow; +import org.omegat.util.FunctionalAction; import org.omegat.util.Platform; import org.omegat.util.Preferences; import org.omegat.util.StringUtil; @@ -93,9 +94,10 @@ private StaticUIUtils() { * {@link JDialog#dispose()} will be called. * * @param dialog + * to configure. */ public static void setEscapeClosable(JDialog dialog) { - setEscapeAction(dialog.getRootPane(), makeCloseAction(dialog)); + setEscapeAction(dialog.getRootPane(), new FunctionalAction(e -> closeWindowByEvent(dialog))); } /** @@ -103,19 +105,10 @@ public static void setEscapeClosable(JDialog dialog) { * will be called. * * @param frame + * to configure. */ public static void setEscapeClosable(JFrame frame) { - setEscapeAction(frame.getRootPane(), makeCloseAction(frame)); - } - - @SuppressWarnings("serial") - public static Action makeCloseAction(final Window window) { - return new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - closeWindowByEvent(window); - } - }; + setEscapeAction(frame.getRootPane(), new FunctionalAction(e -> closeWindowByEvent(frame))); } /** @@ -130,7 +123,9 @@ public static void closeWindowByEvent(Window window) { * Associate a custom action to be called when the Esc key is pressed. * * @param dialog + * target dialog. * @param action + * object to set. */ public static void setEscapeAction(JDialog dialog, Action action) { setEscapeAction(dialog.getRootPane(), action); @@ -140,7 +135,9 @@ public static void setEscapeAction(JDialog dialog, Action action) { * Associate a custom action to be called when the Esc key is pressed. * * @param frame + * target frame. * @param action + * object to set. */ public static void setEscapeAction(JFrame frame, Action action) { setEscapeAction(frame.getRootPane(), action); @@ -150,7 +147,9 @@ public static void setEscapeAction(JFrame frame, Action action) { * Associate a custom action to be called when the Esc key is pressed. * * @param pane + * target UI pane. * @param action + * object to set. */ public static void setEscapeAction(JRootPane pane, Action action) { // Handle escape key to close the window @@ -215,8 +214,7 @@ public static String truncateToFit(String text, JComponent comp, int margin) { } if (chomp != null) { - text = text.substring(0, chompStart) + StringUtil.TRUNCATE_CHAR - + text.substring(chompEnd, text.length()); + text = text.substring(0, chompStart) + StringUtil.TRUNCATE_CHAR + text.substring(chompEnd); } return text; } @@ -319,6 +317,14 @@ public static void visitHierarchy(Component parent, Predicate filter, } } + /** + * list hierarchy for debug. + * + * @param parent + * component to determine. + * @return list of components. + */ + @SuppressWarnings("unused") public static List listHierarchy(Component parent) { List cs = new ArrayList<>(); visitHierarchy(parent, cs::add); @@ -374,7 +380,7 @@ public void componentResized(ComponentEvent e) { public static void setWindowIcon(Window window) { List icons; if (Platform.isMacOSX()) { - icons = Arrays.asList(OSXIntegration.APP_ICON_MAC); + icons = Collections.singletonList(OSXIntegration.APP_ICON_MAC); } else { icons = Arrays.asList(ResourcesUtil.APP_ICON_16X16, ResourcesUtil.APP_ICON_32X32); } @@ -431,34 +437,29 @@ public static String getKeyStrokeText(KeyStroke ks) { return sb.toString(); } - @SuppressWarnings("serial") public static void makeUndoable(JTextComponent comp) { UndoManager manager = new UndoManager(); comp.getDocument().addUndoableEditListener(manager); // Handle undo (Ctrl/Cmd+Z); - KeyStroke undo = KeyStroke.getKeyStroke(KeyEvent.VK_Z, Java8Compat.getMenuShortcutKeyMaskEx(), false); - Action undoAction = new AbstractAction() { - public void actionPerformed(ActionEvent e) { - if (manager.canUndo()) { - manager.undo(); - } - } - }; + KeyStroke undo = KeyStroke.getKeyStroke(KeyEvent.VK_Z, + Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false); comp.getInputMap().put(undo, "UNDO"); - comp.getActionMap().put("UNDO", undoAction); + comp.getActionMap().put("UNDO", new FunctionalAction(e -> { + if (manager.canUndo()) { + manager.undo(); + } + })); // Handle redo (Ctrl/Cmd+Y); - KeyStroke redo = KeyStroke.getKeyStroke(KeyEvent.VK_Y, Java8Compat.getMenuShortcutKeyMaskEx(), false); - Action redoAction = new AbstractAction() { - public void actionPerformed(ActionEvent e) { - if (manager.canRedo()) { - manager.redo(); - } - } - }; + KeyStroke redo = KeyStroke.getKeyStroke(KeyEvent.VK_Y, + Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), false); comp.getInputMap().put(redo, "REDO"); - comp.getActionMap().put("REDO", redoAction); + comp.getActionMap().put("REDO", new FunctionalAction(e -> { + if (manager.canRedo()) { + manager.redo(); + } + })); } /** @@ -471,4 +472,12 @@ public static void requestVisible(DockableScrollPane scrollPane) { desktop.setAutoHide(dockable, false); } } + + /** + * Whether run on GUI or not. + */ + public static boolean isGUI() { + IMainWindow mainWindow = Core.getMainWindow(); + return mainWindow != null && mainWindow.getApplicationFrame() != null; + } } diff --git a/test/src/org/omegat/util/gui/StaticUIUtilsTest.java b/test/src/org/omegat/util/gui/StaticUIUtilsTest.java index 00ddc12f3c..a372443014 100644 --- a/test/src/org/omegat/util/gui/StaticUIUtilsTest.java +++ b/test/src/org/omegat/util/gui/StaticUIUtilsTest.java @@ -26,14 +26,26 @@ package org.omegat.util.gui; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import java.awt.Color; import java.util.stream.IntStream; +import org.junit.Before; import org.junit.Test; +import org.omegat.core.TestCoreInitializer; +import org.omegat.gui.main.ConsoleWindow; +import org.omegat.gui.main.IMainWindow; + public class StaticUIUtilsTest { + @Before + public void setUp() throws Exception { + IMainWindow mainWindow = new ConsoleWindow(); + TestCoreInitializer.initMainWindow(mainWindow); + } + @Test public void testGetHighlightColor() { // Don't make an invalid color even with big or edge-casey adjustment values @@ -44,4 +56,9 @@ public void testGetHighlightColor() { assertEquals(new Color(245, 245, 245), StaticUIUtils.getHighlightColor(Color.WHITE, 10)); assertEquals(new Color(245, 245, 245), StaticUIUtils.getHighlightColor(Color.WHITE, -10)); } + + @Test + public void testIsGUI() { + assertFalse("Run with ConsoleWindow", StaticUIUtils.isGUI()); + } } From 03aad92a34020f85570c7d304b2dc77885ee0262 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 5 Oct 2024 19:13:51 +0900 Subject: [PATCH 67/85] docs: update changes.txt - add BUGS#1267 Signed-off-by: Hiroshi Miura --- release/changes.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/release/changes.txt b/release/changes.txt index 9a24463989..9d8c1873dc 100644 --- a/release/changes.txt +++ b/release/changes.txt @@ -2,7 +2,7 @@ OmegaT 6.1.0 ---------------------------------------------------------------------- 45 Enhancement - 73 Bug fixes + 74 Bug fixes 5 Localisation updates ---------------------------------------------------------------------- 6.1.0 vs 6.0.0 @@ -139,6 +139,9 @@ Bug fixes: + - Console-stats command failed with error + https://sourceforge.net/p/omegat/bugs/1267/ + - Removal of MED package save/load feature https://sourceforge.net/p/omegat/bugs/1266/ From 50d40a271081e59ab7a2993ee8d30cac1ae0440c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 07:09:13 +0900 Subject: [PATCH 68/85] chore(deps): bump com.github.spotbugs from 6.0.24 to 6.0.25 (#1161) Bumps com.github.spotbugs from 6.0.24 to 6.0.25. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8b5261c4d3..65e4082173 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -184,7 +184,7 @@ dictionary = ["trie4j", "dsl4j", "stardict4j", "jsoup"] xmlunit = ["xmlunit-core", "xmlunit-assertj", "assertj"] [plugins] -spotbugs = {id = "com.github.spotbugs", version = "6.0.24"} +spotbugs = {id = "com.github.spotbugs", version = "6.0.25"} spotless = {id = "com.diffplug.spotless", version = "6.25.0"} launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.6"} versions = {id = "com.github.ben-manes.versions", version = "0.51.0"} From 0beee4564811a6625babdff51d6022babb311289 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 31 Oct 2024 07:20:37 +0900 Subject: [PATCH 69/85] fix: spell: look for LT bundle spelling/ folder (#1167) Signed-off-by: Hiroshi Miura --- .../morfologik/MorfologikSpellchecker.java | 18 +++++++++++++++--- .../omegat/languagetools/LanguageManager.java | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/spellchecker/morfologik/src/main/java/org/omegat/spellchecker/morfologik/MorfologikSpellchecker.java b/spellchecker/morfologik/src/main/java/org/omegat/spellchecker/morfologik/MorfologikSpellchecker.java index 252f6bb7de..dd8f0f8ad6 100644 --- a/spellchecker/morfologik/src/main/java/org/omegat/spellchecker/morfologik/MorfologikSpellchecker.java +++ b/spellchecker/morfologik/src/main/java/org/omegat/spellchecker/morfologik/MorfologikSpellchecker.java @@ -93,16 +93,28 @@ protected Optional initializeWithLanguage(final String la return Optional.empty(); } + private String findDictionaryFolderInLTJar(String language) { + final String[] folders = new String[] {"/hunspell/", "/spelling/"}; + for (String folder : folders) { + String path = "/" + new Language(language).getLanguageCode() + folder + language; + if (JLanguageTool.getDataBroker().resourceExists(path + SC_DICT_EXTENSION)) { + return path; + } + } + return null; + } + /** * If there is a Morfologik dictionary for the current target language * bundled with LanguageTool, install it. */ private void installLTBundledDictionary(String dictionaryDir, String language) { - String resPath = "/" + new Language(language).getLanguageCode() + "/hunspell/" + language + SC_DICT_EXTENSION; - String infoPath = "/" + new Language(language).getLanguageCode() + "/hunspell/" + language + SC_INFO_EXTENSION; - if (!JLanguageTool.getDataBroker().resourceExists(resPath)) { + String path = findDictionaryFolderInLTJar(language); + if (path == null) { return; } + String resPath = path + SC_DICT_EXTENSION; + String infoPath = path + SC_INFO_EXTENSION; try { try (InputStream dictStream = JLanguageTool.getDataBroker().getFromResourceDirAsStream(resPath); FileOutputStream fos = new FileOutputStream( diff --git a/src/org/omegat/languagetools/LanguageManager.java b/src/org/omegat/languagetools/LanguageManager.java index fb008773ff..ce53e5d803 100644 --- a/src/org/omegat/languagetools/LanguageManager.java +++ b/src/org/omegat/languagetools/LanguageManager.java @@ -65,7 +65,7 @@ public static Language getLTLanguage(org.omegat.util.Language lang) { return null; } // search for language-country code. - String fqcn = LT_LANGUAGE_CLASSES.get(lang.getLanguage()); + String fqcn = LT_LANGUAGE_CLASSES.get(lang.getLanguage().replace("_", "-")); if (fqcn != null) { result = Languages.getOrAddLanguageByClassName(fqcn); } From 23d20eac480552112e91edce019b9ae68a999c08 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 31 Oct 2024 07:41:29 +0900 Subject: [PATCH 70/85] docs: update changes.txt - Add RFE#1753,1748,1746,1734,1714 - Add feature of AppertiumMT - Add BUGS#1271,1265,1262,1261,1258,1253,847 Signed-off-by: Hiroshi Miura --- release/changes.txt | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/release/changes.txt b/release/changes.txt index 9d8c1873dc..e6cf4555cb 100644 --- a/release/changes.txt +++ b/release/changes.txt @@ -1,17 +1,31 @@ ---------------------------------------------------------------------- OmegaT 6.1.0 ---------------------------------------------------------------------- - 45 Enhancement - 74 Bug fixes + 51 Enhancement + 81 Bug fixes 5 Localisation updates ---------------------------------------------------------------------- 6.1.0 vs 6.0.0 Implemented requests: + - Log filename to be date-time based + https://sourceforge.net/p/omegat/feature-requests/1753/ + + - Support Morfologik spell checker and use LT bundled dictionary + https://sourceforge.net/p/omegat/feature-requests/1748/ + + - Support U*ix variants + https://sourceforge.net/p/omegat/feature-requests/1746 + - Alternative translation highlight https://sourceforge.net/p/omegat/feature-requests/1736/ + - Add timestamp to log + https://sourceforge.net/p/omegat/feature-requests/1734/ + + - Apertium MT now sends whole locale code to server instead of only the language code + - Support for Stardict's Pango content type https://sourceforge.net/p/omegat/feature-requests/1727/ @@ -39,6 +53,9 @@ - Make repository connectors as plugin https://sourceforge.net/p/omegat/feature-requests/1715/ + - Make language libraries in LanguageTools as module + https://sourceforge.net/p/omegat/feature-requests/1714/ + - ResourceBundle filter: "Don't translate NOI18N comment" feature optional https://sourceforge.net/p/omegat/feature-requests/1713/ @@ -139,18 +156,36 @@ Bug fixes: + - Speller: morfologik: LT bundled dictionary not found in Dutch + https://sourceforge.net/p/omegat/bugs/1271/ + - Console-stats command failed with error https://sourceforge.net/p/omegat/bugs/1267/ - Removal of MED package save/load feature https://sourceforge.net/p/omegat/bugs/1266/ + - Failed to load "en-AU" LT language by IllegalArgumentException + https://sourceforge.net/p/omegat/bugs/1265/ + - filter: bundle: when charsert configuration is US_ASCII, force unicode escape https://sourceforge.net/p/omegat/bugs/1264/ + - OmegaT 6.1 does not write startup message in log file + https://sourceforge.net/p/omegat/bugs/1262/ + + - Color customize UI label for marker come from tm/mt/ folder + https://sourceforge.net/p/omegat/bugs/1261/ + + - Fix behaviour where git repos would be recognised as SVN + https://sourceforge.net/p/omegat/bugs/1258/ + - OmegaT does not show entreis of stardict-JMDict dictionary https://sourceforge.net/p/omegat/bugs/1255/ + - Links with ending parens in glossary panes + https://sourceforge.net/p/omegat/bugs/1253/ + - Short glossary items are not recognized with Korean source https://sourceforge.net/p/omegat/bugs/1250/ @@ -349,6 +384,9 @@ - Manually assigned shortcuts open parent folders instead of files https://sourceforge.net/p/omegat/bugs/858/ + - Team projects not saving properly or stopping synchronization + https://sourceforge.net/p/omegat/bugs/847/ + - Lucene 5.2 does not work under WebStart https://sourceforge.net/p/omegat/bugs/813/ From f1dbf0573fe68c0094f92947b049149853217549 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 08:34:11 +0900 Subject: [PATCH 71/85] chore(deps): bump org.wiremock:wiremock from 3.9.1 to 3.9.2 (#1163) Bumps [org.wiremock:wiremock](https://github.com/wiremock/wiremock) from 3.9.1 to 3.9.2. - [Release notes](https://github.com/wiremock/wiremock/releases) - [Commits](https://github.com/wiremock/wiremock/compare/3.9.1...3.9.2) --- updated-dependencies: - dependency-name: org.wiremock:wiremock dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 65e4082173..997ee1ba55 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -25,7 +25,7 @@ jackson = "2.16.1" bc = "1.78.1" nashorn = "15.4" caffeine = "3.1.8" -wiremock = "3.9.1" +wiremock = "3.9.2" vldocking = "3.1.1" xmlunit = "2.10.0" assertj = "3.26.0" From 43f12502e2f393e0ab1a29cafc3c0d88201ba41e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 08:35:31 +0900 Subject: [PATCH 72/85] chore(deps): bump com.formdev:flatlaf from 3.5.1 to 3.5.2 (#1162) Bumps [com.formdev:flatlaf](https://github.com/JFormDesigner/FlatLaf) from 3.5.1 to 3.5.2. - [Release notes](https://github.com/JFormDesigner/FlatLaf/releases) - [Changelog](https://github.com/JFormDesigner/FlatLaf/blob/main/CHANGELOG.md) - [Commits](https://github.com/JFormDesigner/FlatLaf/compare/3.5.1...3.5.2) --- updated-dependencies: - dependency-name: com.formdev:flatlaf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 997ee1ba55..9245ac7c97 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -49,7 +49,7 @@ xjc = "2.3.9" jna = "5.13.0" jfa = "1.2.0" tipoftheday = "0.4.4" -flatlaf="3.5.1" +flatlaf="3.5.2" assertj_swing_junit = "4.0.0-beta-2" morfologik = "2.1.9" jaxb = "2.3.0" From ec5af022b5562b7ec263098249bfd9e2d9985a81 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Fri, 1 Nov 2024 09:39:04 +0900 Subject: [PATCH 73/85] chore: set logger.properties for test It allows developers to manipulate logging levels in precise easily. - Add config/test/logger.properties - Only logging on console when testing - set system property j.u.l.config.file Signed-off-by: Hiroshi Miura --- build.gradle | 12 ++++++++++-- config/test/logger.properties | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 config/test/logger.properties diff --git a/build.gradle b/build.gradle index 9bd5ecdd6e..a900f60e94 100644 --- a/build.gradle +++ b/build.gradle @@ -372,7 +372,9 @@ dependencies { testImplementation(libs.bundles.xmlunit) testImplementation(project(":language-modules")) - testImplementation(libs.languagetool.server) + testImplementation(libs.languagetool.server) { + exclude module: "logback-classic" + } testRuntimeOnly(libs.slf4j.jdk14) // JAXB codegen only @@ -1587,6 +1589,7 @@ test { if (project.hasProperty('headless')) { systemProperty 'java.awt.headless', 'true' } + systemProperty 'java.util.logging.config.file', "${rootDir}/config/test/logger.properties" } tasks.register('testIntegration', JavaExec) { @@ -1599,6 +1602,7 @@ tasks.register('testIntegration', JavaExec) { mainClass = 'org.omegat.core.data.TestTeamIntegration' classpath = sourceSets.testIntegration.runtimeClasspath systemProperties = System.properties + systemProperty 'java.util.logging.config.file', "${rootDir}/config/test/logger.properties" } tasks.register('testOnJava17', Test) { @@ -1607,9 +1611,11 @@ tasks.register('testOnJava17', Test) { languageVersion = JavaLanguageVersion.of(17) vendor = JvmVendorSpec.ADOPTIUM } + systemProperties = System.properties if (project.hasProperty('headless')) { systemProperty 'java.awt.headless', 'true' } + systemProperty 'java.util.logging.config.file', "${rootDir}/config/test/logger.properties" group = 'verification' } @@ -1619,9 +1625,11 @@ tasks.register('testOnJava21', Test) { languageVersion = JavaLanguageVersion.of(21) vendor = JvmVendorSpec.ADOPTIUM } + systemProperties = System.properties if (project.hasProperty('headless')) { systemProperty 'java.awt.headless', 'true' } + systemProperty 'java.util.logging.config.file', "${rootDir}/config/test/logger.properties" group = 'verification' } @@ -1637,7 +1645,7 @@ tasks.register('testAcceptance', Test) { testClassesDirs = sourceSets.testAcceptance.output.classesDirs classpath = sourceSets.testAcceptance.runtimeClasspath systemProperties = System.properties - shouldRunAfter(tasks.test) + systemProperty 'java.util.logging.config.file', "${rootDir}/config/test/logger.properties" } ext.mavenStyleVersion = version.replace('_', '-') diff --git a/config/test/logger.properties b/config/test/logger.properties new file mode 100644 index 0000000000..7c88a237c4 --- /dev/null +++ b/config/test/logger.properties @@ -0,0 +1,35 @@ +handlers = java.util.logging.ConsoleHandler + +# Set the default logging level for the root logger +.level = INFO +org.omegat.level = ALL + +# Set the default logging level +java.util.logging.ConsoleHandler.level = ALL +org.omegat.util.logging.OmegaTFileHandler.level = ALL + +#org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $level: $text $key +org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $threadName [$level] $key $text +#org.omegat.util.logging.OmegaTLogFormatter.mask=$mark: $level: $text $key + +org.omegat.util.logging.OmegaTLogFormatter.timeFormat=HH:mm:ss.SSS + +java.util.logging.ConsoleHandler.formatter = org.omegat.util.logging.OmegaTLogFormatter + +# precise control of log levels, please change when debug +org.omegat.core.data.level = INFO +org.omegat.core.threads.level = INFO +org.omegat.core.team2.impl.level = INFO +org.omegat.core.team2.level = INFO +org.omegat.gui.editor.history.level = INFO +org.omegat.gui.matches.level = INFO +org.omegat.util.gui.level = INFO +org.omegat.util.level = INFO + +# Suppress warning from depndency jStyleParser +cz.vutbr.web.level = SEVERE +org.fit.net.level = SEVERE + +# We can enable specific logging level for some classes +#org.omegat.core.data.SaveThread.level = FINEST +org.omegat.core.segmentation.level = FINEST From 123f1ce373e6772d64a7ef453a7b3e306d5d95c1 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 3 Nov 2024 08:13:20 +0900 Subject: [PATCH 74/85] chore: use xvfb for acceptance test Signed-off-by: Hiroshi Miura --- build.gradle | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/build.gradle b/build.gradle index a900f60e94..a2dbeb3f9e 100644 --- a/build.gradle +++ b/build.gradle @@ -1633,7 +1633,60 @@ tasks.register('testOnJava21', Test) { group = 'verification' } +def startX(display) { + def outputStream = new ByteArrayOutputStream() + exec { + commandLine 'sh', '-c', "Xvfb :${display} -screen 0 1280x1024x24 >>/dev/null 2>&1 & echo \$!" + standardOutput = outputStream + } + def xvfbPid = outputStream.toString().trim() + println "Virtual X server is started with DISPLAY :${display} and PID: ${xvfbPid}" + return xvfbPid +} + +def stopX(pid) { + println "Stopping virtual X server..." + def outputStream = new ByteArrayOutputStream() + exec { + commandLine 'sh', '-c', "kill ${pid} &" + standardOutput = outputStream + errorOutput = outputStream + } +} + +def isCommandAvailable(command) { + def outputStream = new ByteArrayOutputStream() + exec { + commandLine 'sh', '-c', "command -v ${command}" + ignoreExitValue true + standardOutput = outputStream + errorOutput = outputStream + }.exitValue == 0 +} + tasks.register('testAcceptance', Test) { + onlyIf { + isCommandAvailable('Xvfb') + } + def display = 99 + doFirst { + if (display != null) { + def lockFile = new File("/tmp/.X${display}-lock") + if (!lockFile.exists()) { + ext.xvfbPid = startX(display) + environment 'DISPLAY', ":${display}" + } + } + } + doLast { + if (display != null) { + def pid = ext.has('xvfbPid') ? ext.xvfbPid : null + if (pid != null) { + stopX(pid) + } + } + } + description = 'Run Acceptance GUI test' group = 'verification' javaLauncher = javaToolchains.launcherFor { From f391c7e989e6d87287282a8c4b10987e793b7f56 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Mon, 4 Nov 2024 08:58:09 +0900 Subject: [PATCH 75/85] chore: restructure GitHub Actions - Separate gradle wrapper validator - Add acceptance test job - Run build check with headless - Add docs build check job Signed-off-by: Hiroshi Miura --- ...build-master.yml => acceptance-master.yml} | 8 ++-- .github/workflows/gradle-check-master.yml | 39 +++++++++++++++++++ .github/workflows/gradle-wrapper-validate.yml | 12 ++++++ .github/workflows/greetings-builds-master.yml | 24 ++++++++++++ .gitignore | 1 + 5 files changed, 79 insertions(+), 5 deletions(-) rename .github/workflows/{gradle-build-master.yml => acceptance-master.yml} (81%) create mode 100644 .github/workflows/gradle-check-master.yml create mode 100644 .github/workflows/gradle-wrapper-validate.yml create mode 100644 .github/workflows/greetings-builds-master.yml diff --git a/.github/workflows/gradle-build-master.yml b/.github/workflows/acceptance-master.yml similarity index 81% rename from .github/workflows/gradle-build-master.yml rename to .github/workflows/acceptance-master.yml index 3850caa14b..b44d75febd 100644 --- a/.github/workflows/gradle-build-master.yml +++ b/.github/workflows/acceptance-master.yml @@ -1,4 +1,4 @@ -name: Unit Tests, Quality checks, and Acceptance Tests +name: Acceptance Tests on: push: @@ -18,13 +18,11 @@ jobs: with: java-version: 17 distribution: 'temurin' - - uses: gradle/wrapper-validation-action@v3 - name: validate gradle wrapper - uses: gradle/actions/setup-gradle@v4 name: Setup Gradle id: setup-gradle - - name: Run gradle build - run: xvfb-run -a --server-args='-screen 0, 1024x768x24' ./gradlew -PenvIsCi --scan build + - name: Run acceptance test + run: ./gradlew -PenvIsCi=true --scan testAcceptance id: gradle - name: "Add Build Scan URL as PR comment" uses: actions/github-script@v7 diff --git a/.github/workflows/gradle-check-master.yml b/.github/workflows/gradle-check-master.yml new file mode 100644 index 0000000000..6bbdad3e76 --- /dev/null +++ b/.github/workflows/gradle-check-master.yml @@ -0,0 +1,39 @@ +name: Quality checks + +on: + push: + branches: + - master + - releases/* + pull_request: + +jobs: + gradle: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - uses: gradle/actions/setup-gradle@v4 + name: Setup Gradle + id: setup-gradle + - name: Run gradle build + run: ./gradlew -PenvIsCi=true -Pheadless=true --scan check + id: gradle + - name: "Add Build Scan URL as PR comment" + uses: actions/github-script@v7 + if: github.event_name == 'pull_request' && failure() + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `❌ ${{ github.workflow }} **failed**. + + Please look a Gradle Scan page for details: + ${{ steps.gradle.outputs.build-scan-url }}` + }) diff --git a/.github/workflows/gradle-wrapper-validate.yml b/.github/workflows/gradle-wrapper-validate.yml new file mode 100644 index 0000000000..037783e95d --- /dev/null +++ b/.github/workflows/gradle-wrapper-validate.yml @@ -0,0 +1,12 @@ +name: Validate gradle wrapper + +on: + pull_request: + +jobs: + gradle: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: gradle/wrapper-validation-action@v3 + name: validate gradle wrapper diff --git a/.github/workflows/greetings-builds-master.yml b/.github/workflows/greetings-builds-master.yml new file mode 100644 index 0000000000..65a37269af --- /dev/null +++ b/.github/workflows/greetings-builds-master.yml @@ -0,0 +1,24 @@ +name: Check javadoc, greetings and manuals + +on: + push: + branches: + - master + - releases/* + pull_request: + +jobs: + gradle: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - uses: gradle/actions/setup-gradle@v4 + name: Setup Gradle + id: setup-gradle + - name: Run gradle firstSteps manualsHtmls javadoc + run: ./gradlew -PenvIsCi=true firstSteps manualHtmls javadoc + id: gradle diff --git a/.gitignore b/.gitignore index aec3cfdcb2..e61a12e55c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ bin local.properties .idea +.fleet .run out From 5cc1aabcda16c28092a1f38c0c6be72adbc21826 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Mon, 4 Nov 2024 10:04:21 +0900 Subject: [PATCH 76/85] refactor: EditorController - The ctor to accept IMainWindow instead of MainWindow - Core.initializeGUIimpl to take IMainWindow, resolve TODO - TestCoreInitializer call Core.initializeGUIimpl, resolve FIXME Signed-off-by: Hiroshi Miura --- src/org/omegat/core/Core.java | 3 +-- src/org/omegat/gui/editor/EditorController.java | 6 +++--- test/fixtures/org/omegat/core/TestCoreInitializer.java | 7 +------ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/org/omegat/core/Core.java b/src/org/omegat/core/Core.java index 3b6f8f9913..e3ef6bc5d7 100644 --- a/src/org/omegat/core/Core.java +++ b/src/org/omegat/core/Core.java @@ -262,10 +262,9 @@ public static void initializeGUI(final Map params) throws Except /** * initialize GUI body. - * TODO: this should accept IMainWindow. * @throws Exception */ - static void initializeGUIimpl(MainWindow me) throws Exception { + static void initializeGUIimpl(IMainWindow me) throws Exception { MarkerController.init(); LanguageToolWrapper.init(); diff --git a/src/org/omegat/gui/editor/EditorController.java b/src/org/omegat/gui/editor/EditorController.java index 27af65be09..6c42ed2331 100644 --- a/src/org/omegat/gui/editor/EditorController.java +++ b/src/org/omegat/gui/editor/EditorController.java @@ -108,7 +108,7 @@ import org.omegat.gui.main.BaseMainWindowMenu; import org.omegat.gui.main.DockablePanel; import org.omegat.gui.main.IMainMenu; -import org.omegat.gui.main.MainWindow; +import org.omegat.gui.main.IMainWindow; import org.omegat.gui.main.MainWindowStatusBar; import org.omegat.gui.main.ProjectUICommands; import org.omegat.gui.notes.INotes; @@ -183,7 +183,7 @@ enum ForceTranslation { private String emptyProjectPaneTitle; private JTextPane introPane; private JTextPane emptyProjectPane; - protected final MainWindow mw; + protected final IMainWindow mw; /** Currently displayed segments info. */ protected SegmentBuilder[] m_docSegList; @@ -229,7 +229,7 @@ private enum SHOW_TYPE { */ private IProject.AllTranslations previousTranslations; - public EditorController(final MainWindow mainWindow) { + public EditorController(final IMainWindow mainWindow) { this.mw = mainWindow; segmentExportImport = new SegmentExportImport(this); diff --git a/test/fixtures/org/omegat/core/TestCoreInitializer.java b/test/fixtures/org/omegat/core/TestCoreInitializer.java index 5af7f61f64..28396a304b 100644 --- a/test/fixtures/org/omegat/core/TestCoreInitializer.java +++ b/test/fixtures/org/omegat/core/TestCoreInitializer.java @@ -30,7 +30,6 @@ import org.omegat.gui.glossary.IGlossaries; import org.omegat.gui.main.ConsoleWindow; import org.omegat.gui.main.IMainWindow; -import org.omegat.gui.main.MainWindow; /** * Core initializer for unit tests. @@ -56,11 +55,7 @@ public static void initMainWindow(IMainWindow mainWindow) throws Exception { if (mainWindow instanceof ConsoleWindow) { return; } - - // FIXME: IMainWindow on GUI environment should be initialized - if (mainWindow instanceof MainWindow) { - Core.initializeGUIimpl((MainWindow) mainWindow); - } + Core.initializeGUIimpl(mainWindow); } public static void initGlossary(IGlossaries glossaries) { From 91210cb3b34e68a47927aea766b64b86feeea6db Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Mon, 4 Nov 2024 10:48:58 +0900 Subject: [PATCH 77/85] chore: split GitHub CIs greetings and manuals build - split manual build and greetings for speed up Signed-off-by: Hiroshi Miura --- .github/workflows/greetings-builds-master.yml | 6 ++--- .github/workflows/manuals-builds-master.yml | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/manuals-builds-master.yml diff --git a/.github/workflows/greetings-builds-master.yml b/.github/workflows/greetings-builds-master.yml index 65a37269af..1664972545 100644 --- a/.github/workflows/greetings-builds-master.yml +++ b/.github/workflows/greetings-builds-master.yml @@ -1,4 +1,4 @@ -name: Check javadoc, greetings and manuals +name: Chec greetings build on: push: @@ -19,6 +19,6 @@ jobs: - uses: gradle/actions/setup-gradle@v4 name: Setup Gradle id: setup-gradle - - name: Run gradle firstSteps manualsHtmls javadoc - run: ./gradlew -PenvIsCi=true firstSteps manualHtmls javadoc + - name: Run gradle firstSteps + run: ./gradlew -PenvIsCi=true firstSteps id: gradle diff --git a/.github/workflows/manuals-builds-master.yml b/.github/workflows/manuals-builds-master.yml new file mode 100644 index 0000000000..3bc29f5584 --- /dev/null +++ b/.github/workflows/manuals-builds-master.yml @@ -0,0 +1,24 @@ +name: Check manuals build + +on: + push: + branches: + - master + - releases/* + pull_request: + +jobs: + gradle: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - uses: gradle/actions/setup-gradle@v4 + name: Setup Gradle + id: setup-gradle + - name: Run gradle manualsHtmls + run: ./gradlew -PenvIsCi=true manualHtmls + id: gradle From 97822ef712f10a02966dc031122dca2e82658ad6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 07:39:29 +0900 Subject: [PATCH 78/85] chore(deps): bump com.github.spotbugs from 6.0.25 to 6.0.26 (#1173) Bumps com.github.spotbugs from 6.0.25 to 6.0.26. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9245ac7c97..7ca0235a36 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -184,7 +184,7 @@ dictionary = ["trie4j", "dsl4j", "stardict4j", "jsoup"] xmlunit = ["xmlunit-core", "xmlunit-assertj", "assertj"] [plugins] -spotbugs = {id = "com.github.spotbugs", version = "6.0.25"} +spotbugs = {id = "com.github.spotbugs", version = "6.0.26"} spotless = {id = "com.diffplug.spotless", version = "6.25.0"} launch4j = {id = "edu.sc.seis.launch4j", version = "3.0.6"} versions = {id = "com.github.ben-manes.versions", version = "0.51.0"} From e9927383da08b2c393567bcddbf246146ff789df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 07:42:09 +0900 Subject: [PATCH 79/85] chore(deps): bump com.fifesoft:rsyntaxtextarea from 3.5.1 to 3.5.2 (#1168) Bumps [com.fifesoft:rsyntaxtextarea](https://github.com/bobbylight/rsyntaxtextarea) from 3.5.1 to 3.5.2. - [Release notes](https://github.com/bobbylight/rsyntaxtextarea/releases) - [Commits](https://github.com/bobbylight/rsyntaxtextarea/compare/3.5.1...3.5.2) --- updated-dependencies: - dependency-name: com.fifesoft:rsyntaxtextarea dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7ca0235a36..cfbe8bb44e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -130,7 +130,7 @@ bc-pg = {group = "org.bouncycastle", name = "bcpg-jdk18on", version.ref = "bc"} bc-pkix = {group = "org.bouncycastle", name = "bcpkix-jdk18on", version.ref = "bc"} svnkit = {group = "org.tmatesoft.svnkit", name = "svnkit", version.ref = "svnkit"} nashorn-core = {group = "org.openjdk.nashorn", name = "nashorn-core", version.ref = "nashorn"} -fifesoft-rsyntaxtextarea = {group = "com.fifesoft", name = "rsyntaxtextarea", version = "3.5.1"} +fifesoft-rsyntaxtextarea = {group = "com.fifesoft", name = "rsyntaxtextarea", version = "3.5.2"} fifesoft-rstaui = {group = "com.fifesoft", name = "rstaui", version = "3.3.1"} fifesoft-languagesupport = {group = "com.fifesoft", name = "languagesupport", version = "3.3.0"} fifesoft-autocomplete = {group = "com.fifesoft", name = "autocomplete", version = "3.3.1"} From c2a581f1605e8ca58de51b352a69578938d0904c Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 7 Nov 2024 07:47:25 +0900 Subject: [PATCH 80/85] refactor: MainWindowUI accept IMainWindow instead of MainWindow as argument - Test code can use MainWindowUI utility class Signed-off-by: Hiroshi Miura --- src/org/omegat/gui/main/MainWindowUI.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/org/omegat/gui/main/MainWindowUI.java b/src/org/omegat/gui/main/MainWindowUI.java index 186b8db8de..e764a59d20 100644 --- a/src/org/omegat/gui/main/MainWindowUI.java +++ b/src/org/omegat/gui/main/MainWindowUI.java @@ -146,7 +146,7 @@ private File getPerProjectLayout() { /** * Initialize the size of OmegaT window, then load the layout prefs. */ - public static void initializeScreenLayout(MainWindow mainWindow) { + public static void initializeScreenLayout(IMainWindow mainWindow) { /** * (23dec22) Set a reasonable default window size assuming a * standard"pro" laptop resolution of 1920x1080. Smaller screens do not @@ -182,14 +182,14 @@ public static void initializeScreenLayout(MainWindow mainWindow) { // Ensure any "closed" Dockables are visible. These can be newly added // panes not included in an older layout file, or e.g. panes installed // by plugins. - UIDesignManager.ensureDockablesVisible(mainWindow.desktop); + UIDesignManager.ensureDockablesVisible(mainWindow.getDesktop()); } /** * Load the main window layout from the global preferences file. Will reset * to defaults if global preferences are not present or if an error occurs. */ - private static void loadScreenLayoutFromPreferences(MainWindow mainWindow) { + private static void loadScreenLayoutFromPreferences(IMainWindow mainWindow) { File uiLayoutFile = new File(StaticUtils.getConfigDir(), MainWindowUI.UI_LAYOUT_FILE); if (uiLayoutFile.exists()) { loadScreenLayout(mainWindow, uiLayoutFile); @@ -202,9 +202,9 @@ private static void loadScreenLayoutFromPreferences(MainWindow mainWindow) { * Load the main window layout from the specified file. Will reset to * defaults if an error occurs. */ - private static void loadScreenLayout(MainWindow mainWindow, File uiLayoutFile) { + private static void loadScreenLayout(IMainWindow mainWindow, File uiLayoutFile) { try (InputStream in = new FileInputStream(uiLayoutFile)) { - mainWindow.desktop.readXML(in); + mainWindow.getDesktop().readXML(in); } catch (Exception ex) { Log.log(ex); resetDesktopLayout(mainWindow); @@ -234,9 +234,9 @@ private static void saveScreenLayout(MainWindow mainWindow, File uiLayoutFile) { * Restores main window layout to the default values (distinct from global * preferences). */ - public static void resetDesktopLayout(MainWindow mainWindow) { + public static void resetDesktopLayout(IMainWindow mainWindow) { try (InputStream in = MainWindowUI.class.getResourceAsStream("DockingDefaults.xml")) { - mainWindow.desktop.readXML(in); + mainWindow.getDesktop().readXML(in); } catch (Exception e) { Log.log(e); } From 5258a0f3d432a3d492c65480f63f60d85ccc108f Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 7 Nov 2024 08:25:42 +0900 Subject: [PATCH 81/85] chore: property testDisplay for acceptance test - The acceptance test requires a display number for Xvfb - If you run on virtual display, please run gradle like `./gradle -PtestDisplay=99 testAcceptance` - When not specify, or specify without value, it runs on the current live desktop Signed-off-by: Hiroshi Miura --- .github/workflows/acceptance-master.yml | 2 +- build.gradle | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/acceptance-master.yml b/.github/workflows/acceptance-master.yml index b44d75febd..2181a7fa85 100644 --- a/.github/workflows/acceptance-master.yml +++ b/.github/workflows/acceptance-master.yml @@ -22,7 +22,7 @@ jobs: name: Setup Gradle id: setup-gradle - name: Run acceptance test - run: ./gradlew -PenvIsCi=true --scan testAcceptance + run: ./gradlew -PenvIsCi=true -PtestDisplay=99 --scan testAcceptance id: gradle - name: "Add Build Scan URL as PR comment" uses: actions/github-script@v7 diff --git a/build.gradle b/build.gradle index a2dbeb3f9e..f3d5a5a025 100644 --- a/build.gradle +++ b/build.gradle @@ -1666,11 +1666,11 @@ def isCommandAvailable(command) { tasks.register('testAcceptance', Test) { onlyIf { - isCommandAvailable('Xvfb') + isCommandAvailable('Xvfb') || project.hasProperty("acceptanceTestLive") } - def display = 99 + def display = project.hasProperty("testDisplay") ? project.getProperty("testDisplay") : "" doFirst { - if (display != null) { + if (!display.isEmpty()) { def lockFile = new File("/tmp/.X${display}-lock") if (!lockFile.exists()) { ext.xvfbPid = startX(display) @@ -1679,7 +1679,7 @@ tasks.register('testAcceptance', Test) { } } doLast { - if (display != null) { + if (!display.isEmpty()) { def pid = ext.has('xvfbPid') ? ext.xvfbPid : null if (pid != null) { stopX(pid) From 08fb27ce2340d9c48ac0cab8535c444d03fc3392 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 7 Nov 2024 08:55:47 +0900 Subject: [PATCH 82/85] fix: DockablePanel handle name properly - DockablePanel#setName set only a name of the corresponding dockkey object, not set for the self. - DockablePanel#getName returns always null because the object don't have a name. - Define getName method to return dockKey's name. Signed-off-by: Hiroshi Miura --- src/org/omegat/gui/main/DockablePanel.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/org/omegat/gui/main/DockablePanel.java b/src/org/omegat/gui/main/DockablePanel.java index cfecea8f81..5929811570 100644 --- a/src/org/omegat/gui/main/DockablePanel.java +++ b/src/org/omegat/gui/main/DockablePanel.java @@ -71,4 +71,12 @@ public void setToolTipText(String text) { public void setName(String name) { dockKey.setName(name); } + + @Override + public String getName() { + if (dockKey ==null) { + return null; + } + return dockKey.getName(); + } } From bc2e7b2738b2caca42918b635519b14870809bb2 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 7 Nov 2024 08:57:37 +0900 Subject: [PATCH 83/85] fix: TestMainWindow - Initialize screen layout properly Signed-off-by: Hiroshi Miura --- test-acceptance/src/org/omegat/gui/main/TestMainWindow.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java b/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java index 8e7f1a6a2d..ca3c4b3558 100644 --- a/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java +++ b/test-acceptance/src/org/omegat/gui/main/TestMainWindow.java @@ -196,6 +196,8 @@ public void initializeScreenLayout() { Rectangle defaultWindowSize = new Rectangle(omegatLeftPosition, 0, omegatWidth, omegatHeight); applicationFrame.setBounds(defaultWindowSize); + + MainWindowUI.initializeScreenLayout(TestMainWindow.this); } @Override From baec8130be27613ef6b89cf9eae463b293fbd618 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 7 Nov 2024 09:03:54 +0900 Subject: [PATCH 84/85] fix: set EditorScrollPane name Signed-off-by: Hiroshi Miura --- src/org/omegat/gui/editor/EditorController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/omegat/gui/editor/EditorController.java b/src/org/omegat/gui/editor/EditorController.java index 6c42ed2331..a0792c480d 100644 --- a/src/org/omegat/gui/editor/EditorController.java +++ b/src/org/omegat/gui/editor/EditorController.java @@ -373,7 +373,7 @@ public void componentResized(ComponentEvent e) { scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.getVerticalScrollBar().addAdjustmentListener(scrollListener); - + scrollPane.setName("EditorScrollPane"); pane.setLayout(new BorderLayout()); pane.add(scrollPane, BorderLayout.CENTER); From ede7ded898a5a957d039bed424d608f60b869aa8 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 7 Nov 2024 09:04:44 +0900 Subject: [PATCH 85/85] chore: add simple EditorTextAreaTest - Check first steps pane existed, and scrollbar is visible. Signed-off-by: Hiroshi Miura --- .../omegat/gui/editor/EditorTextAreaTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test-acceptance/src/org/omegat/gui/editor/EditorTextAreaTest.java diff --git a/test-acceptance/src/org/omegat/gui/editor/EditorTextAreaTest.java b/test-acceptance/src/org/omegat/gui/editor/EditorTextAreaTest.java new file mode 100644 index 0000000000..c9eba5bcb2 --- /dev/null +++ b/test-acceptance/src/org/omegat/gui/editor/EditorTextAreaTest.java @@ -0,0 +1,20 @@ +package org.omegat.gui.editor; + +import org.junit.Test; + +import org.omegat.gui.main.TestCoreGUI; +import org.omegat.util.OStrings; + +public class EditorTextAreaTest extends TestCoreGUI { + + @Test + public void testIntroPaneExist() { + window.panel(OStrings.getString("DOCKING_FIRST_STEPS_TITLE")).requireEnabled(); + window.panel(OStrings.getString("DOCKING_FIRST_STEPS_TITLE")).scrollPane("EditorScrollPane").requireEnabled(); + window.panel(OStrings.getString("DOCKING_FIRST_STEPS_TITLE")).scrollPane("EditorScrollPane") + .verticalScrollBar().requireVisible(); + window.panel(OStrings.getString("DOCKING_FIRST_STEPS_TITLE")).scrollPane("EditorScrollPane") + .horizontalScrollBar().requireNotVisible(); + } + +}