adityatelange / hugo-PaperMod

A fast, clean, responsive Hugo theme.
https://adityatelange.github.io/hugo-PaperMod/
MIT License
9.6k stars 2.59k forks source link

[Enhancement]: problem multilingual solved #1585

Open taf-neutrino opened 2 weeks ago

taf-neutrino commented 2 weeks ago

What you'd like to propose?

Hugo version: v0.133.0
PaperMod release: 7.0

[solved] First problem, multilingual breadcrumbs.

Example path of file sistem: /content/articles

Configuration hugo.yaml

...
languages:
    en:  
        permalinks:
        page:
            articles: /articles/:slug/
        section:
            articles: /articles/
        menu:
            main:
                - name: Articles
                url: articles/
    it:
        permalinks:
        page:
            articles: /articoli/:slug/
        section:
            articles: /articoli/
        menu:
            main:
                - name: Articoli
                url: articoli/
...

The problem is found in breadcrumbs, if you use only one language works correctly. I modified the file /layouts/partials/breadcrumbs.html with the code I attach.

{{- if (.Param "ShowBreadCrumbs") -}}
<div class="breadcrumbs">
    {{- range .Ancestors.Reverse }}
    <a href="{{ .RelPermalink }}">{{ if .IsHome }}{{ i18n "home" }}{{ else }}{{ print "&nbsp;»&nbsp;" | safeHTML }}{{ .Title }}{{ end }}</a>    
    {{- end -}}
</div>
{{- end -}}

[solved] Second problem, translation tag page.

Configuration hugo.yaml

...
languages:
    en:
        taxonomies:
        tag: tags
    it:
        taxonomies:
        tag: etichette
...

For tags page the problem is present for other languages, the data are not shown.

The solution:

# i18n/en.yaml
- id: tag
  translation: "tags"

# i18n/it.yaml  
- id: tag
  translation: "etichette"

I've changed row number 46 /layouts/_default/single.html

    <!-- original code -->
    {{- $tags := .Language.Params.Taxonomies.tag | default "tags" }}
    <!-- code modified -->
    {{- $tags := .Language.Params.Taxonomies.tag | default | i18n "tag" }}

Code of Conduct