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

Create a simple way to list pages with a default language edition if not found #4463

Closed
bep opened this Issue Mar 1, 2018 · 9 comments

Comments

Projects
None yet
3 participants
@bep
Copy link
Member

bep commented Mar 1, 2018

See https://discourse.gohugo.io/t/is-there-a-good-example-for-overlay-localization-with-hugo/10788

So, if this is rendering the Chinese site, I should be able to do something similar to:

{{ $pages := .Site.RegularPages | languages.Merge "en" }}
{{ range  $pages }}
{{ . }}
{{ end }}

The above should create a page list its default sort which:

  • includes all English pages not translated to Chinese
  • includes all Chinese pages

I would obviously have to work on the API/naming in the above, but the above is hard to do in the templates, but should be fairly trivial to do in Go.

@bep bep added the Enhancement label Mar 1, 2018

@bep bep added this to the v0.38 milestone Mar 1, 2018

@bep bep added the Effective label Mar 1, 2018

@RickCogley

This comment has been minimized.

Copy link
Contributor

RickCogley commented Mar 1, 2018

Related only because it's the same "multilingual" topic, and I can make another issue if it's indeed an issue-worthy thing, but I'd like to know if I can:

  • list all items of a taxonomy regardless of the language of the pages they are attached to, for something like a generic 404 page.
  • create taxo nav href's with something like {{ .URL | absLangURL }} that switches skillfully to what is appropriate for the language, say /tags/ or /en/tags/. In other words, a cleaner way than href="{{ if eq $thislang "en" }}/en/{{ else }}/{{ end }}tags">.

https://discourse.gohugo.io/t/multilingual-site-tag-lists-bug-feature/10688

(now asked in #4464)

@bep

This comment has been minimized.

Copy link
Member Author

bep commented Mar 1, 2018

@RickCogley you need to take that in another issue.

@bep

This comment has been minimized.

Copy link
Member Author

bep commented Mar 15, 2018

OK, naming/computer science experts out there:

{{ $pages := .Site.RegularPage | languages.Merge $enSite.RegularPages  }}

Or is:

{{ $pages := .Site.RegularPage | languages.Union $enSite.RegularPages  }}

... better?

The semantics are:

  • includes all pages in the right collection not translated in the left
  • includes all pages in the left collection

/cc @digitalcraftsman @moorereason @kaushalmodi

bep added a commit to bep/hugo that referenced this issue Mar 15, 2018

bep added a commit to bep/hugo that referenced this issue Mar 15, 2018

@kaushalmodi

This comment has been minimized.

Copy link
Member

kaushalmodi commented Mar 15, 2018

Thanks for the ping. I don't have a strong opinion between Merge and Union, but Merge somehow feels a bit better over here.

@bep

This comment has been minimized.

Copy link
Member Author

bep commented Mar 15, 2018

Thinking about it, this is a left join, so languages.LeftJoin would be better ...

@RickCogley

This comment has been minimized.

Copy link
Contributor

RickCogley commented Mar 15, 2018

@kaushalmodi

This comment has been minimized.

Copy link
Member

kaushalmodi commented Mar 15, 2018

Thinking about it, this is a left join

TIL about LEFT JOIN. But even after reading that:

The LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2). The result is NULL from the right side, if there is no match.

If I understand correctly, what we are trying to do here is (changes for our application in bold):

The LEFT JOIN keyword returns all records from the left table (table1), and the unmatched records from the right table (table2). The result is ALL from the right side, if there is no match.

So it doesn't technically seem to be LEFT JOIN for folks who might be familiar with that.. or may be I am just wrong :)

@bep

This comment has been minimized.

Copy link
Member Author

bep commented Mar 15, 2018

So it doesn't technically seem to be LEFT JOIN for folks who might be familiar with that.. or may be I am just wrong :)

You are absolutely right. I'm thinking slowly today.

@bep

This comment has been minimized.

Copy link
Member Author

bep commented Mar 15, 2018

I will add .MergeByLanguage to the Pages to start with. I will see if I add a languages.Merge template func -- it may make sense to make this pipe friendly. Not sure.

bep added a commit to bep/hugo that referenced this issue Mar 15, 2018

bep added a commit to bep/hugo that referenced this issue Mar 15, 2018

bep added a commit to bep/hugo that referenced this issue Mar 15, 2018

bep added a commit to bep/hugo that referenced this issue Mar 15, 2018

bep added a commit to bep/hugo that referenced this issue Mar 15, 2018

bep added a commit to bep/hugo that referenced this issue Mar 15, 2018

bep added a commit to bep/hugo that referenced this issue Mar 15, 2018

bep added a commit to bep/hugo that referenced this issue Mar 15, 2018

bep added a commit to bep/hugo that referenced this issue Mar 15, 2018

bep added a commit to bep/hugo that referenced this issue Mar 16, 2018

Add a way to merge pages by language
As an example:

```html
{{ $pages := .Site.RegularPages | lang.Merge $frSite.RegularPages | lang.Merge $enSite.RegularPages }}
```

Will "fill in the gaps" in the current site with, from left to right, content from the French site, and lastly the English.

Fixes gohugoio#4463

bep added a commit to bep/hugo that referenced this issue Mar 16, 2018

bep added a commit to bep/hugo that referenced this issue Mar 16, 2018

Add a way to merge pages by language
As an example:

```html
{{ $pages := .Site.RegularPages | lang.Merge $frSite.RegularPages | lang.Merge $enSite.RegularPages }}
```

Will "fill in the gaps" in the current site with, from left to right, content from the French site, and lastly the English.

Fixes gohugoio#4463

bep added a commit to bep/hugo that referenced this issue Mar 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.