Skip to content

Commit 8603bc8

Browse files
authored
[i18n] Support automatic banner management across localizations (#4625)
1 parent 788509e commit 8603bc8

File tree

18 files changed

+156
-37
lines changed

18 files changed

+156
-37
lines changed

.github/workflows/check-i18n.yml

+2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0 # all
1214
- run: scripts/i18n-check.sh -u
1315
- run: .github/workflows/scripts/i18n-check-helper.sh

archetypes/announcement.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: {{ replaceRE "[-_]" " " .Name | title }}
3+
date: {{ .Date | time.Format "2006-01-02" }} # Start date (optional)
4+
expiryDate: {{ dateFormat "2006-01-02" .Date }} # End date (optional)
5+
---
6+
7+
<!-- For more detail about announcements, see
8+
https://opentelemetry.io/docs/contributing/#announcement-management
9+
10+
Erase this comment once you are done including the announcement text below. -->

content/en/_index.md

-12
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ developer_note:
1010
The blocks/cover shortcode (used below) will use as a background image any
1111
image file containing "background" in its name.
1212
show_banner: true
13-
limit_banner: 2 # Default to 2, adjust as needed
14-
banners:
15-
- message:
16-
'<i class="fas fa-bullhorn"></i> We are happy to announce that Elastic''s
17-
donation of the [**eBPF profiling agent has been
18-
accepted**](/blog/2024/elastic-contributes-continuous-profiling-agent)!'
19-
to: 2024-07-25
20-
- message:
21-
'<i class="fas fa-bullhorn"></i> Join us for [**OTel Community Day** on
22-
June
23-
25th](https://events.linuxfoundation.org/open-telemetry-community-day/)!'
24-
to: 2024-06-25
2513
---
2614

2715
<div class="d-none"><a rel="me" href="https://fosstodon.org/@opentelemetry"></a></div>

content/en/announcements/_index.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Announcements
3+
cascade:
4+
type: docs
5+
---

content/en/announcements/eBPF.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: eBPF
3+
date: 2024-06-07
4+
expiryDate: 2024-07-25
5+
---
6+
7+
Elastic's **eBPF profiling agent** is now part of OTel.
8+
[Learn more](/blog/2024/elastic-contributes-continuous-profiling-agent)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: OTel Community Day
3+
date: 2024-04-05
4+
expiryDate: 2024-06-25
5+
weight: -1 # top
6+
---
7+
8+
<i class="fas fa-bullhorn"></i> Join us for
9+
[**OTel Community Day**](https://events.linuxfoundation.org/open-telemetry-community-day/)
10+
on June 25th

content/en/docs/contributing/_index.md

+47
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,53 @@ Keep the following in mind when filing an issue:
600600
Respect your fellow contributors. For example, "The docs are terrible" is not
601601
helpful or polite feedback.
602602

603+
## Announcement management
604+
605+
An announcement is a _regular Hugo page_ contained under the `announcements`
606+
section of a locale. This means that we leverage Hugo's builtin handling of page
607+
dates (future or expired), internationalization, and more, to automatically show
608+
or hide banners depending on the build date, determine banner ordering, handle
609+
fall back to English banners, etc.
610+
611+
> Announcements are currently used as banners only. We _might_ eventually
612+
> support slightly more general announcements as well.
613+
614+
### Creating an announcement
615+
616+
To add a new announcement, create an announcement markdown file under the
617+
`announcements` folder of your localization using the following command:
618+
619+
```sh
620+
hugo new --kind announcement content/YOUR-LOCALE/announcements/announcement-file-name.md
621+
```
622+
623+
Adjust according to your desired locale and file name. Add the announcement text
624+
as the body of the page.
625+
626+
> For banners, the announcement body should be a short phrase.
627+
628+
{{% alert title="For localizations" %}}
629+
630+
If you are creating a **locale specific announcement override**, make sure that
631+
you use the **same filename** as the English language announcement.
632+
633+
{{% /alert %}}
634+
635+
### Announcement list
636+
637+
Any given announcement will appear in a site build when the build date falls
638+
between the `date` and `expiryDate` fields of the announcement. When those
639+
fields are missing they are assumed to be "now" and "forever", respectively.
640+
641+
Announcements will appear in the standard page order as determined using Hugo's
642+
[Regular pages](https://gohugo.io/methods/site/regularpages/) function. That is,
643+
the "lightest" announcements (by `weight`) will appear first; when weights are
644+
the same or unspecified, the most recent announcements (by `date`) will appear
645+
first, etc.
646+
647+
So, if you want to force an announcement to the top, use a negative `weight` in
648+
the front matter.
649+
603650
## Contribute to other repositories
604651

605652
OpenTelemetry is an open source project, and we gladly accept new contributions

content/ja/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ description: >-
44
効果的な観測を可能にする、高品質でユビキタスかつポータブルなテレメトリー
55
developer_note:
66
blocks/coverコラム(以下で使用)は、ファイル名に "background" を含む画像ファイルを背景画像として使用します。
7+
show_banner: true
78
default_lang_commit: 902043db
89
---
910

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: OTel Community Day
3+
date: 2024-04-05
4+
expiryDate: 2024-06-25
5+
weight: -1 # top
6+
default_lang_commit: 788509efd404ba35dd113b4f37bae96ca7558e3e
7+
---
8+
9+
<i class="fas fa-bullhorn"></i>
10+
6月25日に開催される
11+
[**OTel コミュニティデー**](https://events.linuxfoundation.org/open-telemetry-community-day/)
12+
にご参加ください

content/zh/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ show_banner: true
66
developer_note:
77
下文所用的 blocks/cover 短代码将使用文件名中包含 "background"
88
的图像文件作为背景图。
9+
show_banner: true
910
default_lang_commit: 6e35a949
1011
---
1112

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: OTel Community Day
3+
date: 2024-04-05
4+
expiryDate: 2024-06-25
5+
weight: -1 # top
6+
default_lang_commit: 788509efd404ba35dd113b4f37bae96ca7558e3e
7+
---
8+
9+
<i class="fas fa-bullhorn"></i>
10+
加入我们,参加
11+
[**OTel 社区日**](https://events.linuxfoundation.org/open-telemetry-community-day/)
12+
6月25日

hugo.yaml

+19-1
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,34 @@ module:
212212
mounts:
213213
- source: content/en
214214
target: content
215+
216+
## ja
215217
- source: content/ja
216218
target: content
217219
lang: ja
220+
# fallback pages
221+
# - excludeFiles: specs/*
222+
# source: content/en/docs
223+
# target: content/docs
224+
# lang: ja
225+
- source: content/en/announcements
226+
target: content/announcements
227+
lang: ja
228+
229+
## zh
218230
- source: content/zh
219231
target: content
220232
lang: zh
233+
# fallback pages
221234
- excludeFiles: specs/*
222-
source: content/en/docs # zh missing-page fallback
235+
source: content/en/docs
223236
target: content/docs
224237
lang: zh
238+
- source: content/en/announcements
239+
target: content/announcements
240+
lang: zh
241+
242+
# Other site content
225243
- source: tmp/otel/specification
226244
target: content/docs/specs/otel
227245
- source: tmp/opamp

layouts/_default/baseof.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{ partial "navbar.html" . }}
1111
</header>
1212
<div class="container-fluid td-default td-outer">
13-
{{- partial "banner.md" . | .RenderString }}
13+
{{- partial "banner.html" . }}
1414
<main role="main" class="td-main">
1515
{{ block "main" . }}{{ end }}
1616
</main>

layouts/partials/banner.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{ if .Params.show_banner -}}
2+
{{ $announcements := site.GetPage "announcements" -}}
3+
{{ if $announcements -}}
4+
<div class="o-banner">
5+
{{ range $announcements.RegularPages }}
6+
<div>{{ .Content }}</div>
7+
{{ end -}}
8+
</div>
9+
{{ end -}}
10+
{{ end -}}

layouts/partials/banner.md

-20
This file was deleted.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
],
66
"scripts": {
77
"__check:links": "make --keep-going check-links",
8-
"_build": "npm run _hugo -- -e dev -DFE --baseURL \"${DEPLOY_PRIME_URL:-http://localhost}\"",
8+
"_build": "npm run _hugo -- -e dev --buildDrafts --baseURL \"${DEPLOY_PRIME_URL:-http://localhost}\"",
99
"_check:format:any": "npx prettier --check --ignore-path ''",
1010
"_check:format": "npx prettier --check .",
1111
"_check:links--md": "npx markdown-link-check --config .markdown-link-check.json *.md",
@@ -28,7 +28,7 @@
2828
"_prepare:docsy": "cd themes/docsy && npm install",
2929
"_prettier:any": "npx prettier --ignore-path ''",
3030
"_rename-to-kebab-case": "find assets content static -name '*_*' ! -name '_*' -exec sh -c 'mv \"$1\" \"${1//_/-}\"' _ {} \\;",
31-
"_serve:hugo": "hugo server -DFE --minify",
31+
"_serve:hugo": "hugo server --buildDrafts --minify",
3232
"_serve:netlify": "netlify dev -c \"npm run _serve:hugo -- --renderToMemory\"",
3333
"_sync": "./scripts/sync-submodules.pl",
3434
"all": "bash -c 'x=0; for c in \"$@\"; do npm run $c || x=$((x+1)); done; ((!x)) || (echo \"ERROR: some scripts failed!\" && exit 1)' -",

scripts/i18n-check.sh

+12-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ function main() {
106106
# if [[ -n $FLAG_VERBOSE ]]; then echo -e "All targets: $TARGETS"; fi
107107
fi
108108

109+
# set -x
110+
# git branch -vv
111+
109112
SYNCED=1
110113
for f in $TARGETS; do
111114
# if [[ -n $FLAG_VERBOSE ]]; then echo -e "Checking\t$f"; fi
@@ -120,6 +123,14 @@ function main() {
120123
if [[ -z $LASTCOMMIT ]]; then
121124
# Get last commit of `main` that this branch is rooted from.
122125
LASTCOMMIT=$(git merge-base main HEAD)
126+
# elif ! git branch --contains $LASTCOMMIT | grep -q "^\s*main\b"; then # HERE
127+
# # Get last commit of `main` that this branch is rooted from.
128+
# LASTCOMMIT=$(git merge-base main HEAD)
129+
# fi
130+
131+
# if ! (git branch --contains $LASTCOMMIT | grep -q "^\s*main\b"); then
132+
# echo "Something is wrong, the hash is empty or isn't on 'main', aborting: $LASTCOMMIT - $f"
133+
# exit 2
123134
fi
124135

125136
if [[ -n $FLAG_UPDATE ]]; then
@@ -145,7 +156,7 @@ function main() {
145156
fi
146157
done
147158
if [ $SYNCED -ne 1 ]; then
148-
exit 1
159+
exit
149160
fi
150161

151162
echo "$TARGET_PATHS is still in sync"

static/refcache.json

+4
Original file line numberDiff line numberDiff line change
@@ -4811,6 +4811,10 @@
48114811
"StatusCode": 206,
48124812
"LastSeen": "2024-06-06T14:51:47.628909-04:00"
48134813
},
4814+
"https://gohugo.io/methods/site/regularpages/": {
4815+
"StatusCode": 206,
4816+
"LastSeen": "2024-06-07T12:38:33.735717-04:00"
4817+
},
48144818
"https://golang.org/ref/spec#Slice_types": {
48154819
"StatusCode": 200,
48164820
"LastSeen": "2024-01-18T19:02:17.04578-05:00"

0 commit comments

Comments
 (0)