Skip to content

Commit 6001585

Browse files
authored
[i18n] Update localization guidance (#6408)
1 parent 3bd2c26 commit 6001585

File tree

2 files changed

+97
-57
lines changed

2 files changed

+97
-57
lines changed

content/en/docs/contributing/localization.md

+85-57
Original file line numberDiff line numberDiff line change
@@ -11,90 +11,89 @@ localizations. English is the default language, with US English as the default
1111
(implicit) localization. A growing number of other localizations are supported,
1212
as can be seen from the languages dropdown menu in the top nav.
1313

14-
## English language maintainer guidance
14+
## Translation guidance
1515

16-
### When link checking fails for non-English pages
16+
When translating website pages from English, we recommend that you follow the
17+
guidance offered in this section.
1718

18-
English is the default language of the OpenTelemetry website. After you add,
19-
edit, or reorganized English language documentation, link checking may fail for
20-
non-English pages. When this happens:
19+
### Summary / TL;DR {#summary}
2120

22-
<!-- markdownlint-disable blanks-around-fences -->
21+
Do translate:
2322

24-
- Do **not** fix the broken links. Each non-English page is associated with a
25-
specific commit of the corresponding English page, as identified by the git
26-
commit hash value of the `default_lang_commit` front matter key.
27-
- Configure the link checker to ignore the non-English pages by adding the
28-
following to the page's front matter, or to the closest common ancestor file,
29-
when more than one page has link errors:
30-
```yaml
31-
htmltest:
32-
# TODO: remove the IgnoreDirs once broken links are fixed
33-
IgnoreDirs:
34-
- path-regex/to/non-en/directory/contain/files/to/ignore
35-
- path-2-etc
36-
```
37-
- Run `npm run check:links` and include any updates to the `.htmltest.yml`
38-
config file with your PR.
23+
- [Front matter][] fields `title`, `linkTitle`, and `description`
24+
- Page content, including the text fields in Mermaid [diagrams](#images)
3925

40-
<!-- markdownlint-enable blanks-around-fences -->
26+
Do **NOT**:
4127

42-
## Translation guidance
28+
- Translate:
29+
- **File or directory** names of resources in this repository
30+
- [Links](#links), this includes [heading IDs](#headings).[^*]
31+
- [Front matter][] fields other than those listed in the "Do" section above.
32+
In particular, do not translate `aliases`. When in doubt, ask maintainers.
33+
- Create **copies of images**, unless you [localize text in the images](#images)
4334

44-
We recommend that you follow the guidance offered in this section when
45-
translating pages.
35+
[^*]: For a possible exception, see [Links](#links).
4636

47-
### Heading anchors
37+
### Heading IDs {#headings}
4838

4939
To ensure that heading anchor targets are uniform across localizations, when
5040
translating headings:
5141

52-
- Preserve the heading's explicit ID if it has one. [Heading ID syntax] is
42+
- Preserve the heading's explicit ID if it has one. [Heading ID syntax][] is
5343
written after the heading text using syntax like `{ #some-id }`.
5444
- Otherwise, explicitly declare a heading ID corresponding to the autogenerated
5545
ID of the original English heading.
5646

57-
{{% alert title="Note" %}}
58-
59-
We leave it to the discretion of localization authors to decide if they add an
60-
explicit heading ID to all headings of translated pages, or whether this is only
61-
done for known intra-site heading targets, as reported by the link checker. The
62-
former option is more uniform and more work. It better supports having
63-
site-external targets into localization pages and avoids having to revisit
64-
previously translated pages as new heading targets are used.
65-
66-
{{% /alert %}}
67-
6847
[Heading ID syntax]:
6948
https://github.com/yuin/goldmark/blob/master/README.md#headings
7049

71-
### Links
50+
### Links {#links}
7251

73-
For link references to local paths (as opposed to external links), preserve the
74-
path _as is_. This holds true for links to website pages or section-local
75-
resources such as images.
52+
Do **not** translate link references. This holds true for external links, and
53+
paths to website pages and section-local resources such as [images](#images).
54+
55+
The only exception is for links to external pages (such as
56+
<https://en.wikipedia.org>) that have a version specific to your local. Often
57+
this means replacing the `en` in the URL by your locale's language code.
7658

7759
{{% alert title="Note" %}}
7860

7961
The OTel website repository has a custom render-link hook that Hugo uses to
80-
convert **absolute link paths to documentation pages**. Links of the form
81-
`/docs/some-page` are made locale specific by prefixing the path with the page
82-
language code when rendering the link. For example, the previous sample path
83-
would become `/ja/docs/some-page` when rendered from a Japanese page.
62+
convert absolute link paths referring to documentation pages. **Links of the
63+
form `/docs/some-page` are made locale specific** by prefixing the path with the
64+
page language code when rendering the link. For example, the previous sample
65+
path would become `/ja/docs/some-page` when rendered from a Japanese page.
8466

8567
{{% /alert %}}
8668

87-
### Images
69+
### Images and diagrams {#images}
70+
71+
Do **not** make copies of image files unless you localize text in the image
72+
itself[^shared-images].
8873

89-
Hugo is smart in the way that it renders page images that are shared across site
90-
localizations. That is, in the generated site folder, Hugo will output a
91-
_single_ image file that is then shared across localizations.
74+
**Do** translate text in [Mermaid][] diagrams.
9275

93-
So as a general rule, _do not_ make copies of image files in your localization
94-
unless you actually change the image.
76+
[^shared-images]:
77+
Hugo is smart about the way that it renders image files that are shared
78+
across site localizations. That is, Hugo will output a _single_ image file
79+
and share it across locales.
80+
81+
[Mermaid]: https://mermaid.js.org
82+
83+
### Include files {#includes}
84+
85+
**Do** translate page fragments found under `_includes` directories just as you
86+
would translate any other page content.
9587

9688
### Shortcodes
9789

90+
{{% alert title="Note" %}}
91+
92+
As of February 2025, we are in the process of migrating from shortcodes to
93+
[include files](#includes) as a means of supporting shared-page content.
94+
95+
{{% /alert %}}
96+
9897
Some of the base shortcodes contain English text that you might need to localize
9998
-- this is particularly true of those contained in [layouts/shortcodes/docs].
10099

@@ -123,14 +122,14 @@ follows:
123122
```markdown
124123
---
125124
title: Your localized page title
126-
...
127-
128-
default_lang_commit: <commit-hash-of-main-for-default-language-page>
125+
# ...
126+
default_lang_commit: <most-recent-commit-hash-of-default-language-page>
127+
---
129128
```
130129

131130
The front matter above would be in `content/zh/<some-path>/page.md`. The commit
132-
would correspond to the latest commit of `content/en/<some-path>/page.md` in
133-
`main`.
131+
hash would correspond to the latest commit of `content/en/<some-path>/page.md`
132+
from the `main` branch.
134133

135134
### Tracking changes to English pages
136135

@@ -285,6 +284,35 @@ if you are an approver already.
285284

286285
{{% /alert %}}
287286

287+
## English-language maintainer guidance
288+
289+
### When link checking fails for non-English pages
290+
291+
English is the default language of the OpenTelemetry website. After you add,
292+
edit, or reorganized English language documentation, link checking may fail for
293+
non-English pages. When this happens:
294+
295+
<!-- markdownlint-disable blanks-around-fences -->
296+
297+
- Do **not** fix the broken links. Each non-English page is associated with a
298+
specific commit of the corresponding English page, as identified by the git
299+
commit hash value of the `default_lang_commit` front matter key.
300+
- Configure the link checker to ignore the non-English pages by adding the
301+
following to the page's front matter, or to the closest common ancestor file,
302+
when more than one page has link errors:
303+
```yaml
304+
htmltest:
305+
# TODO: remove the IgnoreDirs once broken links are fixed
306+
IgnoreDirs:
307+
- path-regex/to/non-en/directory/contain/files/to/ignore
308+
- path-2-etc
309+
```
310+
- Run `npm run check:links` and include any updates to the `.htmltest.yml`
311+
config file with your PR.
312+
313+
<!-- markdownlint-enable blanks-around-fences -->
314+
315+
[front matter]: https://gohugo.io/content-management/front-matter/
288316
[main]: https://github.com/open-telemetry/opentelemetry.io/commits/main/
289317
[multilingual framework]: https://gohugo.io/content-management/multilingual/
290318
[PR #5386]: https://github.com/open-telemetry/opentelemetry.io/pull/5386/files

static/refcache.json

+12
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,10 @@
18551855
"StatusCode": 200,
18561856
"LastSeen": "2025-01-06T11:23:51.473219-05:00"
18571857
},
1858+
"https://en.wikipedia.org": {
1859+
"StatusCode": 200,
1860+
"LastSeen": "2025-02-24T13:42:37.248355-05:00"
1861+
},
18581862
"https://en.wikipedia.org/wiki/0.0.0.0": {
18591863
"StatusCode": 200,
18601864
"LastSeen": "2025-02-01T07:12:46.109395-05:00"
@@ -12939,6 +12943,10 @@
1293912943
"StatusCode": 206,
1294012944
"LastSeen": "2025-02-01T07:12:15.787072-05:00"
1294112945
},
12946+
"https://gohugo.io/content-management/front-matter/": {
12947+
"StatusCode": 206,
12948+
"LastSeen": "2025-02-24T13:42:35.288155-05:00"
12949+
},
1294212950
"https://gohugo.io/content-management/multilingual/": {
1294312951
"StatusCode": 206,
1294412952
"LastSeen": "2025-02-01T07:09:55.106757-05:00"
@@ -13891,6 +13899,10 @@
1389113899
"StatusCode": 206,
1389213900
"LastSeen": "2025-01-24T14:37:12.587459-05:00"
1389313901
},
13902+
"https://mermaid.js.org": {
13903+
"StatusCode": 206,
13904+
"LastSeen": "2025-02-24T13:42:37.730493-05:00"
13905+
},
1389413906
"https://metricshub.com": {
1389513907
"StatusCode": 200,
1389613908
"LastSeen": "2024-10-07T14:48:00.172830893Z"

0 commit comments

Comments
 (0)