Skip to content

Commit 7811e85

Browse files
authored
[i18n] Support localization of page-not-translated banner (#6339)
1 parent fd873ed commit 7811e85

File tree

13 files changed

+127
-38
lines changed

13 files changed

+127
-38
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: # Bogus entry for markdownlint
3+
_build: { list: never, render: never }
4+
---
5+
6+
<i class="fa-solid fa-circle-info" style="margin-left: -1.5rem"></i> You are
7+
viewing the **English version** of this page because it has not yet been
8+
translated. Interested in helping out? See [Contributing](/docs/contributing/).

content/en/docs/demo/_index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: OpenTelemetry Demo Documentation
2+
title: OpenTelemetry Demo Docs
33
linkTitle: Demo
44
cascade:
55
repo: https://github.com/open-telemetry/opentelemetry-demo

content/en/docs/languages/js/_index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ weight: 20
1010

1111
{{% docs/languages/index-intro js /%}}
1212

13-
{{% include browser-instrumentation-warning.md %}}
13+
{{% include "./_browser-instrumentation-warning.md" %}}
1414

1515
## Version Support
1616

content/en/docs/languages/js/getting-started/browser.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to add OpenTelemetry to your browser app
55
weight: 20
66
---
77

8-
{{% include browser-instrumentation-warning.md %}}
8+
{{% include "./_browser-instrumentation-warning.md" %}}
99

1010
While this guide uses the example application presented below, the steps to
1111
instrument your own application should be similar.

content/en/docs/languages/js/instrumentation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ above, you have a `TracerProvider` setup for you already. You can continue with
335335

336336
#### Browser
337337

338-
{{% include browser-instrumentation-warning.md %}}
338+
{{% include "./_browser-instrumentation-warning.md" %}}
339339

340340
First, ensure you've got the right packages:
341341

content/ja/announcements/_index.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
title: お知らせ
33
cascade:
44
type: docs
5+
params:
6+
hide_feedback: true
57
default_lang_commit: 48eac183a4dd74946d5a45fa436cfc6052f30532
68
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: # Bogus entry for markdownlint
3+
_build: { list: never, render: never }
4+
default_lang_commit: 8d115a9df96c52dbbb3f96c05a843390d90a9800
5+
---
6+
7+
<i class="fa-solid fa-circle-info" style="margin-left: -1.5rem"></i> Você está
8+
visualizando a versão em **versão em inglês** desta página porque ela ainda não
9+
foi traduzida. Possui interesse em ajudar? Veja
10+
[como contribuir](/docs/contributing/).

content/pt/docs/languages/js/getting-started/browser.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ weight: 20
66
default_lang_commit: 7cb1bd39726fc03698164ee17fe9087afdac054c
77
---
88

9-
{{% include browser-instrumentation-warning.md %}}
9+
{{% include "./_browser-instrumentation-warning.md" %}}
1010

1111
Embora este guia utilize o exemplo de aplicação apresentada abaixo, as etapas
1212
para instrumentar a sua própria aplicação devem ser similares.

hugo.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ module:
321321
target: content
322322
lang: es
323323
# fallback pages
324+
- source: content/en/_includes
325+
target: content/_includes
326+
lang: es
324327
- source: content/en/announcements
325328
target: content/announcements
326329
lang: es
@@ -334,19 +337,28 @@ module:
334337
target: content
335338
lang: fr
336339
# fallback pages
340+
- source: content/en/_includes
341+
target: content/_includes
342+
lang: fr
337343
- source: content/en/announcements
338344
target: content/announcements
339345
lang: fr
340346
- excludeFiles: specs/*
341347
source: content/en/docs
342348
target: content/docs
343349
lang: fr
350+
# - source: content/en/ecosystem
351+
# target: content/ecosystem
352+
# lang: fr
344353

345354
## ja
346355
- source: content/ja
347356
target: content
348357
lang: ja
349358
# fallback pages
359+
- source: content/en/_includes
360+
target: content/_includes
361+
lang: ja
350362
- source: content/en/announcements
351363
target: content/announcements
352364
lang: ja
@@ -360,6 +372,9 @@ module:
360372
target: content
361373
lang: zh
362374
# fallback pages
375+
- source: content/en/_includes
376+
target: content/_includes
377+
lang: zh
363378
- source: content/en/announcements
364379
target: content/announcements
365380
lang: zh
@@ -373,6 +388,9 @@ module:
373388
target: content
374389
lang: pt
375390
# fallback pages
391+
- source: content/en/_includes
392+
target: content/_includes
393+
lang: pt
376394
- source: content/en/announcements
377395
target: content/announcements
378396
lang: pt
+37-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,40 @@
11
{{ $pageProseLang := partial "i18n/lang.html" . -}}
22
{{ $siteLang := .Site.Language -}}
33

4-
{{ if ne $siteLang $pageProseLang -}}
5-
6-
<div class="pageinfo pageinfo-secondary">
7-
<p class="ps-4">
8-
<i class="fa-solid fa-circle-info" style="margin-left: -1.5rem"></i>
9-
You are viewing the <strong>English version</strong> of this page because it
10-
has not yet been translated. Interested in helping out? See
11-
<a href="/docs/contributing/">Contributing</a>.
12-
</p>
13-
</div>
14-
15-
{{- end -}}
4+
{{/*
5+
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:
9+
10+
https://github.com/open-telemetry/opentelemetry.io/issues/6340
11+
12+
*/ -}}
13+
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" . -}}
19+
<div class="pageinfo pageinfo-secondary">
20+
<div class="ps-4">
21+
{{ . }}
22+
</div>
23+
</div>
24+
{{ end -}}
25+
{{ end -}}
26+
27+
{{ define "partials/_inline/ot-page-not-found-banner.html" }}
28+
{{ $path := "page-not-translated-msg.md" -}}
29+
{{ $args := (dict
30+
"path" $path
31+
"page" .Page) -}}
32+
{{ $page := partial "func/find-include.html" $args -}}
33+
{{ with $page -}}
34+
{{ .Content }}
35+
{{ else -}}
36+
{{ $lang := .Page.Language.Lang -}}
37+
{{ warnf "_inline/ot-page-not-found-banner: '%s' not found from page %s (%s)" $path .Page.Path $lang -}}
38+
{{ end -}}
39+
{{ end -}}
40+
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{/*
2+
Args: .path .page
3+
4+
Looks for the page specified by .path, starting from .page, moving up the
5+
.Parent relation if necessary. If .path isn't explicitly absolute or relative,
6+
"_includes/" is prepended to it.
7+
8+
*/ -}}
9+
10+
{{ $path := .path -}}
11+
{{ if not (or
12+
(strings.HasPrefix $path "/" )
13+
(strings.HasPrefix $path "."))
14+
-}}
15+
{{ $path = printf "_includes/%s" $path -}}
16+
{{ end -}}
17+
18+
{{ $result := partial "func/_find-include.html" (dict "path" $path "page" .page) -}}
19+
{{ return $result -}}
20+
21+
{{ define "partials/func/_find-include.html" -}}
22+
{{ $result := "" -}}
23+
{{ $page_to_include := .page.GetPage .path -}}
24+
25+
{{ with $page_to_include -}}
26+
{{ $result = . }}
27+
{{ else -}}
28+
{{ $parent := .page.Parent -}}
29+
{{ if $parent -}}
30+
{{ $result = partial "func/_find-include.html" (dict "path" .path "page" $parent) -}}
31+
{{end -}}
32+
{{ end -}}
33+
34+
{{ return $result -}}
35+
{{ end -}}

layouts/shortcodes/include.md

+12-21
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,17 @@
22
calls to shortcodes. */ -}}
33

44
{{ $path := .Get 0 -}}
5-
{{ if not (or
6-
(strings.HasPrefix $path "/" )
7-
(strings.HasPrefix $path "."))
8-
-}}
9-
{{ $path = printf "_includes/%s" $path -}}
10-
{{ end -}}
11-
12-
{{ template "getPage" (dict "ctx" . "path" $path "page" .Page) -}}
5+
{{ $page := partial "func/find-include.html" (dict "path" $path "page" .Page) -}}
6+
{{ with $page -}}
7+
{{ .Content -}}
8+
{{ else -}}
9+
{{ $msg := printf
10+
"Can't include '%s': file not found in page or ancestor contexts of page %s."
11+
$path .Page.Path -}}
12+
{{ warnf $msg -}}
1313

14-
{{ define "getPage" -}}
15-
{{ $page_to_include := .page.GetPage .path -}}
16-
{{ with $page_to_include -}}
17-
{{ .Content -}}
18-
{{ else -}}
19-
{{ $parent := .page.Parent -}}
20-
{{ if $parent -}}
21-
{{ template "getPage" (dict "ctx" .ctx "path" .path "page" $parent) -}}
22-
{{ else -}}
23-
{{ warnf "File not found: %s in page: %s" .path .ctx.Page.Path -}}
24-
**ERROR**: File not found: {{ .path }}.
25-
{{end -}}
26-
{{ end -}}
14+
<div class="alert alert-warning">
15+
<div class="h4 alert-heading">INTERNAL SITE ERROR</div>
16+
{{ $msg }}
17+
</div>
2718
{{ end -}}

0 commit comments

Comments
 (0)