Skip to content

Commit

Permalink
Merge commit '90ad8045056167004d27857a95542936657b8a16'
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Sep 13, 2022
2 parents ab5ce59 + 90ad804 commit af23cdc
Show file tree
Hide file tree
Showing 45 changed files with 366 additions and 156 deletions.
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.idea
/.vscode
/public
/dist
node_modules
nohup.out
.DS_Store
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# github.com/gohugoio/gohugoioTheme v0.0.0-20220228085601-7cfbda06d135
# github.com/gohugoio/gohugoioTheme v0.0.0-20220912070954-88dcaf003b4d
3 changes: 1 addition & 2 deletions docs/content/en/content-management/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ linktitle: Comments
description: Hugo ships with an internal Disqus template, but this isn't the only commenting system that will work with your new Hugo website.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-03-09
keywords: [sections,content,organization]
categories: [project organization, fundamentals]
menu:
Expand Down Expand Up @@ -60,7 +59,7 @@ These are some alternatives to Disqus:
* [Muut](https://muut.com/)
* [Remark42](https://remark42.com/) (Open source, Golang, Easy to run docker)
* [Staticman](https://staticman.net/)
* [Talkyard](https://www.talkyard.io/blog-comments) (Open source, & serverless hosting)
* [Talkyard](https://blog-comments.talkyard.io/) (Open source, & serverless hosting)
* [Utterances](https://utteranc.es/) (Open source, GitHub comments widget built on GitHub issues)

[configuration]: /getting-started/configuration/
Expand Down
6 changes: 5 additions & 1 deletion docs/content/en/content-management/image-processing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ content/
└── sunset.jpg <-- page resource
```

To access an image as a page resource:
## The Image Resource

The `image` resource gives you access to image-specific attributes like the picture's `Width` and `Height`, as well as powerful processing methods and filters. More on that below.

Note that the `image` resource can also be retrieved from a [global resource]({{< relref "/hugo-pipes/introduction#from-file-to-resource" >}})

```go-html-template
{{ $image := .Resources.GetMatch "sunset.jpg" }}
Expand Down
49 changes: 44 additions & 5 deletions docs/content/en/content-management/multilingual.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ linktitle: Multilingual
description: Hugo supports the creation of websites with multiple languages side by side.
date: 2017-01-10
publishdate: 2017-01-10
lastmod: 2017-01-10
categories: [content management]
keywords: [multilingual,i18n, internationalization]
menu:
Expand Down Expand Up @@ -335,21 +334,21 @@ 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.

This comment has been minimized.

Copy link
@snicolai

snicolai Sep 14, 2022

This should be order not other. (the change should be reverted)


```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]
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
Expand All @@ -361,7 +360,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 requirement)

```go-html-template
{{ i18n "readingTime" (dict "Count" 25 "FirstArgument" true "SecondArgument" false "Etc" "so on, so far") }}
Expand Down Expand Up @@ -507,6 +506,40 @@ The rendering of the main navigation works as usual. `.Site.Menus` will just con
</ul>
```

### Dynamically localizing menus with i18n
While customizing menus per language is useful, your config file can become hard to maintain if you have a lot of languages

If your menus are the same in all languages (ie. if the only thing that changes is the translated name) you can use the `.Identifier` as a translation key for the menu name:

{{< code-toggle file="config" >}}
[[menu.main]]
name = "About me"
url = "about"
weight = 1
identifier = "about"
{{< /code-toggle >}}

You now need to specify the translations for the menu keys in the i18n files:

{{< code file="i18n/pt.toml" >}}
[about]
other="Sobre mim"
{{< /code >}}

And do the appropriate changes in the menu code to use the `i18n` tag with the `.Identifier` as a key. You will also note that here we are using a `default` to fall back to `.Name`, in case the `.Identifier` key is also not present in the language specified in the `defaultContentLanguage` configuration.

{{< code file="layouts/partials/menu.html" >}}
<ul>
{{- $currentPage := . -}}
{{ range .Site.Menus.main -}}
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
<a href="{{ .URL | absLangURL }}">{{ i18n .Identifier | default .Name}}</a>
</li>
{{- end }}
</ul>
{{< /code >}}


## Missing Translations

If a string does not have a translation for the current language, Hugo will use the value from the default language. If no default value is set, an empty string will be shown.
Expand Down Expand Up @@ -535,6 +568,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/
Expand Down
19 changes: 10 additions & 9 deletions docs/content/en/content-management/page-bundles.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,27 @@ content/
In the above example `content/` directory, there are four leaf
bundles:

about
`about`
: This leaf bundle is at the root level (directly under
`content` directory) and has only the `index.md`.

my-post
`my-post`
: This leaf bundle has the `index.md`, two other content
Markdown files and two image files.

image1
: This image is a page resource of `my-post`
- image1, image2:
These images are page resources of `my-post`
and only available in `my-post/index.md` resources.

image2
: This image is a page resource of `my-post`
and only available in `my-post/index.md` resources.
- content1, content2:
These content files are page resources of `my-post`
and only available in `my-post/index.md` resources.
They will **not** be rendered as individual pages.

my-other-post
`my-other-post`
: This leaf bundle has only the `index.md`.

another-leaf-bundle
`another-leaf-bundle`
: This leaf bundle is nested under couple of
directories. This bundle also has only the `index.md`.

Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/content-management/page-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ name
: Sets the value returned in `Name`.

{{% warning %}}
The methods `Match` and `GetMatch` use `Name` to match the resources.
The methods `Match`, `Get` and `GetMatch` use `Name` to match the resources.
{{%/ warning %}}

title
Expand Down
Loading

0 comments on commit af23cdc

Please sign in to comment.