Skip to content

Commit f36ff76

Browse files
author
Atanas Mirchev
committed
Localization of 2 resource creation dialogs
'Image Pull Secret' create dialog and 'Namespace' create dialog on the deploy page.
1 parent 7df7b15 commit f36ff76

File tree

9 files changed

+242
-34
lines changed

9 files changed

+242
-34
lines changed

build/i18n.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function extractForLanguage(langKey) {
3535

3636
let translationBundle = path.join(conf.paths.base, `i18n/messages-${langKey}.xtb`);
3737
let codeSource = path.join(conf.paths.serve, '*.js');
38-
let command = `java -jar ${conf.paths.xtbgenerator} --lang cs` +
38+
let command = `java -jar ${conf.paths.xtbgenerator} --lang ${langKey}` +
3939
` --xtb_output_file ${translationBundle}` + ` --js ${codeSource}`;
4040
if (fileExists(translationBundle)) {
4141
command = `${command} --translations_file ${translationBundle}`;

docs/devel/localization.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Localization
2+
3+
The document describes the proper way to introduce new text to dashboard.
4+
5+
## Overview
6+
7+
Dashboard is currently localized through the Google Closure Compiler's `goog.getMsg()` primitive. It allows the developer to define text that needs to be localized as simple variables anywhere in the code.
8+
9+
The localization process itself is integrated into the build pipeline and back-end component of Dashboard and happens automatically. Apart from placing new text into `MSG_` variables and using those in the angular templates, the developer is not required to do anything else.
10+
11+
## The MSG variables
12+
13+
Here is an example of a single `MSG_` variable definition:
14+
15+
```{js}
16+
/** @export {string} @desc The text appears when the image pull secret name exceeds the maximal length. */
17+
let MSG_IMAGE_PULL_SECRET_NAME_LENGTH_WARNING =
18+
goog.getMsg('Name must be up to {$maxLength} characters long.', {maxLength: '253'});
19+
```
20+
21+
Guidelines:
22+
* All variable names *must* start with `MSG_`.
23+
* Placeholders (`maxLength` above) are parts of the text that should remain the same in all translations.
24+
* The description of each variable (`@desc` above) should describe the context of its usage. It is supposed to help the translator.
25+
* The JavaDoc, containing all the annotations, should be kept at 1 line to reduce scrolling time.
26+
27+
For a quick reference please see [this cheat sheet](http://www.closurecheatsheet.com/i18n).
28+
29+
## Organizing the text variables
30+
31+
Currently, the `MSG` variables are stored in a constant dictionary at the bottom of the controller, which scopes the place (template) where they are used. The variables can then be referenced directly in the respective template's HTML code.
32+
33+
Here is an example of how to organize and use such variables:
34+
35+
```{js}
36+
class exampleController {
37+
constructor() {
38+
...
39+
40+
/**
41+
* @export
42+
*/
43+
this.i18n = i18n;
44+
45+
...
46+
}
47+
}
48+
49+
const i18n = {
50+
/** @export {string} @desc a simple example */
51+
MSG_EXAMPLE_TEXT: goog.getMsg('This is an example'),
52+
... // other variables
53+
}
54+
```
55+
56+
```{html}
57+
<html-block>
58+
{::ctrl.i18n.MSG_EXAMPLE_TEXT}}
59+
</html-block>
60+
```
61+
62+
In the HTML code, use one-time bindings like `{{::ctrl.i18n.MSG_EXAMPLE_TEXT}}` for efficiency.
63+
64+
## Naming conventions and guidelines
65+
* Consistently name the object containing the variables for a given controller `i18n`.
66+
* In the variable's name, after `MSG_`, try to write down the name of the controller (or part of Dashboard) to indicate where the variable is being used.
67+
* The suffix of the name should indicate the type (or role) of the text-resource in dashboard.
68+
69+
#### Table of text-resource types
70+
| Suffix | Usage |
71+
|--------------|:------------------------------------------------------------------------|
72+
| _TITLE | Title at the top of a window / view |
73+
| _SUBTITLE | Subtitle placed directly beneath the title |
74+
| _LABEL | Text used as a temporary placeholder or to name an input field |
75+
| _ACTION | A short phrase expressing an action (verb), usually meant to be clicked |
76+
| _WARNING | Warning when a validation error occurs |
77+
| _TOOLTIP | Tooltip / toast text that appears on hover |
78+
| _USER_HELP | Long text giving more details about a part of the UI |
79+
80+
#### Capitalization and punctuation
81+
* Only `_USER_HELP` and `_TOOLTIP` messages have standard punctuation and end with `.`
82+
* All of the messages have only their first word capitalized. Exceptions are names which appear in the middle of a message.
83+
* The human translators are supposed to keep the original capitalization and punctuation if applicable to the specific language.

i18n/messages-en.xtb

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE translationbundle>
3-
<translationbundle lang="cs">
3+
<translationbundle lang="en">
44
<translation id="8895655645940102616" key="MSG_DEPLOY_APP_NAME_USER_HELP" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="User help text for the &quot;App name&quot; on the deploy page.">An 'app' label with this value will be added to the Replication Controller and Service that get deployed.</translation>
5+
<translation id="1629323405372811987" key="MSG_NAMESPACE_CREATE_DIALOG_TITLE" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Create namespace dialog title. The message appears at the top of the dialog box.">Create a new namespace</translation>
6+
<translation id="7894572953642738628" key="MSG_NAMESPACE_CREATE_DIALOG_SUBTITLE" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Create namespace dialog subtitle. Appears right below the title.">The new namespace will be added to the cluster</translation>
7+
<translation id="2275990529199837995" key="MSG_NAMESPACE_NAME_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Namespace name', which appears as a placeholder in an empty input field in the create namespace dialog.">Namespace name</translation>
8+
<translation id="6583711267159567196" key="MSG_NAMESPACE_NAME_PATTERN_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text appears when the namespace name does not match the expected pattern.">Name must be alphanumeric and may contain dashes</translation>
9+
<translation id="3466771004397854426" key="MSG_NAMESPACE_NAME_LENGTH_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text appears when the namespace name exceeds the maximal length.">Name must be up to <ph name="MAX_LENGTH" /> characters long</translation>
10+
<translation id="4267128307522257099" key="MSG_NAMESPACE_NAME_REQUIRED_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Warning which tells the user that the namespace name is required.">Name is required</translation>
11+
<translation id="3530355110223734851" key="MSG_NAMESPACE_CREATE_ACTION" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text is put on the 'Create' button in the namespace creation dialog.">Create</translation>
12+
<translation id="4850098313852875572" key="MSG_NAMESPACE_CANCEL_ACTION" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text is put on the 'Cancel' button in the namespace creation dialog.">Cancel</translation>
13+
<translation id="6489624424433759035" key="MSG_IMAGE_PULL_SECRET_CREATE_DIALOG_TITLE" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Create image pull secret dialog title. The message appears at the top of the dialog box.">Create a new image pull secret</translation>
14+
<translation id="3382981767955244666" key="MSG_IMAGE_PULL_SECRET_CREATE_DIALOG_SUBTITLE" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Create image pull secret dialog subtitle. Appears right below the title.">The new secret will be added to the cluster</translation>
15+
<translation id="696865387402025901" key="MSG_IMAGE_PULL_SECRET_NAME_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Secret name', which appears as a placeholder in an empty input field in the image pull secret creation dialog.">Secret name</translation>
16+
<translation id="7256994603560688149" key="MSG_IMAGE_PULL_SECRET_NAME_PATTERN_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text appears when the image pull secret name does not match the expected pattern.">Name must follow the DNS domain name syntax (e.g. new.image-pull.secret)</translation>
17+
<translation id="4127420758208322272" key="MSG_IMAGE_PULL_SECRET_NAME_LENGTH_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text appears when the image pull secret name exceeds the maximal length.">Name must be up to <ph name="MAX_LENGTH" /> characters long.</translation>
18+
<translation id="7263428501718162087" key="MSG_IMAGE_PULL_SECRET_NAME_REQUIRED_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Warning which tells the user that the image pull secret name is required.">Name is required.</translation>
19+
<translation id="8342519402917559446" key="MSG_IMAGE_PULL_SECRET_CREATE_DIALOG_USER_HELP" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="User help text for the create image pull secret dialog. Directly after this text a specific namespace is specified.">A secret with the specified name will be added to the cluster in the namespace</translation>
20+
<translation id="2983148182170296230" key="MSG_IMAGE_PULL_SECRET_DATA_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Image pull secret data', which appears as a placeholder in an empty input field in the image pull secret creation dialog.">Image pull secret data</translation>
21+
<translation id="3432622161353334586" key="MSG_IMAGE_PULL_SECRET_DATA_REQUIRED_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Warning which tells the user that the image pull secret data is required.">Data is required</translation>
22+
<translation id="6217421730854783216" key="MSG_IMAGE_PULL_SECRET_DATA_BASE64_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text appears when the image pull secret data is not Base64 encoded.">Data must be Base64 encoded</translation>
23+
<translation id="7793557773608682327" key="MSG_IMAGE_PULL_SECRET_DATA_USER_HELP" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="User help text for the input of the &quot;Image Pull Secret&quot; data.">Specify the data for your secret to hold. The value is the Base64 encoded content of a .dockercfg file.</translation>
24+
<translation id="413516354763358070" key="MSG_IMAGE_PULL_SECRET_CREATE_ACTION" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text is put on the 'Create' button in the image pull secret creation dialog.">Create</translation>
25+
<translation id="919509716730095946" key="MSG_IMAGE_PULL_SECRET_CANCEL_ACTION" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text is put on the 'Cancel' button in the image pull secret creation dialog.">Cancel</translation>
26+
<translation id="7394607899033025775" key="MSG_IMAGE_PULL_SECRET_LEARN_MORE_ACTION" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text is used as a 'Learn more' link text in the image pull secret creation dialog">Learn more</translation>
527
</translationbundle>

i18n/messages-ja.xtb

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE translationbundle>
3-
<translationbundle lang="cs">
3+
<translationbundle lang="ja">
44
<translation id="8895655645940102616" key="MSG_DEPLOY_APP_NAME_USER_HELP" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="User help text for the &quot;App name&quot; on the deploy page.">An 'app' label with this value will be added to the Replication Controller and Service that get deployed.</translation>
5+
<translation id="1629323405372811987" key="MSG_NAMESPACE_CREATE_DIALOG_TITLE" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Create namespace dialog title. The message appears at the top of the dialog box.">Create a new namespace</translation>
6+
<translation id="7894572953642738628" key="MSG_NAMESPACE_CREATE_DIALOG_SUBTITLE" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Create namespace dialog subtitle. Appears right below the title.">The new namespace will be added to the cluster</translation>
7+
<translation id="2275990529199837995" key="MSG_NAMESPACE_NAME_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Namespace name', which appears as a placeholder in an empty input field in the create namespace dialog.">Namespace name</translation>
8+
<translation id="6583711267159567196" key="MSG_NAMESPACE_NAME_PATTERN_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text appears when the namespace name does not match the expected pattern.">Name must be alphanumeric and may contain dashes</translation>
9+
<translation id="3466771004397854426" key="MSG_NAMESPACE_NAME_LENGTH_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text appears when the namespace name exceeds the maximal length.">Name must be up to <ph name="MAX_LENGTH" /> characters long</translation>
10+
<translation id="4267128307522257099" key="MSG_NAMESPACE_NAME_REQUIRED_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Warning which tells the user that the namespace name is required.">Name is required</translation>
11+
<translation id="3530355110223734851" key="MSG_NAMESPACE_CREATE_ACTION" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text is put on the 'Create' button in the namespace creation dialog.">Create</translation>
12+
<translation id="4850098313852875572" key="MSG_NAMESPACE_CANCEL_ACTION" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text is put on the 'Cancel' button in the namespace creation dialog.">Cancel</translation>
13+
<translation id="6489624424433759035" key="MSG_IMAGE_PULL_SECRET_CREATE_DIALOG_TITLE" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Create image pull secret dialog title. The message appears at the top of the dialog box.">Create a new image pull secret</translation>
14+
<translation id="3382981767955244666" key="MSG_IMAGE_PULL_SECRET_CREATE_DIALOG_SUBTITLE" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Create image pull secret dialog subtitle. Appears right below the title.">The new secret will be added to the cluster</translation>
15+
<translation id="696865387402025901" key="MSG_IMAGE_PULL_SECRET_NAME_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Secret name', which appears as a placeholder in an empty input field in the image pull secret creation dialog.">Secret name</translation>
16+
<translation id="7256994603560688149" key="MSG_IMAGE_PULL_SECRET_NAME_PATTERN_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text appears when the image pull secret name does not match the expected pattern.">Name must follow the DNS domain name syntax (e.g. new.image-pull.secret)</translation>
17+
<translation id="4127420758208322272" key="MSG_IMAGE_PULL_SECRET_NAME_LENGTH_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text appears when the image pull secret name exceeds the maximal length.">Name must be up to <ph name="MAX_LENGTH" /> characters long.</translation>
18+
<translation id="7263428501718162087" key="MSG_IMAGE_PULL_SECRET_NAME_REQUIRED_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Warning which tells the user that the image pull secret name is required.">Name is required.</translation>
19+
<translation id="8342519402917559446" key="MSG_IMAGE_PULL_SECRET_CREATE_DIALOG_USER_HELP" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="User help text for the create image pull secret dialog. Directly after this text a specific namespace is specified.">A secret with the specified name will be added to the cluster in the namespace</translation>
20+
<translation id="2983148182170296230" key="MSG_IMAGE_PULL_SECRET_DATA_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Image pull secret data', which appears as a placeholder in an empty input field in the image pull secret creation dialog.">Image pull secret data</translation>
21+
<translation id="3432622161353334586" key="MSG_IMAGE_PULL_SECRET_DATA_REQUIRED_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Warning which tells the user that the image pull secret data is required.">Data is required</translation>
22+
<translation id="6217421730854783216" key="MSG_IMAGE_PULL_SECRET_DATA_BASE64_WARNING" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text appears when the image pull secret data is not Base64 encoded.">Data must be Base64 encoded</translation>
23+
<translation id="7793557773608682327" key="MSG_IMAGE_PULL_SECRET_DATA_USER_HELP" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="User help text for the input of the &quot;Image Pull Secret&quot; data.">Specify the data for your secret to hold. The value is the Base64 encoded content of a .dockercfg file.</translation>
24+
<translation id="413516354763358070" key="MSG_IMAGE_PULL_SECRET_CREATE_ACTION" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text is put on the 'Create' button in the image pull secret creation dialog.">Create</translation>
25+
<translation id="919509716730095946" key="MSG_IMAGE_PULL_SECRET_CANCEL_ACTION" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text is put on the 'Cancel' button in the image pull secret creation dialog.">Cancel</translation>
26+
<translation id="7394607899033025775" key="MSG_IMAGE_PULL_SECRET_LEARN_MORE_ACTION" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="The text is used as a 'Learn more' link text in the image pull secret creation dialog">Learn more</translation>
527
</translationbundle>

0 commit comments

Comments
 (0)