A language tool for MkDocs Material theme
Project description
MkDocs Material Langly Plugin
The Langly plugin for MkDocs is a plugin that provides language support and translations for websites created with MkDocs using the Material theme. It enables easy management of multilingual content and automatic translation of texts to reach a wider audience. It deliberately does not comply with any of the current translation standards, but takes a completely unique but open approach.
This plugin was created to use the great Material theme and offers functionalities to e.g. internationalize the blog area.
The only translation engine currently available is Deepl and a DeepL api key is required to use the plugin.
Directly supported plugins for mkdocs
This list includes plugins that were used directly in the development of Langly and are considered compatible. But it is not impossible that other plugins will also work.
- mkdocs-material{:target="_blank"}
- mkdocs-strings{:target="_blank"}
- mkdocs-glightbox{:target="_blank"}
These great plugins definitely need full support and recognition.
!!! note The plugin is still under development and it is recommended to read the documentation to understand the functionalities and limitations. I also ask you to report all requirements and suggested changes in the GitHub issues.
Let's get started
To get started, a few preliminary steps are required to use the plugin.
- mkdocs with installed material theme
- A DeepL-Free-Account is required
Installation of the plugin
To use the plugin, you must first install it. To do this, execute the following command:
pip install mkdocs-material-langly
Provide Api key
To use the plugin, you need a Deepl API key. You can obtain this free of charge from the Deepl website.
After you have created the api key, create a file called auth_key.json in the root directory of your project and add the following content:
{
"deepl": "DEEPL-API-KEY"
}
Replace DEEPL-API-KEY with your own api key.
Protect Api key
!!! danger Please read this section carefully and be sure to exclude the Api key in the .gitignore and also protect it in every possible way from being uploaded to the Internet.
Open the .gitignore file in the root directory and add the line auth_key.json to prevent the file from being uploaded by mistake. Then check online that the key cannot be found in the repo.
Configuration of the plugin
After installation, you can activate the plugin in your mkdocs.yml. Langly should be the last plugin in the list.
!!! info
No language-related settings need to be made in the Material theme. This means that the theme>language and extra>alternate options are set by the plugin.
site_url: https://<example>.com
..
..
..
plugins:
- search
- .
- .
- langly:
lang_switch: true
source:
name: Deutsch
lang: de
targets:
- name: English
lang: en-us
In this configuration, German is set as the source language and English as the target language. You can add as many target languages as you like. However, this will affect the serve performance all the more. The site_url option should correspond to the publication address of your website so that the sitemap and canonicals function correctly.
!!! warning
It is important to use the Deepl language codes for source and target. These can be found on the following website: Deepl Language Codes{:target="_blank"}
Once you have made the configuration, you can use the translation functions in your Markdown files.
Using the plugin
The plugin analyzes Markdown texts and evaluates masked text passages that are enclosed with {[ and ]}. These delimiter are removed when the page is rendered and the source and target language are displayed correctly on your page.
Proceed as follows to mask texts
{[Your text]}
The text within the masking is then automatically translated by Langly.
A few simple examples
Set
{[This text represents your source language]}
Paragraph
{[This paragraph contains several sentences in your source language. It is the recommended way of masking text passages and provides Deepl with more context to deliver a better translation.]}
Enumeration with colon
{[Enumeration]}:{[Value after the colon]}
Changelog und Features
0.1.2
- As the algorithm uses the characters
{[and]}as masking for translatable text, these characters cannot be documented directly in the text. Instead,hintsare used, which are automatically converted to{[and]}after translation. - Markdown export on first run of
serve,buildorgh-deployfor specified pages and languages with defined path. - Change to pyproject.toml
0.1.1 - Initial Release
- Insert an "index.html" with redirection to the target language according to the browser language.
- Configure MKDocs and the material theme for each build in the respective language.
- Optional language switching, which is configured automatically.
- Set all open translations to draft mode during
serveto minimize access to the translation api. - Browse page content to find additional translations created with third-party plugins such as
mkdocs-strings. - Save all translations in one JSON file per page to minimize access to the translation api and allow manual changes.
- Converts Markdown to HTML, translates and converts back to get text formatting like
code,strongandem. - Get fixe words in code tags with temporary HTML attributes.
- Navigation translation
- Copy the CNAME file required for gh-deploy to the root directory of the build.
- REPLACED - Ignore delimiters (e.g.
{[and]}) within a masking.
Feedback and support
I am happy to receive any kind of feedback and support.
Thank you for your interest in this plugin!
Have fun translating!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_material_langly-0.1.2.tar.gz.
File metadata
- Download URL: mkdocs_material_langly-0.1.2.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3347d53260d2963098d02e9ce7585f43fd8a99e9efb88fa3e973d5f7259ac809
|
|
| MD5 |
64b131d2920440ba1b2308fb1baa3629
|
|
| BLAKE2b-256 |
eed505a635f3f5364ccf71b8ef7c86f0b164e801bb1b4daede7a5c8973f30f2e
|
Provenance
The following attestation bundles were made for mkdocs_material_langly-0.1.2.tar.gz:
Publisher:
python-publish.yml on KemoPanzah/MkDocs-Material-Langly
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_material_langly-0.1.2.tar.gz -
Subject digest:
3347d53260d2963098d02e9ce7585f43fd8a99e9efb88fa3e973d5f7259ac809 - Sigstore transparency entry: 179592491
- Sigstore integration time:
-
Permalink:
KemoPanzah/MkDocs-Material-Langly@80f26b764217fadfc62e1840be5c00e02399bd3d -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/KemoPanzah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@80f26b764217fadfc62e1840be5c00e02399bd3d -
Trigger Event:
release
-
Statement type:
File details
Details for the file mkdocs_material_langly-0.1.2-py3-none-any.whl.
File metadata
- Download URL: mkdocs_material_langly-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97b7128569fb95f4283c0cc820f87680425f2732a7f31a25235cb9ba112f3532
|
|
| MD5 |
361e89b162d51feb4639e77a63fb99d3
|
|
| BLAKE2b-256 |
a2974444b126511ca93c92a0386308429587a6feeb19f2ebc9bcda78195186c9
|
Provenance
The following attestation bundles were made for mkdocs_material_langly-0.1.2-py3-none-any.whl:
Publisher:
python-publish.yml on KemoPanzah/MkDocs-Material-Langly
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_material_langly-0.1.2-py3-none-any.whl -
Subject digest:
97b7128569fb95f4283c0cc820f87680425f2732a7f31a25235cb9ba112f3532 - Sigstore transparency entry: 179592493
- Sigstore integration time:
-
Permalink:
KemoPanzah/MkDocs-Material-Langly@80f26b764217fadfc62e1840be5c00e02399bd3d -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/KemoPanzah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@80f26b764217fadfc62e1840be5c00e02399bd3d -
Trigger Event:
release
-
Statement type: