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

Multiple languages #129

Closed
egonelbre opened this issue Nov 21, 2013 · 5 comments
Closed

Multiple languages #129

egonelbre opened this issue Nov 21, 2013 · 5 comments

Comments

@egonelbre
Copy link
Contributor

I'm not sure what the best way is to do multilingual sites with this. Maybe an example would be useful with this.

I use currently this technique... on each page header:

lang: "et"
groups: ["et"]

And in the menu generation:

    {{ if (eq .Params.lang "en") }}
        {{ range .Site.Indexes.groups.en.Pages }}
            <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
        {{ end }}
    {{ else }}
        {{ range .Site.Indexes.groups.et.Pages }}
            <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
        {{ end }}
    {{ end }}

Is there an easier way to do this?

@spf13
Copy link
Contributor

spf13 commented Nov 22, 2013

We don’t have a defined way of doing this, but using an index as you have seems like a great approach. I’d be happy to add this as an example to the docs, probably in the indexing section. Would you care to send a pull request with this?

I’ve also given it some thought and if there’s a desire we could incorporate such functionality. 

One idea I had is that content could be tagged with a “language” by extension.

for example:
my_blog_post.md
my_blog_post.es.md

We could then render the permalinks to domain.com/my_blog_post/ and es.domain.com/my_blog_post/

I’m just not sure this solution is right for enough use cases. 

The nice thing about indexes is they are flexible enough to do things like this. 

Feedback welcome.

Best,
Steve

-- 
Steve Francia
http://stevefrancia.com
http://spf13.com
http://twitter.com/spf13

On November 21, 2013 at 11:14:52 AM, Egon Elbre (notifications@github.com) wrote:

I'm not sure what the best way is to do multilingual sites with this. Maybe an example would be useful with this.

I use currently this technique... on each page header:

lang: "et"
groups: ["et"]

And in the menu generation:

{{ if (eq .Params.lang "en") }}
    {{ range .Site.Indexes.groups.en.Pages }}
        <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
    {{ end }}
{{ else }}
    {{ range .Site.Indexes.groups.et.Pages }}
        <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
    {{ end }}
{{ end }}

Is there an easier way to do this?


Reply to this email directly or view it on GitHub.

@egonelbre
Copy link
Contributor Author

I finally got everything working as needed. I'll make a pull request once I put together a better example.

The problems I encountered were following:

  • Indexes don't allow front matter, which means I can't use multilingual layouts... e.g. I can't define a property in the front matter and do an if in a subtemplate.
  • I wasn't able to set the target url of an index.
  • I wasn't able to manually set the layout file to be used. I tried setting type, layout, template in the front matter, but it didn't seem to have any effect.
  • Permalink for a page didn't work when I set "url: /" for it in the front matter.
  • static css files aren't being updated while in watching mode.
  • Totally crashes on an empty content file.

My totally biased opinion on these things are... (of course do regard them as opinions... people have different needs... and etc.):

  • Allow some way to use subtemplates with property dispatch. e.g. you have layout files "head.en.html" and "head.et.html" then something like {{ template (join "head." .Params.lang ".html") . }}.
  • Move the "index.html" page to the content folder.
  • Move the "indexes" out of the layouts folder... or alternatively...
  • Remove the special "indexes" folder and simply use a content page with front matter defining "template: 'news/index.html'". You can write your "index" loop over pages inside the template with ".Data.Index.tag". For me, it would make things simpler to understand. This may also be because there aren't many examples how to use indexes properly.

I am also bit confused how the correct layout is found. Documentation for the layout finding, could be a simple: for "content/news/sub/item.html" it will try these templates in order... "layouts/news/single.html", "layouts/_default/single.html"...

(Don't let the bugs/issues I encountered discourage you... for me it's already nicer to use than jekyll... so great work :)

Best,
Egon

@egonelbre
Copy link
Contributor Author

  • Also it does auto pluralization for index titles, and I couldn't find a place where to override that.

@noahcampbell
Copy link
Contributor

Egon,

This is wonderful feedback. I think the new dimension here is the i18n aspect of what you're doing. Also...indexes need some tlc.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants