OmegaT Documentation

repository·master·Indexed 19 days ago

https://github.com/omegat-org/omegat

Professional computer-aided translation (CAT) tool supporting translation memory, TMX sharing, and various file formats like XLIFF, PO, and DOCX. This documentation covers core features, Java-based development, plugin creation, and automation using Groovy or JavaScript scripts. It includes guides for contributing to the modular architecture, setting up integration tests via Docker Compose, and the Request for Feature Enhancement (RFE) process.

Tokens
81K
Snippets
167
Records
394
Agent score
67%

What's inside OmegaT

  1. Overview of OmegaT CI/CD Platforms

    master

    OmegaT utilizes two distinct CI/CD platforms to manage its build and delivery lifecycle:

    • Azure Pipelines: The primary platform. It handles the core build, testing, and publishing of Windows packages and documentation.
    • GitHub Actions: Handles Linux package builds, daily quality checks (static analysis, acceptance tests), and supplementary publishing tasks.

    Configuration files are located in ci/azure-pipelines/ for Azure and .github/workflows/ for GitHub.

  2. Overview of OmegaT features and requirements

    master

    OmegaT is a professional computer-assisted translation (CAT) tool. It is a local application that does not require an internet connection and does not send data to online services unless explicitly configured by the user.

    Key Capabilities

    • Translation Memory: Flexible support with real-time matching.
    • Collaboration: Supports TMX sharing and fully shared projects.
    • File Formats: Supports industry standards including XLIFF, TMX, TTX, PO, HTML, and DOCX.
    • Assistance Tools: Autocompletion (based on history, predictions, glossaries, and tags), glossaries, spell checking, and grammar checking.
    • Language Support: Unicode and Right-to-Left (RTL) support.
    • Extensibility: Supports plugins and scripting.
    • Machine Translation: Easy access to MT services.

    System Requirements

    OmegaT runs on any operating system that supports the Java Runtime Environment (JRE), including Linux, macOS, and Windows.

  3. Understand the OmegaT website project structure

    master

    The OmegaT website (https://omegat.org/) is built using the Jekyll page generator. The source code for the website is maintained in a separate repository: https://github.com/omegat-org/omegat-website.

    Localization is handled via the _i18n/ directory. The English version is located at _i18n/en, while other language versions are stored in subdirectories named after their respective language codes (e.g., _i18n/fr, _i18n/de).

  4. Understand the OmegaT source tree structure

    master

    The OmegaT project follows a structured directory layout for source code, tests, documentation, and sub-modules.

    Main Source Code

    • src/main/java: Contains the primary OmegaT Java source code.
    • src/main/schemas: Contains XML schemas used for JAXB code generation.
    • src/test: Contains unit and regression tests, organized into java and resources sub-folders.
    • src/testFixtures: Provides base test code shared across multiple sub-projects.
    • test-integration: Contains integration tests. The test-integration/docker folder includes a Dockerfile for setting up test server and client environments for automated testing.

    Documentation

    Documentation is managed using Markdown and the Sphinx processing system. Key directories include:

    • src/docs/manual: User manuals and start guides.
    • src/docs/developer: Developer notes (Markdown files).
    • src/docs/greeting: HTML content shown on the OmegaT startup screen.
    • src/docs/tips: HTML files for 'Tips of the Day'.
    • src/docs/template, src/docs/style, and src/docs/xsl: Files used to generate the HTML/PDF manual output.

    Sub-modules and Plugins

    • tipoftheday: A sub-project implemented as an OmegaT plugin. It uses a standard Maven source tree structure and is configured via its own build.gradle file. Content for the 'Tip of the Day' dialog is stored in the docs folder and must be indexed in tips.yaml when new content is added.
  5. Overview of OmegaT Core Events

    master
    OmegaT provides a standard API for hooking into GUI and application lifecycle events via the org.omegat.core.CoreEvents class. Developers can listen for various system changes, including application startup/shutdown, project changes, file/segment navigation (entry events), font configuration changes, and editor caret movements.
  6. Handle CJK hash collision issues in glossary matching

    master

    For CJK (Chinese, Japanese, Korean) languages, high hash collision rates for short strings can lead to inaccurate matches. To mitigate this, getMatchingTokens implements a rawMatch check.

    When a match is identified via the tokenizer, the system performs an additional verification: it ensures that at least one of the matched tokens is a literal substring of the glossary term. This prevents linguistically irrelevant matches caused by aggressive stemming or tokenizer collisions in non-space-delimited languages.

  7. How File Filters work

    master

    A Filter is a class responsible for parsing and building translation files (e.g., *.po, *.properties, *.html). A FilterMaster manages these filters and detects the correct one for a given file format.

    To implement a filter, it must be two-fold: it must support both reading (extracting translatable content) and writing (replacing content with translations) for the same format.

    Filters are distinguished by file extension or content. A single filter class may be instantiated multiple times with different parameters (e.g., different encodings for text files), or a single instance may handle multiple similar formats (e.g., an Open Office filter).

  8. Understand the static analysis toolset

    master

    OmegaT employs a multi-layered static analysis strategy to catch different types of issues:

    1. SpotBugs: Focuses on runtime behavior, potential bugs, and security vulnerabilities.
    2. PMD: Analyzes code quality, maintainability, and performance (e.g., code smells, unused code, unnecessary object creation).
    3. Checkstyle: Enforces coding standards and formatting consistency.
    4. Error Prone (with NullAway): Provides compile-time bug detection, prevents common Java mistakes, and enforces null safety via the NullAway plugin.
  9. Understand TMX backup behavior in Team Projects

    master

    In Team Projects, OmegaT uses the team sync feature to manage versioning and conflicts. When you save, OmegaT attempts to sync with the remote repository (indicated by the status message TEAM_SYNCHRONIZE).

    If the remote file has been modified by other translators, OmegaT detects the difference and creates a timestamped backup to prevent overwriting work. After a sync-driven save, you may see three files:

    1. project_save.tmx.bak: The state of the file immediately before the current save.
    2. project_save.tmx.YYYYMMDDhhmm.bak: A timestamped backup of the file as it existed after the translator's previous work, preserved because a remote change was detected.
    3. project_save.tmx: The final merged file containing translations from both the local user and other team members.

    Note: If no other translators have modified the remote file, the timestamped .YYYYMMDDhhmm.bak file is not created.

  10. How dependency verification works in OmegaT

    master

    OmegaT uses Gradle's built-in dependency verification to protect against supply chain attacks (such as hijacked packages or man-in-the-middle substitutions). The system validates the SHA-256 checksum of every downloaded artifact against known-good values stored in gradle/verification-metadata.xml. If an artifact's hash does not match the recorded value, the build fails immediately before any code is compiled or executed.

    Key security properties of this setup:

    • Metadata Verification: Both POM files and Gradle module metadata (.module files) are verified (verify-metadata: true) to prevent attacks that manipulate dependency resolution graphs.
    • Checksum-based Safety: Protects against compromised repositories, cache poisoning, and artifact substitution.
    • Exclusions: Source (-sources.jar) and Javadoc (-javadoc.jar) JARs are globally trusted and excluded from checksum verification because they contain no executable code and are difficult to track in metadata.
    <!-- The verification metadata is located at: -->
    gradle/verification-metadata.xml
  11. How plugin isolation works in OmegaT

    master

    OmegaT uses a Type-Based ClassLoader Isolation strategy to manage plugins. Instead of a single shared ClassLoader for all plugins (which causes dependency conflicts) or a unique ClassLoader for every single plugin (which can break resource sharing), OmegaT groups plugins by their PluginType.

    Each PluginType is assigned its own MainClassLoader via an EnumMap. This allows plugins of the same type to share necessary resources while providing isolation between different categories of plugins.

    Grouping Logic

    • Theme plugins: Share one ClassLoader to allow registration of Look-and-Feel (LaF) classes with the global Swing UIManager.
    • Language plugins: Share one ClassLoader to facilitate sharing dictionaries with the core library and other language modules.
    • Filter plugins: Share one ClassLoader.
    • Other types: Follow the same pattern of grouping by type.

    Implications for Plugin Developers

    • Intra-type interference: Because plugins of the same type share a ClassLoader, they can access each other's classes. You should be aware that your plugin might interact with other plugins of the same type.
    • Dependency Conflicts: If two plugins of the same type require different versions of the same library, a conflict may occur because they share the same namespace.
    • Fault Propagation: A memory leak or bug in one plugin can affect other plugins within the same PluginType group.
    // Internal implementation mechanism for type-based isolation
    EnumMap<PluginType, MainClassLoader> MAINCLASSLOADERS;
  12. Understand the glossary result sort order

    master

    Glossary results are sorted using compareGlossaryEntries based on a specific precedence hierarchy. If you are implementing custom sorting or debugging result order, follow this priority:

    1. Priority: Entries from the 'writable' glossary or designated priority glossaries appear first.
    2. Source Term Length: If GLOSSARY_SORT_BY_SRC_LENGTH is enabled, longer source terms are prioritized when terms share the same starting characters (e.g., 'apple' vs 'apples').
    3. Source Term Alphabetical: Language-dependent sorting using a Collator (respecting Primary, Secondary, and Tertiary strength).
    4. Target Term Length: If GLOSSARY_SORT_BY_LENGTH is enabled, longer target terms are prioritized.
    5. Target Term Alphabetical: Language-dependent sorting of the target terms.