Browse Source

i18n for navigation items

tags/v1.0.0
Robert Roth 4 years ago
parent
commit
7e4ac98dfd
4 changed files with 42 additions and 14 deletions
  1. 8
    8
      exampleSite/config.toml
  2. 15
    1
      exampleSite/i18n/en.yaml
  3. 15
    1
      exampleSite/i18n/fr.yaml
  4. 4
    4
      layouts/partials/navigation.html

+ 8
- 8
exampleSite/config.toml View File



############################# Navigation ################################## ############################# Navigation ##################################
[[menu.main]] [[menu.main]]
name = "About Us"
name = "about"
URL = "about" URL = "about"
weight = 1 weight = 1


[[menu.main]] [[menu.main]]
name = "Service"
name = "services"
URL = "services" URL = "services"
weight = 2 weight = 2


[[menu.main]] [[menu.main]]
name = "Portfolio"
name = "portfolio"
URL = "portfolio" URL = "portfolio"
weight = 3 weight = 3


[[menu.main]] [[menu.main]]
name = "Team"
name = "team"
URL = "team" URL = "team"
weight = 4 weight = 4


[[menu.main]] [[menu.main]]
name = "Pricing"
name = "pricing"
URL = "pricing" URL = "pricing"
weight = 5 weight = 5


[[menu.main]] [[menu.main]]
name = "Blog"
name = "blog"
URL = "blog" URL = "blog"
weight = 6 weight = 6


[[menu.main]] [[menu.main]]
name = "Contact"
name = "contact"
URL = "contact" URL = "contact"
weight = 7 weight = 7


contentDir = "content/french" contentDir = "content/french"
weight = 2 weight = 2
home = "Accueil" home = "Accueil"
copyright = "copyright et copie; 2019 [gethugothemes] (https://gethugothemes.com) tous droits réservés"
copyright = "copyright et copie; 2019 [gethugothemes] (https://gethugothemes.com) tous droits réservés"

+ 15
- 1
exampleSite/i18n/en.yaml View File

- id: submit - id: submit
translation: Submit translation: Submit
- id: all - id: all
translation: All
translation: All
- id: about
translation: About Us
- id: services
translation: Service
- id: portfolio
translation: Portfolio
- id: team
translation: Team
- id: pricing
translation: Pricing
- id: blog
translation: Blog
- id: contact
translation: Contact

+ 15
- 1
exampleSite/i18n/fr.yaml View File

- id: submit - id: submit
translation: Soumettre translation: Soumettre
- id: all - id: all
translation: All
translation: All
- id: about
translation: À propos
- id: services
translation: Services
- id: portfolio
translation: Portfolio
- id: team
translation: Équipe
- id: pricing
translation: Tarification
- id: blog
translation: Blog
- id: contact
translation: Contact

+ 4
- 4
layouts/partials/navigation.html View File

<li class="nav-item"><a class="nav-link" href="#body">{{ .Site.Params.home }}</a></li> <li class="nav-item"><a class="nav-link" href="#body">{{ .Site.Params.home }}</a></li>
{{ if .IsHome }} {{ if .IsHome }}
{{ range .Site.Menus.main }} {{ range .Site.Menus.main }}
<li class="nav-item"><a class="nav-link" href="#{{ .URL }}">{{ .Name }}</a></li>
<li class="nav-item"><a class="nav-link" href="#{{ .URL }}">{{ i18n .Name }}</a></li>
{{ end }} {{ end }}


{{ else }} {{ else }}


{{ range .Site.Menus.main }} {{ range .Site.Menus.main }}
<li class="nav-item"><a class="nav-link" href="{{ $.Site.BaseURL | relLangURL }}#{{ .URL }}">{{ .Name }}</a>
<li class="nav-item"><a class="nav-link" href="{{ $.Site.BaseURL | relLangURL }}#{{ .URL }}">{{ i18n .Name }}</a>
</li> </li>
{{ end }} {{ end }}
{{ end }} {{ end }}


{{ range .Site.Menus.static }} {{ range .Site.Menus.static }}
<li class="nav-item"><a class="nav-link" target="_blank" href="{{ .URL }}">{{ .Name }}</a>
<li class="nav-item"><a class="nav-link" target="_blank" href="{{ .URL }}">{{ i18n .Name }}</a>
</li> </li>
{{ end }} {{ end }}
</div> </div>
</nav> </nav>
</div> </div>
</section>
</section>

Loading…
Cancel
Save