npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jsboost/xlf-translator

v1.0.0

Published

An XLF translator which auto-translates your XLF files into the target locales

Downloads

1

Readme

XLF Translator

XLF Translator takes an XLF file as an input (e.g. terms.xlf), goes through all the translation units, translates them to the target language (locale) and saves them to a target file (e.g.terms.de.xlf).

If the file already exists, XLF Translator compares the ids of the translation units, if something already exists in the target file, it won't be overwritten.

This way, manual editions are possible after the auto-translations. They are not going to be overwritten.

Feedback

If something doesn't work as expected, leave an issue here:
https://github.com/jsboost/jsboost/issues

Installation

npm i @jsboost/xlf-translator --save-dev

Import

import import { XlfTranslator } from @jsboost/xlf-translator

Usage

Before you can start XlfTranslator, you need to define 3 things:

  1. inputXlfFilePath - The path to the source XLF file, which is going to be the source of the translations
  2. localeFiles - Definitions of the target locales, including their file paths.
  3. translate - A translate function, so you can customize it and use the service which you wish (e.g. GoogleTranslate, Deepl, etc.)

translate has to implement the following API:

export function translate (
  sourceText: string,
  targetLocale: string,
  sourceLocale?: string
): Promise<string> {

Create a new file four your script and call it something like this:

translate-xlf.ts

import { XlfTranslator, LocaleFile } from './translator';
import { translate } from './translate.func';

// Preparing params
const i18nFolder = `app/src/i18n`;
const inputXlfFilePath = `${i18nFolder}/terms.xlf`;
const localeFiles: LocaleFile[] = [
  { locale: 'en-US', filePath: `${i18nFolder}/terms.en-US.xlf` },
  { locale: 'es-MX', filePath: `${i18nFolder}/terms.es-MX.xlf` },
  ...
];

// Usage
const translator = new XlfTranslator(
  inputXlfFilePath,
  localeFiles,
  translate
);
translator.start();

Execute it like this:

ts-node translate-xlf.ts

And watch the results:

console output