ultrabug / mkdocs-static-i18n

MkDocs i18n plugin using static translation markdown files
https://ultrabug.github.io/mkdocs-static-i18n/
MIT License
229 stars 38 forks source link

"Help to translate" options in the language switcher #266

Closed Andygol closed 1 year ago

Andygol commented 1 year ago

I am attempting to replicate the following approach to encourage users to participate in the translation of a project based on Materials for MkDocs. This involves placing a call to action in the language menu drop-down, similar to what is done on the https://spaceship-prompt.sh website.

image

In the spaceship-prompt repo I found next code

extra:
  alternate:
    - name: English
      lang: en
      link: .
    - name: Deutsch
      lang: de
      link: /de/
    - name: Français
      lang: fr
      link: /fr/
    - name: Українська
      lang: uk
      link: /uk/
    - name: 简体中文
      lang: zh
      link: /zh/
    - name: Help translating
      lang: null
      link: https://translate.spaceship-prompt.sh/

I would prefer not to use alternate but leverage the capabilities of mkdocs-static-i18n for implementing the language switcher.

plugin:
    - i18n:
      docs_structure: folder
      reconfigure_material: true
      languages:
        - locale: en
          name: English
        - locale: de
          name: Deutsch
        - locale: null
          name: Help to translate
          link: http://translate.service/

Unfortunately, I got next

ERROR   -  Config value 'plugins': Plugin 'i18n' option 'languages': Sub-option 'locale': Required configuration not provided.
Aborted with 1 configuration errors!

Even if I specified valid locale ISO-code, link is still invalid

ERROR   -  Config value 'plugins': Plugin 'i18n' option 'languages': Sub-option 'link': languages[io].link should be an absolute
           link starting with a leading / and ending with a / (like /io/).
Aborted with 1 configuration errors!

Could you consider adding such a call to action option to facilitate translation efforts?

ultrabug commented 1 year ago

Thanks for detailing the issue and what you'd like @Andygol

Let me think about it, having a full URL as a link is easy. Finding the right option for the locale raises more questioning tho...

ultrabug commented 1 year ago

@Andygol you'll be happy to hear that I've proposed #270 to allow that behavior using the null locale along with a fixed_link usage.

Tests are OK + I added a special section in the documentation about this feature

Andygol commented 1 year ago

🙏 Thank you very much for the implementation. This will make it possible to keep all necessary parameters with translation in one place in mkdocs.yml. I look forward to the release.

ultrabug commented 1 year ago

Version 1.1.0 is out