Skip to content

Commit a37e423

Browse files
authored
Add i18n guidance re. images & shortcodes + some rework (#4790)
1 parent 2c7cc75 commit a37e423

File tree

1 file changed

+60
-22
lines changed

1 file changed

+60
-22
lines changed

content/en/docs/contributing/localization.md

+60-22
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,83 @@
11
---
22
title: Site localization
3-
description:
4-
Guidance on creating and maintaining site page in non-English localizations.
3+
description: Creating and maintaining site pages in non-English localizations.
54
linkTitle: Localization
65
weight: 25
6+
cSpell:ignore: shortcodes
77
---
88

9-
{{% pageinfo color="warning" %}}
10-
11-
🚧 This DRAFT page is under active development. 🚧
12-
13-
{{% /pageinfo %}}
14-
15-
This website uses Hugo's [multilingual framework] to support page localizations.
9+
The OTel website uses Hugo's [multilingual framework] to support page localizations.
1610
English is the default language, with US English as the default (implicit) localization.
1711
A growing number of other localizations are supported, as can be seen from the languages
1812
dropdown menu in the top nav.
1913

20-
## Translation tips
14+
## Translation guidance
15+
16+
We recommend that you follow the guidance offered in this section when
17+
translating pages.
18+
19+
### Heading anchors
20+
21+
To ensure that heading anchor targets are uniform across localizations, when
22+
translating headings:
23+
24+
- Preserve the heading's explicit ID if it has one. [Heading ID syntax] is
25+
written after the heading text using syntax like `{ #some-id }`.
26+
- Otherwise, explicitly declare a heading ID corresponding to the autogenerated
27+
ID of the original English heading.
28+
29+
{{% alert title="Note" %}}
30+
31+
We leave it to the discretion of localization authors to decide if they add an
32+
explicit heading ID to all headings of translated pages, or whether this is only
33+
done for known intra-site heading targets, as reported by the link checker. The
34+
former option is more uniform and more work. It better supports having
35+
site-external targets into localization pages and avoids having to revisit
36+
previously translated pages as new heading targets are used.
2137

22-
When you translate page content, follow this guidance:
38+
{{% /alert %}}
39+
40+
[Heading ID syntax]:
41+
https://github.com/yuin/goldmark/blob/master/README.md#headings
42+
43+
### Links
2344

24-
- To ensure that heading anchor targets are uniform across localizations, when
25-
translating headings:
26-
- If the heading has an explicit ID (which is of the form `{ #some-id }` and
27-
comes after the heading text), then preserve the given ID
28-
- Otherwise, include a heading ID corresponding to the original English
29-
heading text.
30-
- For link references that are local paths, preserve the path _as is_.
45+
For link references to local paths (as opposed to external links), preserve the
46+
path _as is_. This holds true for links to website pages or section-local
47+
resources such as images.
3148

3249
{{% alert title="Note" %}}
3350

34-
This repository has a custom render-link hook that Hugo uses to convert
35-
**absolute link paths to documentation pages** that are of the form
36-
`/docs/some-page`, to be locale specific, by prefixing the path with page
51+
The OTel website repository has a custom render-link hook that Hugo uses to
52+
convert **absolute link paths to documentation pages**. Links of the form
53+
`/docs/some-page` are made locale specific by prefixing the path with the page
3754
language code when rendering the link. For example, the previous sample path
3855
would become `/ja/docs/some-page` when rendered from a Japanese page.
3956

4057
{{% /alert %}}
4158

42-
## Keeping track of localized page drift {#track-changes}
59+
### Images
60+
61+
Hugo is smart in the way that it renders page images that are shared across site
62+
localizations. That is, in the generated site folder, Hugo will output a
63+
_single_ image file that is then shared across localizations.
64+
65+
So as a general rule, _do not_ make copies of image files in your localization
66+
unless you actually change the image.
67+
68+
### Shortcodes
69+
70+
Some of the base shortcodes contain English text that you might need to localize
71+
-- this is particularly true of those contained in [layouts/shortcodes/docs].
72+
73+
If you need to create a localized version of a shortcode, place it under
74+
`layouts/shortcodes/xx`, where `xx` is your localization's language code. From
75+
there, use the same relative path as the original base shortcode.
76+
77+
[layouts/shortcodes/docs]:
78+
https://github.com/open-telemetry/opentelemetry.io/tree/main/layouts/shortcodes/docs
79+
80+
## Keeping track of localized-page drift {#track-changes}
4381

4482
One of the main challenges of maintaining localized pages, is identifying when
4583
the corresponding English language pages have been updated. This section

0 commit comments

Comments
 (0)