Featured image of post Free Markdown Translator

Free Markdown Translator

This is an introduction to an open source project "Free Markdown Translator"

Warning: This page is translated by MACHINE, which may lead to POOR QUALITY or INCORRECT INFORMATION, please read with CAUTION!

Origin

I wanted to add I18N related content to my blog, so I wanted to find some Markdown document translators (because HUGO published a blog using a Markdown document) or related interfaces, found that the relevant content was very small, and it did not meet the intentions and expectations. So I could only learn from the reference. The experience of the predecessors has been modified and developed a Markdown document translator. The specific content is below. The project link is at the end of the article.

Brief introduction

Free Markdown Translator is a free, open source Markdown document (hereinafter referred to as MD) translator based on Google Translate API, which can translate your MD into any type of language.

Function:

  • Translate MD into any type of language
  • It will not destroy the original format of MD, while supporting custom translation rules
  • Support multi -threaded translation, and add load balancing mechanisms at the same time, which can effectively use Google translation interfaces and avoid the failure of document translation.
  • Support a program to run multiple folders and multiple files under one folder, which increases convenience
  • Support to add warnings to MDs of machine translation

Google Translate API ReferenceVictorzhang2014/free-Google-Translate: Free Google Translator API free Google translation (github.com), This program referenceHow to use translate.google.cn free Google translation website to translate the entire Markdown document, v2 modified version (knightli.com)

Installation and operation

  1. Download the warehouse or download the source code to the local area
1
git clone git@github.com:CrazyMayfly/Free-Markdown-Translator.git
  1. Install software packagePyExecJS
1
pip install PyExecJS
  1. Enter the code directory, run the code
1
python.exe .\MarkdownTranslator.py

usage

1
python.exe MarkdownTranslator.py [-h] folder [folder ...]

Place the folder to be translated for the parameter position, you can add multiple folders, and the program will automatically translate each folder in the file in the configuration file.

For example, if the specified target language is English (EN), Japanese (JA), thenreadme.mdThe file will be translated to the same folderreadme.en.md,readme.ja.md.

Configuration

please atconfig.pyConfiguration

  1. insert_warnings: Control whether to add machine translation in front of the article
  2. src_language: Specify the source language, Auto means that Google automatically identifies
  3. warnings_mapping: Configure the taroning of the target language
  4. dest_langs: Configure the target language, you can manually specify the target language, or you can use it directlywarnings_mappingThe target language configured in the middle is translated in the order of definition
  5. skipped_regexs: Specify the regular expression of the character to skip the translation
  6. detect_filenames: The name of the MD document that needs to be translated in the file directory
  7. front_matter_transparent_keys: Markdown’s Front Matter does not need to translate parts
  8. front_matter_key_value_keys: FRONT MATTER needs to be key-Value form translation part
  9. front_matter_key_value_array_keys: FRONT MATTER-Value -Rrays format translation

Target language configuration details

Because the Google translation interface is used, the target language needs to use ISO 639-1 Language code, you can refer to it for detailsList of ISO 639-1 codes- Wikipedia, Here are some commonly used language code

Language nameThis language claims toLanguage code
Chinese漢語、汉语、华语zh
EnglishEnglishen
Japanese日本語ja
SpanishEspañoles
Russianрусскийru
Frenchfrançaisfr
GermanDeutschde
Arabicالعربيةar
Hindiहिन्दीhi
PortuguesePortuguêspt
Korean한국어/韓國語, 朝鮮말/조선말ko