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

fix lang changes #1175

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,21 @@ If you want to add a new language, it's only a 2-step process:
[languages.en.params]
languageName = 'english'
languageNameShort = 'en'
languageCode = 'en'
[languages.fr]
contentDir = 'i18n/fr'
weight = 2
[languages.fr.params]
languageName = 'français'
languageNameShort = 'fr'
languageCode 'fr'
[languages.es]
contentDir = 'i18n/es'
weight = 3
[languages.fr.params]
languageName = 'español'
languageNameShort = 'es'
languageCode = 'es'
```
2. In the `i18n/` folder, add a yml file with the language shortname, e.g. `i18n/es.yml` (if spanish), and translate each key in this file.

Expand Down
17 changes: 17 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,26 @@ home = ['HTML']
[languages.en.params]
languageName = 'english'
languageNameShort = 'en'
languageCode = 'en'
[languages.fr]
contentDir = 'i18n/fr'
weight = 2
[languages.fr.params]
languageName = 'français'
languageNameShort = 'fr'
languageCode = 'fr'
[languages.pt-br]
contentDir = 'i18n/pt-br'
weight = 3
[languages.pt-br.params]
languageName = 'português brasileiro'
languageNameShort = 'pt-br'
languageCode = 'pt-br'
[languages.ja]
contentDir = 'i18n/ja'
weight = 4
[languages.ja.params]
languageName = '日本語'
languageNameShort = 'ja'
languageCode = 'jp'

45 changes: 0 additions & 45 deletions hugo.toml

This file was deleted.

6 changes: 3 additions & 3 deletions layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="{{ T "languageNameShort"}}">
<html lang="{{ .Site.Params.languageCode }}">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand Down Expand Up @@ -32,7 +32,7 @@
d="M60 0c33.137 0 60 26.863 60 60s-26.863 60-60 60S0 93.137 0 60 26.863 0 60 0zm4.167 26.667h-25c-6.904 0-12.5 5.596-12.5 12.5v25c0 6.903 5.596 12.5 12.5 12.5h4.166v4.166c0 6.904 5.597 12.5 12.5 12.5h25c6.904 0 12.5-5.596 12.5-12.5v-25c0-6.903-5.596-12.5-12.5-12.5h-4.166v-4.166c0-6.904-5.597-12.5-12.5-12.5zM80.833 47.5a8.343 8.343 0 018.334 8.333v25a8.343 8.343 0 01-8.334 8.334h-25a8.343 8.343 0 01-8.333-8.334v-4.166h16.667c6.903 0 12.5-5.597 12.5-12.5V47.5h4.166zM64.167 30.833a8.343 8.343 0 018.333 8.334v4.166H55.833c-6.903 0-12.5 5.597-12.5 12.5V72.5h-4.166a8.343 8.343 0 01-8.334-8.333v-25a8.343 8.343 0 018.334-8.334h25z"
fill-rule="evenodd"/>
</svg>
<h1 class="title" lang="en">{{ T "title" | safeHTML}}</h1>
<h1 class="title">{{ T "title" | safeHTML}}</h1>
<nav aria-label="{{ T "lang" | safeHTML}}">
<ul class="lang">
{{ $siteLanguages := site.Languages}}
Expand All @@ -44,7 +44,7 @@ <h1 class="title" lang="en">{{ T "title" | safeHTML}}</h1>
{{ if eq $pageLang .Lang}}
<li>{{ .Params.languageNameShort }} <span class="sr-only">{{ .Params.languageName }}</span></li>
{{ else }}
<li><a href="{{ $translation.Permalink | relURL }}" lang="{{ .Params.languageNameShort }}">{{ .Params.languageNameShort }} <span class="sr-only">{{ .Params.languageName }}</span></a></li>
<li><a href="{{ $translation.Permalink | relURL }}" lang="{{ .Params.languageCode }}">{{ .Params.languageNameShort }} <span class="sr-only">{{ .Params.languageName }}</span></a></li>
{{ end }}
{{ end }}
{{ end }}
Expand Down
Loading