Multi-language / translations
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
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
languagefolder?) - 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.)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with marcel.config.js, the content folder's language-suffixed files, and the Nunjucks template setup described in the issue. Trace how content, templates, dates, permalinks, and links are currently generated before deciding the configuration and translation design. Done should cover the listed multilingual content and string behavior, language-aware URLs, and access to translated content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- content, internationalization, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100