Hi, I can’t make i18n / the Translate method works. It just prints nothing, no error, just nothing.
Content of fr-FR.toml:
glossary = "Glossaire"
close-glossary = "Fermer le glossaire"
consulter-glossary = "Consulter le Glossaire"
read-more = "Lire la suite"
in baseof.html
<footer id="footer">
<div class="left">
{{ site.Title}}
</div>
<div class="glossaire-footer">
<a href="{{(site.GetPage "/glossaire/").RelPermalink}}">
{{ T "consulter-glossary" }}
</a>
</div>
<div class="right">
{{now.Year}}
</div>
</footer>
i18n directory:
/home/drm/Psychototal_hugo/i18n
├── de-DE.toml
├── en-US.toml
└── fr-FR.toml
Arif
January 23, 2024, 6:48pm
2
Tom_Durand:
Content of fr-FR.toml:
Try this instead
[glossary]
other = "Glossaire"
For simple translations (no pluralization) you can just do:
foo = 'bar'
https://gohugo.io/functions/lang/translate/
Please post the languages section of your site config.
Arif
January 23, 2024, 8:52pm
5
Interesting…I guess I need to rework my i8n files then.
[languages]
[languages.de]
LanguageName = 'Deutsch'
LanguageCode = 'de-DE'
title = 'Totale Psychologie'
weight = 3
[languages.en]
LanguageName = 'English'
LanguageCode = 'en-US'
title = 'Total Psychology'
weight = 2
[languages.fr]
LanguageName = 'Français'
LanguageCode = 'fr-FR'
title = 'Psychologie Totale'
weight = 1
fr-FR.toml
glossary = "Glossaire"
close-glossary = "Fermer le glossaire"
consulter-glossary = "Consulter le Glossaire"
read-more = "Lire la suite"
Before I had the "other = " format. Same result either way. Is it possible to put it all three languages in the same file ?
Hugo’s localization features (translations, dates, currencies, collation, etc.) are based on the language key. In your example above, the language keys are de, en, and fr.
Hugo’s localization features are not based on .Site.Language.LanguageCode. That value is only used in a few of the built-in templates. See https://gohugo.io/content-management/multilingual/#configure-languages .
Your i18n/xxx filenames must match the lanugage key.
Is it possible to put it all three languages in the same file ?
No.
system
Closed
January 25, 2024, 11:22pm
9
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.