Skip to content

Localization OS 1.2.0

Choose a tag to compare

@brentmsummers brentmsummers released this 10 Nov 04:24
· 7 commits to main since this release

Localization OS 1.2.0

Release 1.2.0 makes Bilingua the file parsing engine and carries a large set of file filter fixes. Bilingua is
the open source Rust parsing engine (patois-labs/bilingua). It is installed with the app and on by default for
all 85 formats it parses. The filter fixes tighten security around hostile files, make archive handling safer,
repair encoding and code page handling, speed up the slowest readers and correct a long list of format-specific
details.

There is no database migration in this release. Upgrading is a dependency refresh.

Highlights

  • Bilingua is the parsing engine, on by default. The install-wide setting bilingua_formats now defaults to
    all: every format Bilingua parses is read by it on new uploads. A blank value switches back to the built-in
    Python filters for every format; a comma list such as md,json,po picks formats. The setting is on the Settings
    page (File parsing), in loc config set bilingua_formats ..., in the admin API and in the MCP settings tool,
    and the environment variable LOC_TMS_BILINGUA_FORMATS overrides it. An unknown format name, or a list of more
    than 256 names, is refused with nothing saved.
  • Documents keep their engine. A document imported before the upgrade stays on the filter that imported it,
    and a document imported by Bilingua is always read and exported by Bilingua, whatever the setting says later.
    Emptying the list stops new Bilingua imports at once and never moves an existing document. If Bilingua's
    profile for a stored document no longer matches at export, the export asks for a re-import instead of failing.
  • Same tokens, same translation memory, for nearly every format. Bilingua numbers inline tags and
    placeholders with the same text the Python filters produce, so existing translation memory keeps matching.
    The exceptions are listed under Known limitations.
  • Shadow mode. bilingua_shadow_formats also parses new uploads with Bilingua in the background and logs only
    counts and hashes, never content; nothing stored changes. It is empty by default.
  • Platform note. The Bilingua wheel is published for x86_64 Linux (glibc 2.28 or newer, manylinux 2_28) and
    Windows x64. On any other operating system or machine (for example macOS, aarch64 Linux or Alpine) the package
    is skipped at install time, the Settings page says the module is not installed, and every format keeps its
    Python filter. Nothing else changes. On x86_64 Linux with an older glibc, pip install -r requirements.lock
    stops with no matching wheel; use a newer base system.

Security and injection guards

  • Translated text can no longer inject markup or code into Markdown and MDX, SVG, PHP, JavaScript and TypeScript,
    JSP and AsciiDoc outputs; heading escapes, indentation, backticks, backslashes and marks next to code spans are
    kept intact.
  • Text in a translation that merely looks like a placeholder or tag is kept as text on export in 25 more filter
    families, rather than being dropped or read as a code.
  • PDF reading runs in a child process with a wall-clock limit (PDF_CALL_TIMEOUT_S 60 s per step,
    PDF_TOTAL_TIMEOUT_S 150 s in all), and on Linux a memory cap (PDF_WORKER_MEMORY_MB 1024), so a hostile file
    cannot hold a worker. A PDF that exceeds a limit is refused with HTTP 413. PDF_WORKERS (default 4) bounds the
    children running at once.
  • A start tag with more than 2,048 attributes or namespace declarations is refused before any XML parse, in plain
    XML and inside package parts, because such a tag makes the XML library take minutes.

Zip and archive safety

  • Packages and batch ZIPs refuse encrypted members and symbolic links, member names that leave the package
    (absolute paths, .., drive letters, control characters, names made only of dots or spaces) and duplicate member
    names, counting names that differ only in case or slash direction as the same.
  • Batch ZIPs name members that Windows cannot unpack (device names such as CON, and colons) and keep listing
    symbolic links as skipped.
  • Office and XLIFF packages report the part that holds invalid XML, so the error says where to look.

Encodings and code pages

  • A UTF-8 byte order mark before non-UTF-8 text in legacy subtitle formats is read as a mark, not as text.
  • HTML reads rarer charsets, orphan end tags and mixed declarations; ISO-8859-8 is labelled only where the label
    cannot mislead.
  • HTML Help projects read the code page of their project file, and Bilingua documents carry the same code page
    warnings as the Python filters.

Speed

  • HTML tokenizing and raw-quote handling are faster.
  • XML resource files (resx and similar) build faster, and builds of a Bilingua document reuse the extraction of a
    clean parse, about 28% faster.
  • On our own test corpus of 3,670 real-world files, 2,720 build byte for byte as the Python filters build them;
    the differences in the rest are the classes listed under Known limitations. Parse and build times are close to the
    Python filters for most formats and faster for the slowest ones; a few small-file formats are a few
    milliseconds slower per file.

Format-specific fixes

  • Web pages: a global rule keeps hidden forms hidden.
  • Markdown: a paragraph that holds an image is translated in full-text mode; emphasis next to CJK text agrees with
    the Python reader.
  • HTML and XML: orphan end tags, language and translate="no" handling in DITA and DocBook, XLIFF comments with
    versioned token numbering, tag budgets before every XML parse, NUL bytes and line endings, TTX targets that hold
    only control characters.
  • Strings and resources: WiX strings beside comments are read, Fluent values with a leading dot on their own line
    are escaped, a resx value that spans lines and is unchanged keeps its CRLF.
  • AsciiDoc: marks next to code marks, terms and titles keep their structure.
  • Subtitles: MicroDVD control codes across a line break are refused.
  • DOCX, XLSX, PPTX, ODF, IDML, ICML, MIF, XLIFF and CAT formats (SDLXLIFF, MQXLIFF, MXLIFF, TXML, TTX): the
    Bilingua adapter keeps the same refusals, warnings, comments and skeleton bookkeeping as the Python filters.
  • CSV: column planning and formula injection guards are the same under Bilingua as under the Python filter.

Upgrade notes

  1. Back up first (loc-tms db backup-full), as for any upgrade.
  2. Refresh the dependencies: pip install -r requirements.lock. This installs bilingua on x86_64 Linux and
    Windows x64. Nothing else is needed, and there is no database migration.
  3. In the container, rebuild the image. The build checks that bilingua imports on x86_64. To build the engine
    from source instead, see docs/runbooks/bilingua-wheel.md.
  4. To keep the previous behaviour for new uploads, set bilingua_formats to blank after upgrading.
  5. A file that Bilingua refuses is reported with a plain message, as the Python filters do; the Python filter reads
    the formats it handled before whenever the setting is blank or the module is missing.

Known limitations

  • Bilingua's output differs from the Python filters' for some files. Known cases:
    • server pages and HTML that declare a legacy charset but hold UTF-8 bytes (Bilingua writes the declaration
      that matches the bytes), and a Shift_JIS HTML table character;
    • Arabic notes in DOCX (Bilingua keeps the bidi marks);
    • wiki file links (Bilingua leaves option words untranslated);
    • some reStructuredText, LaTeX, AsciiDoc and MadCap Flare details;
    • PDF text cleaning and hyphen joins; STL, SCC and STF subtitle details; DXF percent codes; HTML Help CJK
      labels; xml:lang stamping in DITA and DocBook; WiX line breaks;
    • xcstrings: Bilingua offers one unit per phrase where the Python filter offered none for some catalogs;
    • token numbering for MXLIFF mixed codes, and for typed unknown tokens in PPTX and XLSX text boxes, so TM
      matches on those segments may need a review;
    • a non-localized build of a CSV with a target column.
      To keep the Python filters' output for a format, leave it out of bilingua_formats.
  • A document imported by Bilingua cannot be exported on a machine without the Bilingua module; install the wheel or
    re-import the file there.