Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diplodoc-platform/translation
generate xlf and skeleton for translation and assemble markdown out of xlf and skeleton
https://github.com/diplodoc-platform/translation
Last synced: about 2 months ago
JSON representation
generate xlf and skeleton for translation and assemble markdown out of xlf and skeleton
- Host: GitHub
- URL: https://github.com/diplodoc-platform/translation
- Owner: diplodoc-platform
- License: mit
- Created: 2023-04-05T11:18:24.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-11-05T15:45:33.000Z (about 2 months ago)
- Last Synced: 2024-11-11T21:23:02.427Z (about 2 months ago)
- Language: TypeScript
- Size: 2.1 MB
- Stars: 7
- Watchers: 13
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.MD
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 📝 markdown-translation
## 📚 Sections
- [👋 Introduction](#-introduction)
- [🌟 Project Overview](#-project-overview)
- [🎯 Purpose and Scope](#-purpose-and-scope)
- [🚀 Getting Started](#-getting-started)
- [💻 Installation](#-installation)
- [📖 API](#-api)
- [💡 Usage](#-usage)
## 👋 Introduction
Hey, There! 🤙🏼
Are you tired of copying and pasting your markdown content into translation tools, seeing markdown syntax instead of translatable text and collisions?
Say no more! 👌
With markdown-translation, you can easily generate a skeleton and xlf for CATs, and translate your content on the go! 🚀
## 🌟 Project Overview
🚀💻 This library got you covered with two API interfaces: extract and compose. 💻🚀
Extract text from markdown files 📄 and generate a skeleton/XLF file. 🧑💻
Compose the extracted text with the translations from the XLF file to create the translated markdown file. 🌎📄💬
Say goodbye to manual translation work and streamline your workflow with markdown-translation! 🤖💪
## 🎯 Purpose and Scope
🤯 Hold on to your hats, folks! This library is tackling some serious problems with markdown translations!
🚫 Say goodbye to unnecessary heavy load on translators caused by naive approaches that include markdown syntax constructs into text segments.
💥 And don't even get us started on "collisions" - yikes! But fear not, this library has got your back with a reliable solution for extracting text content from markdown without those pesky collisions.
🕵️♀️ How? By parsing and rendering xlf and skeleton, of course! So sit back, relax, and let this library handle all your markdown translation needs.
🧑💻 Say goodbye to those pesky issues and hello to efficient and accurate translations with markdown-translation!
## 🚀 Getting Started
### 💻 Installation
```
npm install @diplodoc/markdown-translation
```### 📖 API
#### 🔍 extract ✨
This function extracts skeleton and XLF strings from a given markdown string 📝, to use in the 💻 Computer Assisted Translation tool. 🌟
```typescript
function extract(parameters: ExtractParameters): ExtractOutput;
```#### 🎛️ Parameters `Object`
| Name | Type | Description |
| -------------- | ---------------- | --------------------------------------------------------- |
| `markdown` | `string` | The markdown string to extract text content from. |
| `source` | `LanguageLocale` | The source language and locale. |
| `target` | `LanguageLocale` | The target language and locale. |
| `skeletonPath` | `string` | The path where you will put the skeleton file. |
| `markdownPath` | `string` | The path from where the markdown file were read. |#### 📚 Types
#### 🎛️ LanguageLocale `Object`
| Name | Type | Description |
| ---------- | -------- | ------------------------------------------------------------- |
| `language` | `string` | The language code, as described in ISO 639-1. |
| `locale` | `string` | The locale code in alpha-2 format, as described in ISO 3166-1 |#### 🎛️ ExtractOutput `Object`
| Name | Type | Description |
| ---------- | -------- | --------------------------------------------------------- |
| `skeleton` | `string` | The extracted skeleton string. |
| `xlf` | `string` | The extracted XLF string. |#### 🔤 compose ✨
This function composes 🔠 translated 📝 markdown from given 🧟♂️ skeleton and 💬 XLF.
```typescript
function compose(parameters: ComposeParameters): string
```#### 🎛️ Parameters `Object`
| Name | Type | Description |
| -------------- | ---------------- | --------------------------------------------------------- |
| `skeleton` | `string` | The skeleton with hashes instead of translatable text |
| `xlf` | `string` | XLF with translated text |### 👨💻 Usage
#### 🔍 Extract
Extract skeleton and xlf from markdown
#### 👀 Example
```typescript
import {extract} from '@diplodoc/markdown-translation';const markdown = `# Heading 1
Paragraph
- First list item
- Second list itemHeading 2
-----------Paragraph with **bold text** and *italic*
> text inside of the blockquote
1. First ordered list item
2. Second ordered list item[Link text](files/file.md "Link Description")
![Alternative image text](files/image.png "Image title")
`;const params = {
markdown,
source: {language: 'en', locale: 'US' as const},
target: {language: 'ru', locale: 'RU' as const},
skeletonPath: 'path/where/you/will/put/generated/skeleton.skl.md',
markdownPath: 'path/to/file/where/markdown/string/came/from.md',
}const {skeleton, xlf} = extract(params);
console.log(skeleton);
console.log(xlf);
```#### 💥 Output
![skeleton output](assets/extract-output-skeleton.png "skeleton")
![xlf output](assets/extract-output-xlf.png "xlf")
#### 🔤 Compose
Compose skeleton and xlf into translated markdown
#### 👀 Example
```typescript
import {compose} from '@diplodoc/markdown-translation';const skeleton = `%%%1%%%
%%%2%%%
- %%%3%%%
- %%%4%%%
%%%5%%%
-----------
%%%6%%%**%%%7%%%**%%%8%%%*%%%9%%%*
> %%%10%%%
1. %%%11%%%
2. %%%12%%%[%%%13%%%](files/file.md "%%%14%%%")
![%%%15%%%](files/image.png "%%%16%%%")
`const xlf = `
Heading 1
Заголовок 1
Paragraph
Параграф
First list item
Первый элемент списка
Second list item
Второй элемент списка
Heading 2
Заголовок 2
Paragraph with
Параграф содержащий
bold text
жирный текст
and
и
italics
курсив
text inside of the blockquote
текст внутри цитаты
First ordered list item
Первый элемент нумерованного списка
Second ordered list item
Второй элемент нумерованного списка
Link text
Текст ссылки
Link Description
Описание ссылки
Alternative image text
Альтернативный текст картинки
Image title
Титул картинки
`;
const markdown = compose({skeleton, xlf});
console.log(markdown);
```#### 💥 Output
![markdown output](assets/compose-output-markdown.png "markdown")