Fix Learn theme addition to git
This commit is contained in:
78
themes/learn/exampleSite/content/cont/i18n/_index.en.md
Normal file
78
themes/learn/exampleSite/content/cont/i18n/_index.en.md
Normal file
@ -0,0 +1,78 @@
|
||||
---
|
||||
date: 2016-04-09T16:50:16+02:00
|
||||
title: Multilingual and i18n
|
||||
weight: 30
|
||||
---
|
||||
|
||||
**Learn theme** is fully compatible with Hugo multilingual mode.
|
||||
|
||||
It provides:
|
||||
|
||||
- Translation strings for default values (English and French). Feel free to contribute !
|
||||
- Automatic menu generation from multilingual content
|
||||
- In-browser language switching
|
||||
|
||||

|
||||
|
||||
## Basic configuration
|
||||
|
||||
After learning [how Hugo handle multilingual websites](https://gohugo.io/content-management/multilingual), define your languages in your `config.toml` file.
|
||||
|
||||
For example with current French and English website.
|
||||
|
||||
```toml
|
||||
# English is the default language
|
||||
defaultContentLanguage = "en"
|
||||
# Force to have /en/my-page and /fr/my-page routes, even for default language.
|
||||
defaultContentLanguageInSubdir= true
|
||||
|
||||
[Languages]
|
||||
[Languages.en]
|
||||
title = "Documentation for Hugo Learn Theme"
|
||||
weight = 1
|
||||
languageName = "English"
|
||||
|
||||
[Languages.fr]
|
||||
title = "Documentation du thème Hugo Learn"
|
||||
weight = 2
|
||||
languageName = "Français"
|
||||
```
|
||||
|
||||
Then, for each new page, append the *id* of the language to the file.
|
||||
|
||||
- Single file `my-page.md` is split in two files:
|
||||
- in English: `my-page.en.md`
|
||||
- in French: `my-page.fr.md`
|
||||
- Single file `_index.md` is split in two files:
|
||||
- in English: `_index.en.md`
|
||||
- in French: `_index.fr.md`
|
||||
|
||||
{{% notice info %}}
|
||||
Be aware that only translated pages are displayed in menu. It's not replaced with default language content.
|
||||
{{% /notice %}}
|
||||
|
||||
{{% notice tip %}}
|
||||
Use [slug](https://gohugo.io/content-management/multilingual/#translate-your-content) Front Matter parameter to translate urls too.
|
||||
{{% /notice %}}
|
||||
|
||||
## Overwrite translation strings
|
||||
|
||||
Translations strings are used for common default values used in the theme (*Edit this page* button, *Search placeholder* and so on). Translations are available in french and english but you may use another language or want to override default values.
|
||||
|
||||
To override these values, create a new file in your local i18n folder `i18n/<idlanguage>.toml` and inspire yourself from the theme `themes/hugo-theme-learn/i18n/en.toml`
|
||||
|
||||
By the way, as these translations could be used by other people, please take the time to propose a translation by [making a PR](https://github.com/matcornic/hugo-theme-learn/pulls) to the theme !
|
||||
|
||||
## Disable language switching
|
||||
|
||||
Switching the language in the browser is a great feature, but for some reasons you may want to disable it.
|
||||
|
||||
Just set `disableLanguageSwitchingButton=true` in your `config.toml`
|
||||
|
||||
```toml
|
||||
[params]
|
||||
# When using mulitlingual website, disable the switch language button.
|
||||
disableLanguageSwitchingButton = true
|
||||
```
|
||||
|
||||

|
78
themes/learn/exampleSite/content/cont/i18n/_index.fr.md
Normal file
78
themes/learn/exampleSite/content/cont/i18n/_index.fr.md
Normal file
@ -0,0 +1,78 @@
|
||||
---
|
||||
date: 2016-04-09T16:50:16+02:00
|
||||
title: Multi-langue et i18n
|
||||
weight: 30
|
||||
---
|
||||
|
||||
**Learn** est complètement compatible avec le mode multi-langue d'Hugo.
|
||||
|
||||
Il fournit :
|
||||
|
||||
- Des *translation strings* pour les valeurs par défaut utilisées par le thème (Anglais et Français). N'hésitez pas à contribuer !
|
||||
- Génération automatique du menu avec le contenu multi-langue
|
||||
- Modification de la langue dans le navigateur
|
||||
|
||||

|
||||
|
||||
## Configuration simple
|
||||
|
||||
Après avoir appris [comment Hugo gère les sites multi-langue](https://gohugo.io/content-management/multilingual), définissez vos langues dans votre fichier `config.toml`.
|
||||
|
||||
Par exemple, pour ce site, avec du contenu en français et en anglais.
|
||||
|
||||
```toml
|
||||
# Anglais est la langue par défaut
|
||||
defaultContentLanguage = "en"
|
||||
# Force d'avoir /en/ma-page et /fr/ma-page routes, même avec la langue par défaut.
|
||||
defaultContentLanguageInSubdir= true
|
||||
|
||||
[Languages]
|
||||
[Languages.en]
|
||||
title = "Documentation for Hugo Learn Theme"
|
||||
weight = 1
|
||||
languageName = "English"
|
||||
|
||||
[Languages.fr]
|
||||
title = "Documentation du thème Hugo Learn"
|
||||
weight = 2
|
||||
languageName = "Français"
|
||||
```
|
||||
|
||||
Puis, pour chaque nouvelle page, ajoutez *l'id* de la langue du fichier.
|
||||
|
||||
- Le fichier `my-page.md` est découpé en deux fichiers :
|
||||
- en anglais : `my-page.en.md`
|
||||
- en français : `my-page.fr.md`
|
||||
- Le fichier `_index.md` est découpé en deux fichiers :
|
||||
- en anglais: `_index.en.md`
|
||||
- en français: `_index.fr.md`
|
||||
|
||||
{{% notice info %}}
|
||||
Attention, seulement les pages traduites sont affichées dans le menu. Le contenu n'est pas remplacé par les pages de la langue par défaut.
|
||||
{{% /notice %}}
|
||||
|
||||
{{% notice tip %}}
|
||||
Utilisez le paramètre du Front Matter [slug](https://gohugo.io/content-management/multilingual/#translate-your-content) pour traduire également les URLs.
|
||||
{{% /notice %}}
|
||||
|
||||
## Surcharger les *translation strings*
|
||||
|
||||
Les *Translations strings* sont utilisées comme valeurs par défaut dans le thème (Bouton *Modifier la page*, Element de subsitution *Recherche*, etc.). Les traductions sont disponibles en français et en anglais mais vous pouvez utiliser n'importe quelle autre langue et surcharger avec vos propres valeurs.
|
||||
|
||||
Pour surcharger ces valeurs, créer un nouveau fichier dans votre dossier i18n local `i18n/<idlanguage>.toml` et inspirez vous du thème `themes/hugo-theme-learn/i18n/en.toml`
|
||||
|
||||
D'ailleurs, ces traductions pour servir à tout le monde, donc svp prenez le temps de [proposer une Pull Request](https://github.com/matcornic/hugo-theme-learn/pulls) !
|
||||
|
||||
## Désactiver le changement de langue
|
||||
|
||||
Vous pouvez changer de langue directement dans le navigateur. C'est une super fonctionnalité, mais vous avez peut-être besoin de la désactiver.
|
||||
|
||||
Pour ce faire, ajouter le paramètre `disableLanguageSwitchingButton=true` dans votre `config.toml`
|
||||
|
||||
```toml
|
||||
[params]
|
||||
# Quand vous utilisez un site en multi-langue, désactive le bouton de changment de langue.
|
||||
disableLanguageSwitchingButton = true
|
||||
```
|
||||
|
||||

|
BIN
themes/learn/exampleSite/content/cont/i18n/images/i18n-menu.gif
Normal file
BIN
themes/learn/exampleSite/content/cont/i18n/images/i18n-menu.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Reference in New Issue
Block a user