Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi language site support #100

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Conversation

Ze0nC
Copy link
Contributor

@Ze0nC Ze0nC commented Nov 11, 2020

Hi @JohnSundell

Thank you for creating Publish.

I wanted to make my site support multi-language, for example:

  • example.com/en, for English index
  • example.com/en/posts/article, for English article
  • example.com/zh, for Chinese index
  • example.com/zh/posts/article, for Chinese article

So I tried to:

  • Add markdown files in different folders for each language
  • Correlate markdown files in language variations of the same item.
  • Output the html files in folders for each language.
  • And keep behavior of standard Website unchanged.

You may check how to use it in documentation: generate-multi-language-site

I have applied it to my own site at: czj.io

The design is basically :

  • Add var language: Language? to ContentProtocol, to assign each item/page/index a language.
  • Add public protocol MultiLanguageWebsite: Website where ItemMetadata: MultiLanguageWebsiteItemMetadata
  • Extend existing struct/protocol to handle multi-language website
  • Added internal struct MultiLanguageContentManager to correlate items and links of different languages.

I had to override (mostly copy and paste) many functions to handle multi-language website while keeping original functions unchanged. This caused redundant in code.

If you agree, I want to try to merge the code of MultiLanguageWebsite into Website, to make codes shorter and clearer.

I understand that you are busy recently and may not have much time on checking this.
But I sincerely hope to hear from you and get feedback.

Cheers,
Zhijin

@JohnEstropia
Copy link

@JohnSundell Hi, this PR had aged a bit but I think multi-language support is still a desired feature.
What were your thoughts on how to approach localization?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants