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

.IsTranslated behaviour with identical filenames #2699

Closed
bcgwebdesign opened this Issue Nov 16, 2016 · 7 comments

Comments

Projects
None yet
5 participants
@bcgwebdesign

bcgwebdesign commented Nov 16, 2016

Using Hugo v0.17 on ubuntu 14.04.4

In the case of

/about/
/about/index.md
/about/index.de.md
/services/index.md

the ,isTranslated variable is true for /services/index.md and /about/index.md but both refer to the /about/index.de.md

Can the behaviour be improved to deal with this?

The workaround I'm going with at the moment is to not have filenames the same throughout the site.

(using this partial for showing when a page has a translation)

@bep

This comment has been minimized.

Show comment
Hide comment
@bep
Member

bep commented Nov 19, 2016

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep May 27, 2017

Member

This issue has been automatically marked as stale because it has not been commented on for at least six months.

The resources of the Hugo team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

Member

bep commented May 27, 2017

This issue has been automatically marked as stale because it has not been commented on for at least six months.

The resources of the Hugo team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@borisschapira

This comment has been minimized.

Show comment
Hide comment
@borisschapira

borisschapira Jun 7, 2017

@bep A possible workaround would be to add support for a translation key inside the front matter metadatas. That way, a contributor would specify the same key for content he would like to see matched, without interfering with filenames.

borisschapira commented Jun 7, 2017

@bep A possible workaround would be to add support for a translation key inside the front matter metadatas. That way, a contributor would specify the same key for content he would like to see matched, without interfering with filenames.

@bep bep added Keep Enhancement and removed Stale labels Jun 7, 2017

@bep bep added this to the v0.23 milestone Jun 7, 2017

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 7, 2017

Member

@borisschapira yea, that is probably the way to go.

Member

bep commented Jun 7, 2017

@borisschapira yea, that is probably the way to go.

@bep bep modified the milestones: v0.23, v0.24, v0.25 Jun 16, 2017

@bademux

This comment has been minimized.

Show comment
Hide comment
@bademux

bademux Jul 5, 2017

Nested section multilanguage articles are broken.
@borisschapira
"A possible workaround would be to add support for a translation key inside the front matter metadatas"

I think it will be safe to assume that all indices in the same path are translations, eg.

ls -la content/blog/test
index.md
index.pl.md
index.en.md
Meanwhile I place here very limited and ugly hack

Show language dropdown assertions: "en" is your default language path for article is unchanged content placed in "/content/" dir allarticle files are named as "index\.(.{2})\.md" PureCss framework is used ```html

  • {{ .Lang }}
      {{- range where .Site.AllPages "File.Dir" .File.Dir -}} {{- if ne .Lang $.Lang -}}
    • {{ .Lang }}
    • {{- end -}} {{- end -}}
``` used to be ```html
  • {{ .Lang }} {{ if .IsTranslated }}
      {{ range .Translations }}
    • {{ .Lang }}
    • {{ end}}
    {{ end }}
```

bademux commented Jul 5, 2017

Nested section multilanguage articles are broken.
@borisschapira
"A possible workaround would be to add support for a translation key inside the front matter metadatas"

I think it will be safe to assume that all indices in the same path are translations, eg.

ls -la content/blog/test
index.md
index.pl.md
index.en.md
Meanwhile I place here very limited and ugly hack

Show language dropdown assertions: "en" is your default language path for article is unchanged content placed in "/content/" dir allarticle files are named as "index\.(.{2})\.md" PureCss framework is used ```html

  • {{ .Lang }}
      {{- range where .Site.AllPages "File.Dir" .File.Dir -}} {{- if ne .Lang $.Lang -}}
    • {{ .Lang }}
    • {{- end -}} {{- end -}}
``` used to be ```html
  • {{ .Lang }} {{ if .IsTranslated }}
      {{ range .Translations }}
    • {{ .Lang }}
    • {{ end}}
    {{ end }}
```

@bep bep modified the milestones: v0.25, v0.26 Jul 5, 2017

@bep bep modified the milestones: v0.26, v0.27 Aug 6, 2017

@bep bep modified the milestones: v0.27, v0.28 Sep 7, 2017

@bep bep modified the milestones: v0.28, v0.27 Sep 7, 2017

mbarbon added a commit to mbarbon/hugo that referenced this issue Sep 18, 2017

hugolib: add new front matter field to use as the translation groupin…
…g key

Currently, Hugo uses only the filename to build the translation key for content
page, this means that pages with the same filename in different sections are
considered translations of the same content.

This commit implements the suggested solution in issue
gohugoio#2699

mbarbon added a commit to mbarbon/hugo that referenced this issue Sep 18, 2017

hugolib: add new front matter field to use as the translation groupin…
…g key

Currently, Hugo uses only the filename to build the translation key for content
page, this means that pages with the same filename in different sections are
considered translations of the same content.

This commit implements the suggested solution in issue
gohugoio#2699

Fixes gohugoio#2699

@bep bep modified the milestones: v0.28, v0.29, v0.30 Sep 21, 2017

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Sep 28, 2017

Member

It is hard to change this to anything good without breaking stuff, so I suggest this:

  • Add a TranslationKey method on Page
  • Use translationKey from front matter if set
  • Alternatively use "dir + .TranslationBaseName" (i.e. about/index.md)

Does that sound like a good approach?

Member

bep commented Sep 28, 2017

It is hard to change this to anything good without breaking stuff, so I suggest this:

  • Add a TranslationKey method on Page
  • Use translationKey from front matter if set
  • Alternatively use "dir + .TranslationBaseName" (i.e. about/index.md)

Does that sound like a good approach?

@bep bep modified the milestones: v0.30, v0.31 Oct 13, 2017

@bep bep self-assigned this Oct 30, 2017

@bep bep modified the milestones: v0.31, v0.32 Oct 30, 2017

@hudecof

This comment has been minimized.

Show comment
Hide comment
@hudecof

hudecof commented Nov 8, 2017

+1

bep added a commit to bep/hugo that referenced this issue Nov 17, 2017

hugolib: Fix .IsTranslated with identical filenames
This commit refines the key used to map translations:

* Use `translationKey` set in front matter
* Fall back to path + base filename (i.e. the filename without extension and language code)

Note that the Page Kinde will be prepended to both cases above. It does not make sense to have a section as translation for the home page.

Fixes gohugoio#2699

bep added a commit to bep/hugo that referenced this issue Nov 17, 2017

hugolib: Fix .IsTranslated with identical filenames
This commit refines the key used to map translations:

* Use `translationKey` set in front matter
* Fall back to path + base filename (i.e. the filename without extension and language code)

Note that the Page Kinde will be prepended to both cases above. It does not make sense to have a section as translation for the home page.

Fixes gohugoio#2699

@bep bep closed this in #4098 Nov 17, 2017

bep added a commit that referenced this issue Nov 17, 2017

hugolib: Fix .IsTranslated with identical filenames
This commit refines the key used to map translations:

* Use `translationKey` set in front matter
* Fall back to path + base filename (i.e. the filename without extension and language code)

Note that the Page Kinde will be prepended to both cases above. It does not make sense to have a section as translation for the home page.

Fixes #2699
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment