From ed48563aa290d95c5278179c26b824c522875227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=C4=83ng=20T=C3=BA?= <6233777-ngdangtu@users.noreply.gitlab.com> Date: Sat, 26 Sep 2020 21:08:16 +0700 Subject: [PATCH] Misc improvements Add Windows note for installing from source (gcc) Correct multilingual.md typo and i18n.md info Add detail for Installation on Windows note Reverse misinfo, this need more investigation. --- content/en/content-management/multilingual.md | 14 +++-- content/en/functions/i18n.md | 2 +- content/en/getting-started/installing.md | 57 ++++++++++++------- 3 files changed, 49 insertions(+), 24 deletions(-) diff --git a/content/en/content-management/multilingual.md b/content/en/content-management/multilingual.md index 49c09b3f6..613f590c2 100644 --- a/content/en/content-management/multilingual.md +++ b/content/en/content-management/multilingual.md @@ -335,13 +335,13 @@ This article has 101 words. ### Query a singular/plural translation -In order to meet singular/plural requirement, you must pass a dictionary (map) with a numeric `.Count` property to the `i18n` function. The below example uses `.ReadingTime` variable which has a built-in `.Count` property. +In other to meet singular/plural requirement, you must pass a dictionary (map) with a numeric `.Count` property to the `i18n` function. The below example uses `.ReadingTime` variable which has a built-in `.Count` property. ```go-html-template {{ i18n "readingTime" .ReadingTime }} ``` -The function will read `.Count` from `.ReadingTime` and evaluate where the number is singular (`one`) or plural (`other`). After that, it will pass to `readingTime` id: +The function will read `.Count` from `.ReadingTime` and evaluate whether the number is singular (`one`) or plural (`other`). After that, it will pass to `readingTime` id in `i18n/en-US.toml` file: {{< code-toggle file="i18n/en-US" >}} [readingTime] @@ -349,7 +349,7 @@ one = "One minute to read" other = "{{.Count}} minutes to read" {{< /code-toggle >}} -Assume `.ReadingTime.Count` in the context has value of 525600. The result will be: +Assuming `.ReadingTime.Count` in the context has value is 525600. The result will be: ```text 525600 minutes to read @@ -361,7 +361,7 @@ If `.ReadingTime.Count` in the context has value is 1. The result is: One minute to read ``` -In case you need to pass custom data: (`(dict "Count" 25)` is minimum requirement) +In case you need to pass a custom data: (`(dict "Count" numeric_value_only)` is minimum requirment) ```go-html-template {{ i18n "readingTime" (dict "Count" 25 "FirstArgument" true "SecondArgument" false "Etc" "so on, so far") }} @@ -569,6 +569,12 @@ To support Multilingual mode in your themes, some considerations must be taken f If there is more than one language defined, the `LanguagePrefix` variable will equal `/en` (or whatever your `CurrentLanguage` is). If not enabled, it will be an empty string (and is therefore harmless for single-language Hugo websites). + +## Generate multilingual content with `hugo new` +Currently, `hugo new` is not ready to support generating multilingual content. But there is a [proposal topic](https://github.com/gohugoio/hugo/issues/7732) about this in Github issue to discuss how it should work. + + + [abslangurl]: /functions/abslangurl [config]: /getting-started/configuration/ [contenttemplate]: /templates/single-page-templates/ diff --git a/content/en/functions/i18n.md b/content/en/functions/i18n.md index 7d88292b9..5c2e019dc 100644 --- a/content/en/functions/i18n.md +++ b/content/en/functions/i18n.md @@ -18,7 +18,7 @@ deprecated: false aliases: [] --- -This translates a piece of content based on your `i18n/en-US.yaml` (and similar) files. You can use the [go-i18n](https://github.com/nicksnyder/go-i18n) tools to manage your translations. The translations can exist in both the theme and at the root of your repository. +This translates a piece of content based on your `i18n/en-US.toml` files. You can use the [go-i18n](https://github.com/nicksnyder/go-i18n) tools to manage your translations. The translations can exist in both the theme and at the root of your repository. ``` {{ i18n "translation_id" }} diff --git a/content/en/getting-started/installing.md b/content/en/getting-started/installing.md index e0df15d72..d2d912a28 100644 --- a/content/en/getting-started/installing.md +++ b/content/en/getting-started/installing.md @@ -109,6 +109,7 @@ scoop install hugo-extended #### Prerequisite Tools * [Git][installgit] +* [GCC][] (For Windows users only) * [Go (at least Go 1.11)](https://golang.org/dl/) #### Fetch from GitHub @@ -126,7 +127,14 @@ go install --tags extended Remove `--tags extended` if you do not want/need Sass/SCSS support. {{% note %}} -If you are a Windows user, substitute the `$HOME` environment variable above with `%USERPROFILE%`. + +##### For installation on Windows + +* Substitute the `$HOME` environment variable above with `%USERPROFILE%`. +* If you install `--tags extended` version, you may encounter this error `"gcc": executable file not found in %PATH%` + * Please make sure you have installed `gcc` command and add it to `%PATH%`. + * "MinGW" is recommended, it has been tested and built successfully + {{% /note %}} ## macOS @@ -289,21 +297,21 @@ If `hugo` is not in your `PATH`: If your default shell is zsh: - ``` - nano ~/.zprofile - ``` - - If your default shell is bash: - - ``` - nano ~/.bash_profile - ``` + ``` + nano ~/.zprofile + ``` + + If your default shell is bash: + + ``` + nano ~/.bash_profile + ``` 3. Insert a line to add `$HOME/bin` to your existing `PATH`. - ``` - export PATH=$PATH:$HOME/bin - ``` + ``` + export PATH=$PATH:$HOME/bin + ``` 4. Save the file by pressing Control-X, then Y. @@ -358,7 +366,7 @@ The following aims to be a complete guide to installing Hugo on your Windows PC. {{< youtube G7umPCU-8xc >}} -### Assumptions +### Assumptions for Windows 1. You will use `C:\Hugo\Sites` as the starting point for your new project. 2. You will use `C:\Hugo\bin` to store executable files. @@ -468,11 +476,15 @@ Directory of C:\hugo\sites\example.com In any of the [Linux distributions that support snaps][snaps], you may install the "extended" Sass/SCSS version with this command: - snap install hugo --channel=extended +``` +snap install hugo --channel=extended +``` To install the non-extended version without Sass/SCSS support: - snap install hugo +``` +snap install hugo +``` To switch between the two, use either `snap refresh hugo --channel=extended` or `snap refresh hugo --channel=stable`. @@ -484,7 +496,9 @@ Hugo installed via Snap can write only inside the user’s `$HOME` directory---a [@anthonyfok](https://github.com/anthonyfok) and friends in the [Debian Go Packaging Team](https://go-team.pages.debian.net/) maintains an official hugo [Debian package](https://packages.debian.org/hugo) which is shared with [Ubuntu](https://packages.ubuntu.com/hugo) and is installable via `apt-get`: - sudo apt-get install hugo +``` +sudo apt-get install hugo +``` What this installs depends on your Debian/Ubuntu version. On Ubuntu bionic (18.04), this installs the non-extended version without Sass/SCSS support. On Ubuntu disco (19.04), this installs the extended version with Sass/SCSS support. @@ -502,7 +516,9 @@ sudo pacman -S hugo Fedora maintains an [official package for Hugo](https://packages.fedoraproject.org/pkgs/hugo/hugo) which may be installed with: - sudo dnf install hugo +``` +sudo dnf install hugo +``` For the latest version, the Hugo package maintained by [@daftaupe](https://github.com/daftaupe) at Fedora Copr is recommended: @@ -530,7 +546,9 @@ sudo eopkg install hugo OpenBSD provides a package for Hugo via `pkg_add`: - doas pkg_add hugo +``` +doas pkg_add hugo +``` ## Upgrade Hugo @@ -551,6 +569,7 @@ Now that you've installed Hugo, read the [Quick Start guide][quickstart] and exp [dep]: https://github.com/golang/dep [highlight shortcode]: /content-management/shortcodes/#highlight [installgit]: https://git-scm.com/ +[GCC]: http://www.mingw.org/ [installgo]: https://golang.org/dl/ [linuxbrew]: https://docs.brew.sh/Homebrew-on-Linux [quickstart]: /getting-started/quick-start/