Skip to content

Commit 496e850

Browse files
committed
Make views translatable
1 parent 2e2b474 commit 496e850

23 files changed

+661
-175
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
bower_components/*
22
node_modules/*
3-
templates.js
3+
templates.js

Gruntfile.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,30 @@ module.exports = function(grunt) {
8989
src: 'views/**.html',
9090
dest: 'templates.js'
9191
}
92+
},
93+
nggettext_extract: {
94+
pot: {
95+
files: {
96+
'po/kubernetes-object-describer.pot': ['views/*.html']
97+
}
98+
}
99+
},
100+
nggettext_compile: {
101+
all: {
102+
options: {
103+
format: "json"
104+
},
105+
files: [
106+
{
107+
expand: true,
108+
dot: true,
109+
cwd: "po",
110+
dest: "dist/languages",
111+
src: ["*.po"],
112+
ext: ".json"
113+
}
114+
]
115+
}
92116
}
93117
});
94118

@@ -99,6 +123,9 @@ module.exports = function(grunt) {
99123
grunt.loadNpmTasks('grunt-contrib-concat');
100124
grunt.loadNpmTasks('grunt-wiredep');
101125
grunt.loadNpmTasks('grunt-angular-templates');
126+
grunt.loadNpmTasks('grunt-angular-gettext');
127+
128+
grunt.registerTask('update-po', ['nggettext_extract']);
102129

103130
grunt.registerTask('serve', [
104131
'less',
@@ -109,10 +136,11 @@ module.exports = function(grunt) {
109136
]);
110137

111138
grunt.registerTask('build', [
139+
'nggettext_compile',
112140
'less',
113141
'ngtemplates',
114142
'concat'
115143
]);
116144
grunt.registerTask('default', ['serve']);
117145

118-
};
146+
};

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"dist/object-describer.js"
2525
],
2626
"dependencies": {
27-
"angular": "~1.3.8"
27+
"angular": "~1.3.8",
28+
"angular-gettext": "~2.1.0"
2829
},
2930
"devDependencies": {
3031
"bootstrap": "~3.3.4",

dist/languages/ja.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"ja":{"Name":"名前"}}

dist/object-describer.js

Lines changed: 84 additions & 84 deletions
Large diffs are not rendered by default.

index.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
</style>
2323
</head>
2424
<body ng-app="exampleApp" style="margin-left: 10px;">
25+
<label translate>Select a language:</label>
26+
<select ng-model="lang"
27+
ng-options="lang for lang in languages"
28+
ng-change="switchLanguage()">
29+
</select>
2530
<h1>Default generic describer</h1>
2631
<kubernetes-object-describer resource="kubernetesExamplePod" more-details-link="example/path/to/more/details.htm"></kubernetes-object-describer>
2732
<hr>
@@ -45,6 +50,7 @@ <h1>Replication Controller describer</h1>
4550
<!-- build:js(.) scripts/vendor.js -->
4651
<!-- bower:js -->
4752
<script src="bower_components/angular/angular.js"></script>
53+
<script src="bower_components/angular-gettext/dist/angular-gettext.js"></script>
4854
<!-- endbower -->
4955
<!-- endbuild -->
5056

@@ -57,15 +63,21 @@ <h1>Replication Controller describer</h1>
5763

5864
<script src="bower_components/jQuery/dist/jquery.js"></script>
5965
<script type="text/javascript">
60-
angular.module('exampleApp', ['kubernetesUI'])
61-
.run(function($rootScope) {
66+
angular.module('exampleApp', ['kubernetesUI', 'gettext'])
67+
.run(function($rootScope, gettextCatalog) {
6268
// TODO any example JS will go here
6369
$rootScope.kubernetesExamplePod = window.EXAMPLE_POD;
6470
$rootScope.kubernetesExampleService = window.EXAMPLE_SERVICE;
6571
$rootScope.kubernetesExampleHeadlessService = window.EXAMPLE_HEADLESS_SERVICE;
6672
$rootScope.kubernetesExampleNodePortService = window.EXAMPLE_NODE_PORT_SERVICE;
6773
$rootScope.kubernetesExampleLoadBalancedService = window.EXAMPLE_LOAD_BALANCED_SERVICE;
6874
$rootScope.kubernetesExampleRC = window.EXAMPLE_RC;
75+
$rootScope.languages = ['en', 'ja'];
76+
$rootScope.lang = 'en';
77+
$rootScope.switchLanguage = function() {
78+
gettextCatalog.setCurrentLanguage($rootScope.lang);
79+
gettextCatalog.loadRemote('/dist/languages/' + $rootScope.lang + '.json');
80+
};
6981
});
7082
</script>
7183
</body>

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
"dependencies": {},
1111
"devDependencies": {
1212
"grunt": "~0.4.5",
13+
"grunt-angular-gettext": "^2.1.3",
14+
"grunt-angular-templates": "~0.5.7",
15+
"grunt-contrib-concat": "~0.5.1",
1316
"grunt-contrib-connect": "~0.9.0",
1417
"grunt-contrib-jshint": "~0.11.1",
1518
"grunt-contrib-less": "~1.0.0",
16-
"grunt-wiredep": "~2.0.0",
1719
"grunt-contrib-watch": "~0.6.1",
18-
"grunt-angular-templates": "~0.5.7",
19-
"grunt-contrib-concat": "~0.5.1"
20+
"grunt-wiredep": "~2.0.0"
2021
},
2122
"scripts": {
2223
"test": "echo \"Error: no test specified\" && exit 1"

po/ja.po

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
msgid ""
2+
msgstr ""
3+
"Content-Type: text/plain; charset=UTF-8\n"
4+
"Content-Transfer-Encoding: 8bit\n"
5+
"Project-Id-Version: \n"
6+
"Language: ja\n"
7+
8+
#: views/annotations.html:1
9+
msgid "Annotations"
10+
msgstr ""
11+
12+
#: views/pod.html:28
13+
msgid "Container Statuses"
14+
msgstr ""
15+
16+
#: views/pod-template.html:10
17+
msgid "Containers"
18+
msgstr ""
19+
20+
#: views/metadata.html:6
21+
#: views/pod.html:8
22+
#: views/replication-controller.html:8
23+
#: views/service.html:8
24+
msgid "Created"
25+
msgstr ""
26+
27+
#: views/pod-template.html:5
28+
msgid "DNS policy"
29+
msgstr ""
30+
31+
#: views/containers.html:15
32+
msgid "Env vars"
33+
msgstr ""
34+
35+
#: views/_collapse-long-text.html:3
36+
msgid "Expand"
37+
msgstr ""
38+
39+
#: views/volumes.html:15
40+
msgid "GCE persistent disk"
41+
msgstr ""
42+
43+
#: views/volumes.html:18
44+
msgid "Git repository"
45+
msgstr ""
46+
47+
#: views/service.html:12
48+
msgid "IP"
49+
msgstr ""
50+
51+
#: views/pod.html:22
52+
msgid "IP on node"
53+
msgstr ""
54+
55+
#: views/containers.html:5
56+
msgid "Image"
57+
msgstr ""
58+
59+
#: views/service.html:23
60+
msgid "Ingress points"
61+
msgstr ""
62+
63+
#: views/labels.html:1
64+
msgid "Labels"
65+
msgstr ""
66+
67+
#: views/container-statuses.html:9
68+
msgid "Last State"
69+
msgstr ""
70+
71+
#: views/footer.html:2
72+
msgid "More details..."
73+
msgstr ""
74+
75+
#: views/container-statuses.html:3
76+
#: views/containers.html:3
77+
#: views/metadata.html:2
78+
#: views/pod.html:4
79+
#: views/replication-controller.html:4
80+
#: views/service.html:4
81+
#: views/volumes.html:3
82+
msgid "Name"
83+
msgstr "名前"
84+
85+
#: views/metadata.html:4
86+
#: views/pod.html:6
87+
#: views/replication-controller.html:6
88+
#: views/service.html:6
89+
msgid "Namespace"
90+
msgstr ""
91+
92+
#: views/pod.html:19
93+
msgid "Node"
94+
msgstr ""
95+
96+
#: views/service.html:16
97+
msgid "None"
98+
msgstr ""
99+
100+
#: views/volumes.html:8
101+
msgid "Path"
102+
msgstr ""
103+
104+
#: views/pod.html:17
105+
msgid "Phase"
106+
msgstr ""
107+
108+
#: views/containers.html:8
109+
#: views/service.html:14
110+
msgid "Ports"
111+
msgstr ""
112+
113+
#: views/container-statuses.html:13
114+
msgid "Ready"
115+
msgstr ""
116+
117+
#: views/replication-controller.html:10
118+
msgid "Replicas"
119+
msgstr ""
120+
121+
#: views/volumes.html:19
122+
msgid "Repository"
123+
msgstr ""
124+
125+
#: views/container-statuses.html:15
126+
msgid "Restart Count"
127+
msgstr ""
128+
129+
#: views/pod-template.html:3
130+
#: views/pod.html:10
131+
msgid "Restart policy"
132+
msgstr ""
133+
134+
#: views/volumes.html:21
135+
msgid "Revision"
136+
msgstr ""
137+
138+
#: views/container-state.html:9
139+
msgid "Running"
140+
msgstr ""
141+
142+
#: views/replication-controller.html:13
143+
#: views/service.html:29
144+
msgid "Selector"
145+
msgstr ""
146+
147+
#: views/pod-template.html:7
148+
#: views/pod.html:12
149+
msgid "Service account"
150+
msgstr ""
151+
152+
#: views/service.html:21
153+
msgid "Session affinity"
154+
msgstr ""
155+
156+
#: views/container-statuses.html:5
157+
msgid "State"
158+
msgstr ""
159+
160+
#: views/pod.html:15
161+
msgid "Status"
162+
msgstr ""
163+
164+
#: views/container-state.html:13
165+
msgid "Terminated"
166+
msgstr ""
167+
168+
#: views/service.html:10
169+
#: views/volumes.html:11
170+
#: views/volumes.html:14
171+
#: views/volumes.html:17
172+
#: views/volumes.html:6
173+
msgid "Type"
174+
msgstr ""
175+
176+
#: views/pod-template.html:12
177+
msgid "Volumes"
178+
msgstr ""
179+
180+
#: views/container-state.html:5
181+
msgid "Waiting"
182+
msgstr ""
183+
184+
#: views/container-state.html:14
185+
msgid "at {{stateDescription.finishedAt | date:'medium'}}"
186+
msgstr ""
187+
188+
#: views/volumes.html:12
189+
msgid "empty directory"
190+
msgstr ""
191+
192+
#: views/volumes.html:7
193+
msgid "host path"
194+
msgstr ""
195+
196+
#: views/annotations.html:2
197+
#: views/container-state.html:1
198+
#: views/container-statuses.html:1
199+
#: views/containers.html:10
200+
#: views/containers.html:17
201+
#: views/containers.html:7
202+
#: views/labels.html:2
203+
#: views/pod.html:25
204+
#: views/volumes.html:1
205+
msgid "none"
206+
msgstr ""
207+
208+
#: views/volumes.html:24
209+
msgid "not specified"
210+
msgstr ""
211+
212+
#: views/container-state.html:10
213+
msgid "since {{stateDescription.startedAt | date:'medium'}}"
214+
msgstr ""
215+
216+
#: views/containers.html:12
217+
msgid "to host port {{port.hostPort}}"
218+
msgstr ""
219+
220+
#: views/container-state.html:15
221+
msgid "with exit code {{stateDescription.exitCode}}"
222+
msgstr ""

0 commit comments

Comments
 (0)