Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[i18n] Display page-outdated banner for non-en pages that have drifted #6475

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/ja/docs/collector/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cascade:
vers: 0.120.0
weight: 270
default_lang_commit: cd90ab77550fb2e92ca37cb3c753ec2d8bb7d8dc
drifted_from_default: true
---

![Jaeger、OTLP、Prometheusを統合したOpenTelemetryコレクターのダイアグラム](img/otel-collector.svg)
Expand Down
1 change: 1 addition & 0 deletions content/ja/docs/demo/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ linkTitle: アーキテクチャ
aliases: [current_architecture]
body_class: otel-mermaid-max-width
default_lang_commit: fd7da211d5bc37ca93112a494aaf6a94445e2e28
drifted_from_default: true
---

**OpenTelemetryデモ** は、異なるプログラミング言語で書かれた複数のマイクロサービスから構成されており、gRPCとHTTPを使って相互に通信を行います。
Expand Down
1 change: 1 addition & 0 deletions content/ja/docs/demo/feature-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ aliases:
- services/feature-flag
- services/featureflagservice
default_lang_commit: 24146bd1368e4c6082c7d6077efd29dba0d51055
drifted_from_default: true
cSpell:ignore: loadgenerator OLJCESPC7Z
---

Expand Down
66 changes: 51 additions & 15 deletions layouts/docs/td-content-after-header.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,66 @@
{{ $pageProseLang := partial "i18n/lang.html" . -}}
{{ $siteLang := .Site.Language -}}

{{/*
{{ if ne .Language.Lang "en" -}}
{{ if .Params.drifted_from_default -}}
{{ with partial "_inline/ot-page-drifted-banner.html" . -}}
{{ . -}}
{{ end -}}
{{ else if ne $siteLang $pageProseLang -}}
{{ with partial "_inline/ot-page-not-found-banner.html" . -}}
<div class="pageinfo pageinfo-secondary">
<div class="ps-4">
{{ . }}
</div>
</div>
{{ end -}}
{{ else if false -}}
{{ with partial "_inline/ot-page-drifted-banner.html" . -}}
{{ . -}}
{{ end -}}
{{ end -}}
{{ end -}}

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

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

*/ -}}
{{ $resultsArray := where .Translations "Lang" "en" -}}
{{ $defaultLangPage := index $resultsArray 0 -}}

{{ if and
(ne $siteLang $pageProseLang)
(not (.Param "disable_translation_not_found_msg"))
-}}
{{ with partial "_inline/ot-page-not-found-banner.html" . -}}
<div class="pageinfo pageinfo-secondary">
<div class="ps-4">
{{ . }}
<p>
<i class="fa-solid fa-triangle-exclamation" style="margin-left: -1.9rem; padding-right: 0.5rem;"></i>
The content of this page may be <b>outdated</b> and some links may be invalid.

{{- if and $defaultLangPage .Params.default_lang_commit }}
A <strong>newer version</strong> of this page exists in
<a href="{{ $defaultLangPage.RelPermalink }}">English</a>.
<details class="mt-2">
<summary>More information ...</summary>
<p>
To see the changes to the English page since this page was last updated: visit
{{ $compareUrl := printf "%s/compare/%s..%s"
.Site.Params.github_repo .Params.default_lang_commit $defaultLangPage.GitInfo.Hash -}}
<a href="{{ $compareUrl }}" class="external-link" target="_blank" rel="noopener" data-proofer-ignore>
GitHub compare
{{ substr .Params.default_lang_commit 0 8 }}..{{ $defaultLangPage.GitInfo.AbbreviatedHash -}}
</a>
and search for
{{ $defLangPath := strings.TrimPrefix (add hugo.WorkingDir "/") $defaultLangPage.File.Filename -}}
<code>{{ $defLangPath }}</code>.
</p>
</details>
{{ else if not $defaultLangPage }}
This page no longer has a corresponding English page.
{{ end -}}
</p>
</div>
</div>
{{ end -}}
</div>
{{ end -}}


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

2 changes: 1 addition & 1 deletion layouts/partials/i18n/fallback-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

*/ -}}

Expand Down
2 changes: 1 addition & 1 deletion scripts/check-i18n.sh
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function main() {
if [[ ! -e "$EN_VERSION" ]]; then
((FILE_PROCESSED_COUNT++))
if [[ -z $FLAG_QUIET ]]; then
echo -e "File not found:\t$EN_VERSION - $f - $DEFAULT_LANG was removed or renamed"
echo -e "File not found:\t$f - $DEFAULT_LANG page was removed or renamed"
fi
set_file_drifted_status "$f" "file not found"
continue
Expand Down