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

@doc-tools/yfm2xliff

v0.0.5

Published

text extraction from yfm syntax into xliff format

Downloads

473

Readme

yfm2xliff

helps you translate your yfm files.

installation library

npm install @doc-tools/yfm2xliff --save
const {compose, extract} = require('@doc-tools/yfm2xliff');

installation cli

git clone [email protected]:yandex-cloud/yfm2xliff.git yfm2xliff
cd yfm2xliff
npm install
npm link

dependencies

library has peer dependency @doc-tools/transform

npm install @doc-tools/transform

usage library

api

note: types are provided for educational purposes, there is no typings available for the library for now.

extract

type ExtractParameters = {
  // source string in the format language-LOCALE, example: ru-RU, en-US
  source: string;
  // target string in the format language-LOCALE, example ru-RU, en-US
  target: string;
  // input yfm/markdown string to extract text segments from
  md: string;
  // path to the markdown markdown string comes from, note: crucial for valid xliff file generation
  mdPath: string;
  // path to where generated skeleton file will be stored(by you), note: crucial for valid xliff file generation
  sklPath: string
  // options to pass to yfm-transform
  options: {
    // array of yfm-transform plugins
    plugings: [];
    ...
  }
}

type ExtractOutput = {
  skeleton: string;
  xliff: string;
  data: {
    // see Parameters.mdPath
    markdownFileName: string;
    // see Parameters.sklPath
    skeletonFilename: string;
    // see Paramters.source
    srcLang: string;
    // see Parameters.target
    trgLang: string;
    // extracted text segments
    units: string[]
  }
}

extract(ExtractParameters) => ExtractOutput

compose

// xliff file string
type Xliff = string;

// skeleton file string
type Skeleton = string;

// callback function which will recieve results in the form of the composed markdown/yfm file string
type CallBack = <T>(err: Error, generated: ComposeOutput) => CallBackOutput

// callback function output
type CallbackOutput = any;

compose(xliff: Xliff, skeleton: Skeleton, cb: CallBack) => CallbackOutput

example

extract

refer to cli extractor, extract tests for usage examples.

compose

refer to cli composer for usage example.

usage cli

supports:

  • extraction of the text tokens from markup to the xliff format.
  • their composition in the translated markup document.

environment variables

supported by all commands

  • DEBUG - enables failures logging to the filesystem output_dir/.yfm2xliff.failures.log. continues to extract/compose even if some failures occured in the process.

commands

  • extract
  • compose

extract

extract text tokens for translation from all of the markup files inside the given directory into xliff.

options
  • -i/input - input directory to get markup files from
  • -o/output - output directory to persist extracted tokens in the xliff format (preserves original file path)
example
yfm2xliff extract -i cloud-docs/ru -o cloud-docs-extracted

compose

compose translated text units from all of the xliff files inside the given directory into translated markup.

environment variables
  • USE_SOURCE - uses originally extracted text tokens instead of the translated ones, thus giving you original non translated markup.
options
  • -i/input - input directory to get translated units from xliff files.
  • -o/output - output directory to persist translated markup (preserves original file path)
example
yfm2xliff compose -i cloud-docs-extracted -o cloud-docs-translated