|
1 | 1 | ---
|
2 | 2 | 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. |
5 | 4 | linkTitle: Localization
|
6 | 5 | weight: 25
|
| 6 | +cSpell:ignore: shortcodes |
7 | 7 | ---
|
8 | 8 |
|
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. |
16 | 10 | English is the default language, with US English as the default (implicit) localization.
|
17 | 11 | A growing number of other localizations are supported, as can be seen from the languages
|
18 | 12 | dropdown menu in the top nav.
|
19 | 13 |
|
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. |
21 | 37 |
|
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 |
23 | 44 |
|
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. |
31 | 48 |
|
32 | 49 | {{% alert title="Note" %}}
|
33 | 50 |
|
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 |
37 | 54 | language code when rendering the link. For example, the previous sample path
|
38 | 55 | would become `/ja/docs/some-page` when rendered from a Japanese page.
|
39 | 56 |
|
40 | 57 | {{% /alert %}}
|
41 | 58 |
|
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} |
43 | 81 |
|
44 | 82 | One of the main challenges of maintaining localized pages, is identifying when
|
45 | 83 | the corresponding English language pages have been updated. This section
|
|
0 commit comments