Skip to content

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

Development

Successfully merging this pull request may close these issues.

2 participants