sdltm
v2.1.0
Published
TypeScript library for converting SDLTM files to TMX 1.4
Readme
sdltm
TypeScript library for converting SDLTM files (Translation Memory databases from Trados Studio) to TMX 1.4b
Installation
npm install sdltm
Requirements
- Node.js 20.11+ (or any release that ships the
node:sqliteexperimental module) - SQLite-compatible
.sdltmfiles created by SDL/Trados Studio
Usage
Promise handling
import { TMReader, TMReaderResult } from 'sdltm';
function convertWithPromise(): void {
const reader: TMReader = new TMReader({ productName: 'My Tool', version: '2.0.0' });
reader.convert('Japanese.sdltm', 'Japanese.tmx').then((result: TMReaderResult) => {
console.log(`Conversion completed with status: ${result.status}, total TUs: ${result.count}`);
}).catch((error: unknown) => {
const message: string = error instanceof Error ? error.message : String(error);
console.error('Conversion failed:', message);
});
}
convertWithPromise();Async/await
import { TMReader, TMReaderResult } from 'sdltm';
async function convertWithAsyncAwait(): Promise<void> {
const reader: TMReader = new TMReader({ productName: 'My Tool', version: '2.0.0' });
try {
const result: TMReaderResult = await reader.convert('Japanese.sdltm', 'Japanese.tmx');
console.log(`Conversion completed with status: ${result.status}, total TUs: ${result.count}`);
} catch (error: unknown) {
const message: string = error instanceof Error ? error.message : String(error);
console.error('Conversion failed:', message);
}
}
convertWithAsyncAwait();Notes
productNameandversioncan be omitted; when they are,TMReaderfalls back to the values declared in the package’s ownpackage.json.convert()returns a promise and automatically closes the SDLTM database connection when the process finishes or fails.- The Node.js
node:sqlitemodule currently logs an experimental warning; this is expected until the API is stabilized upstream.
