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 / translations #12

Open
5 tasks
danburzo opened this issue Jun 15, 2018 · 1 comment
Open
5 tasks

Multi-language / translations #12

danburzo opened this issue Jun 15, 2018 · 1 comment
Labels
brainstorming Discussing ideas around a concept and its implementation ↑↑↑ Priority: Essential

Comments

@danburzo
Copy link
Member

danburzo commented Jun 15, 2018

Marcel needs to be built with multi-language websites in mind. Some things that need to be translated:

  • the website's content
  • strings in templates
  • date formats
  • what else?

Configuring languages

In marcel.config.js:

languages: ['en', 'ro'],
defaultLanguage: 'ro'

Translating content

Translations of content are linked together by sharing the same file name and location in the content folder. They are distinguished by separate language suffixes.

content
  - my-post.ro.md
  - my-post.en.md

These two refer to the same post. The language code suffix is ignored when generating the slug.

What if one of the languages needs a different slug? It can be overriden in the post's front matter (the slug property).

Generating permalinks for content

One idea from WordPress-land is to have urls in the form:

http://mysite.com/posts/my-post
http://mysite.com/en/posts/my-post-in-english

That is, the defaultLanguage does not include the language code in the URL, while others do.

Note: It should be possible to override the permalink scheme for multi-language content.

Translating strings

This will probably require two things:

  • a dictionary (keep separate files in a language folder?)
  • a filter in the nunjucks templates

How does the filter look?

<a href='#next'>{{ "Next" | translate }}</a>

If no string is found in the dictionary for the current language, the string is rendered as-is.

Links to translated content

The templates should have access to a languages object that contains an array of all available languages.

Should the post object be augmented with a translations property that holds the equivalent posts? (Full objects, so you have access to title, content, permalink etc.)

@danburzo danburzo changed the title i18n Multi-language / translations Jun 16, 2018
@danburzo danburzo added brainstorming Discussing ideas around a concept and its implementation ↑↑ Priority: Important labels Jun 16, 2018
@danburzo danburzo mentioned this issue Jun 16, 2018
@danburzo danburzo added ↑↑↑ Priority: Essential and removed ↑↑ Priority: Important labels Nov 22, 2018
@danburzo
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brainstorming Discussing ideas around a concept and its implementation ↑↑↑ Priority: Essential
Projects
None yet
Development

No branches or pull requests

1 participant