diff --git a/README.md b/README.md index 401a230..27e1660 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,31 @@ Described at [documentation](https://github.com/stradichenko/PKB-theme/blob/main ### [Color Theme Customization](https://stradichenko.github.io/PKB-theme/docs/color-theme-customization) +### Internationalization (i18n) + +The theme uses Hugo's built-in [i18n](https://gohugo.io/content-management/multilingual/) system so that template strings can be translated. All user-facing strings live in `i18n/en.toml` at the theme root, and templates reference them via `{{ T "key" }}`. + +To add a translation: + +1. Copy `i18n/en.toml` to `i18n/.toml` (e.g. `i18n/es.toml` for Spanish) and translate the values, leaving the keys unchanged. +2. Register the new language in `config/_default/hugo.toml` under the `[languages]` block: + + ```toml + [languages] + [languages.en] + languageName = "English" + languageCode = "en-US" + weight = 1 + [languages.es] + languageName = "Español" + languageCode = "es-ES" + weight = 2 + ``` + +3. Optionally, override individual strings from your own site by creating an `i18n/.toml` file in your project root — Hugo's lookup order will prefer your project's translations over the theme's defaults. + +See [Hugo's multilingual documentation](https://gohugo.io/content-management/multilingual/) for full details on translating content, menus, and dates. + ## FAQ ### Hugo's Theme Configuration Inheritance (Lookup Order) diff --git a/config/_default/hugo.toml b/config/_default/hugo.toml index a01c33d..88bd991 100644 --- a/config/_default/hugo.toml +++ b/config/_default/hugo.toml @@ -2,6 +2,9 @@ baseURL = 'https://example.org/' languageCode = 'en-us' title = 'HUGO_site' +defaultContentLanguage = "en" +defaultContentLanguageInSubdir = false + enableGitInfo = true #relativeURLs = true #canonifyURLs = true @@ -518,4 +521,10 @@ enableGitInfo = true filename = 'sitemap.xml' priority = -1 -uglyURLs = false \ No newline at end of file +uglyURLs = false + +[languages] + [languages.en] + languageName = "English" + languageCode = "en-US" + weight = 1 \ No newline at end of file diff --git a/i18n/en.toml b/i18n/en.toml new file mode 100644 index 0000000..e1a64b4 --- /dev/null +++ b/i18n/en.toml @@ -0,0 +1,103 @@ +# Common +SiteTitle = "PKB Theme" +ReadMore = "Read more" +BackToTop = "Back to top" + +# Single post +Created = "Created" +Updated = "Updated" +TableOfContents = "Table of Contents" +Author = "Author" +Tags = "Tags" +Categories = "Categories" +References = "References" +Footnotes = "Footnotes" +Citations = "Citations" + +# Search +Search = "Search" +SearchPlaceholder = "Search…" +SearchNoResults = "No results" +SearchResultsFor = "Results for" + +# Theme toggle +ToggleTheme = "Toggle theme" +ThemeLight = "Light" +ThemeDark = "Dark" + +# Share +Share = "Share" +ShareModalTitle = "Share this page" +CopyLink = "Copy link" +LinkCopied = "Link copied!" + +# QR +QRCode = "QR code" +QRCodeFor = "QR code for" + +# About page +NoSocialLinks = "No social links available." +NoInterests = "No interests listed." +Interests = "Interests" + +# PDF +GeneratePDF = "Generate PDF" +PrintToPDF = "Print to PDF" + +# TTS +ListenToPage = "Listen to this page" +TTSSystemVoice = "System Voice" +TTSBrowserBuiltin = "Browser built-in" +TTSNeuralHD = "Neural HD" +TTSOnetimeDownload = "One-time download · cached locally" +TTSPlay = "Play" +TTSPause = "Pause" +TTSStop = "Stop" + +# Knowledge graph +KGPhysicsControls = "Physics Controls" +KGRepulsion = "Repulsion" +KGResetToDefault = "Reset to Default" +KGAllNodes = "All Nodes" +KGSaveAsPNG = "Save as PNG" +KGSaveAsSVG = "Save as SVG" +KGSaveAsJPEG = "Save as JPEG" +KGFullscreen = "Fullscreen" + +# Activity calendar +ActivityCalendar = "Activity Calendar" +CalendarLess = "Less" +CalendarMore = "More" +CalendarContributions = "contributions" +CalendarNoActivity = "No activity" + +# Zipf's law / LDA +ZipfTitle = "Zipf's Law" +ZipfWord = "Word" +ZipfFrequency = "Frequency" +ZipfRank = "Rank" +LDATopics = "Topics" +LDADocument = "Document" +LDATopicNumber = "Topic" + +# Filters +FilterByTag = "Filter by tag" +FilterByCategory = "Filter by category" +FilterClear = "Clear filters" +FilterAll = "All" + +# 404 page +NotFoundTitle = "404 — Page Not Found" +NotFoundMessage = "The page you are looking for could not be found." +NotFoundReturnHome = "Return home" + +# Comments +CommentsLoading = "Loading comments…" +CommentsDisabled = "Comments are disabled." + +# Misc +PoweredBy = "Powered by" +GeneratedBy = "Generated by" +LoadingMore = "Loading more…" +Error = "Error" +AnchorLabel = "Permalink to this section"