Skip to content

Commit 408c6bc

Browse files
committed
[i18n] Display a page-may-be-outdated banner
Signed-off-by: Patrice Chalin <[email protected]>
1 parent baef949 commit 408c6bc

File tree

6 files changed

+56
-17
lines changed

6 files changed

+56
-17
lines changed

content/ja/docs/collector/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ cascade:
55
vers: 0.120.0
66
weight: 270
77
default_lang_commit: cd90ab77550fb2e92ca37cb3c753ec2d8bb7d8dc
8+
drifted_from_default: true
89
---
910

1011
![Jaeger、OTLP、Prometheusを統合したOpenTelemetryコレクターのダイアグラム](img/otel-collector.svg)

content/ja/docs/demo/architecture.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ linkTitle: アーキテクチャ
44
aliases: [current_architecture]
55
body_class: otel-mermaid-max-width
66
default_lang_commit: fd7da211d5bc37ca93112a494aaf6a94445e2e28
7+
drifted_from_default: true
78
---
89

910
**OpenTelemetryデモ** は、異なるプログラミング言語で書かれた複数のマイクロサービスから構成されており、gRPCとHTTPを使って相互に通信を行います。

content/ja/docs/demo/feature-flags.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ aliases:
55
- services/feature-flag
66
- services/featureflagservice
77
default_lang_commit: 24146bd1368e4c6082c7d6077efd29dba0d51055
8+
drifted_from_default: true
89
cSpell:ignore: loadgenerator OLJCESPC7Z
910
---
1011

layouts/docs/td-content-after-header.html

+51-15
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,66 @@
11
{{ $pageProseLang := partial "i18n/lang.html" . -}}
22
{{ $siteLang := .Site.Language -}}
33

4-
{{/*
4+
{{ if ne .Language.Lang "en" -}}
5+
{{ if .Params.drifted_from_default -}}
6+
{{ with partial "_inline/ot-page-drifted-banner.html" . -}}
7+
{{ . -}}
8+
{{ end -}}
9+
{{ else if ne $siteLang $pageProseLang -}}
10+
{{ with partial "_inline/ot-page-not-found-banner.html" . -}}
11+
<div class="pageinfo pageinfo-secondary">
12+
<div class="ps-4">
13+
{{ . }}
14+
</div>
15+
</div>
16+
{{ end -}}
17+
{{ else if false -}}
18+
{{ with partial "_inline/ot-page-drifted-banner.html" . -}}
19+
{{ . -}}
20+
{{ end -}}
21+
{{ end -}}
22+
{{ end -}}
523

6-
The disable_translation_not_found_msg param isn't currently used and I suspect
7-
that we won't need it, but I'll wait until the following feature is implemented
8-
before removing the code:
924

10-
https://github.com/open-telemetry/opentelemetry.io/issues/6340
25+
{{ define "partials/_inline/ot-page-drifted-banner.html" }}
26+
{{/* Assumption: .Params.drifted_from_default */ -}}
1127

12-
*/ -}}
28+
{{ $resultsArray := where .Translations "Lang" "en" -}}
29+
{{ $defaultLangPage := index $resultsArray 0 -}}
1330

14-
{{ if and
15-
(ne $siteLang $pageProseLang)
16-
(not (.Param "disable_translation_not_found_msg"))
17-
-}}
18-
{{ with partial "_inline/ot-page-not-found-banner.html" . -}}
1931
<div class="pageinfo pageinfo-secondary">
2032
<div class="ps-4">
21-
{{ . }}
33+
<p>
34+
<i class="fa-solid fa-triangle-exclamation" style="margin-left: -1.9rem; padding-right: 0.5rem;"></i>
35+
The content of this page may be <b>outdated</b> and some links may be invalid.
36+
37+
{{- if and $defaultLangPage .Params.default_lang_commit }}
38+
A <strong>newer version</strong> of this page exists in
39+
<a href="{{ $defaultLangPage.RelPermalink }}">English</a>.
40+
<details class="mt-2">
41+
<summary>More information ...</summary>
42+
<p>
43+
To see the changes to the English page since this page was last updated: visit
44+
{{ $compareUrl := printf "%s/compare/%s..%s"
45+
.Site.Params.github_repo .Params.default_lang_commit $defaultLangPage.GitInfo.Hash -}}
46+
<a href="{{ $compareUrl }}" class="external-link" target="_blank" rel="noopener">
47+
GitHub compare
48+
{{ substr .Params.default_lang_commit 0 8 }}..{{ $defaultLangPage.GitInfo.AbbreviatedHash -}}
49+
</a>
50+
and search for
51+
{{ $defLangPath := strings.TrimPrefix (add hugo.WorkingDir "/") $defaultLangPage.File.Filename -}}
52+
<code>{{ $defLangPath }}</code>.
53+
</p>
54+
</details>
55+
{{ else if not $defaultLangPage }}
56+
This page no longer has a corresponding English page.
57+
{{ end -}}
58+
</p>
2259
</div>
23-
</div>
24-
{{ end -}}
60+
</div>
2561
{{ end -}}
2662

63+
2764
{{ define "partials/_inline/ot-page-not-found-banner.html" }}
2865
{{ $path := "page-not-translated-msg.md" -}}
2966
{{ $args := (dict
@@ -37,4 +74,3 @@
3774
{{ warnf "_inline/ot-page-not-found-banner: '%s' not found from page %s (%s)" $path .Page.Path $lang -}}
3875
{{ end -}}
3976
{{ end -}}
40-

layouts/partials/i18n/fallback-page.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Returns the fallback page of this page, if it has one. A fallback page is a
44
page in the default site language that has been mounted under this locale as a
5-
fallback when this locale is missing a translation.
5+
fallback when this locale is missing a page translation.
66

77
*/ -}}
88

scripts/check-i18n.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function main() {
317317
if [[ ! -e "$EN_VERSION" ]]; then
318318
((FILE_PROCESSED_COUNT++))
319319
if [[ -z $FLAG_QUIET ]]; then
320-
echo -e "File not found:\t$EN_VERSION - $f - $DEFAULT_LANG was removed or renamed"
320+
echo -e "File not found:\t$f - $DEFAULT_LANG page was removed or renamed"
321321
fi
322322
set_file_drifted_status "$f" "file not found"
323323
continue

0 commit comments

Comments
 (0)