Skip to content

Commit d4777b5

Browse files
authored
Merge pull request #15110 from mrdoob/editor
Editor: Added localisation support.
2 parents de6f8f7 + b2ce63c commit d4777b5

File tree

11 files changed

+213
-43
lines changed

11 files changed

+213
-43
lines changed

editor/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
<script src="js/Sidebar.Animation.js"></script>
139139
<script src="js/Sidebar.Script.js"></script>
140140
<script src="js/Sidebar.History.js"></script>
141+
<script src="js/Strings.js"></script>
141142
<script src="js/Toolbar.js"></script>
142143
<script src="js/Viewport.js"></script>
143144
<script src="js/Viewport.Info.js"></script>

editor/js/Config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ var Config = function () {
77
var name = 'threejs-editor';
88

99
var storage = {
10+
'language': 'en',
11+
1012
'autosave': true,
1113
'theme': 'css/light.css',
1214

editor/js/Editor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ var Editor = function () {
7575
this.config = new Config();
7676
this.history = new History( this );
7777
this.storage = new Storage();
78+
this.strings = new Strings( this.config );
79+
7880
this.loader = new Loader( this );
7981

8082
this.camera = this.DEFAULT_CAMERA.clone();

editor/js/Menubar.Add.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
Menubar.Add = function ( editor ) {
66

7+
var strings = editor.strings;
8+
79
var container = new UI.Panel();
810
container.setClass( 'menu' );
911

1012
var title = new UI.Panel();
1113
title.setClass( 'title' );
12-
title.setTextContent( 'Add' );
14+
title.setTextContent( strings.getKey( 'menubar/add' ) );
1315
container.add( title );
1416

1517
var options = new UI.Panel();
@@ -20,7 +22,7 @@ Menubar.Add = function ( editor ) {
2022

2123
var option = new UI.Row();
2224
option.setClass( 'option' );
23-
option.setTextContent( 'Group' );
25+
option.setTextContent( strings.getKey( 'menubar/add/group' ) );
2426
option.onClick( function () {
2527

2628
var mesh = new THREE.Group();
@@ -39,7 +41,7 @@ Menubar.Add = function ( editor ) {
3941

4042
var option = new UI.Row();
4143
option.setClass( 'option' );
42-
option.setTextContent( 'Plane' );
44+
option.setTextContent( strings.getKey( 'menubar/add/plane' ) );
4345
option.onClick( function () {
4446

4547
var geometry = new THREE.PlaneBufferGeometry( 1, 1, 1, 1 );
@@ -56,7 +58,7 @@ Menubar.Add = function ( editor ) {
5658

5759
var option = new UI.Row();
5860
option.setClass( 'option' );
59-
option.setTextContent( 'Box' );
61+
option.setTextContent( strings.getKey( 'menubar/add/box' ) );
6062
option.onClick( function () {
6163

6264
var geometry = new THREE.BoxBufferGeometry( 1, 1, 1, 1, 1, 1 );
@@ -72,7 +74,7 @@ Menubar.Add = function ( editor ) {
7274

7375
var option = new UI.Row();
7476
option.setClass( 'option' );
75-
option.setTextContent( 'Circle' );
77+
option.setTextContent( strings.getKey( 'menubar/add/circle' ) );
7678
option.onClick( function () {
7779

7880
var geometry = new THREE.CircleBufferGeometry( 1, 8, 0, Math.PI * 2 );
@@ -88,7 +90,7 @@ Menubar.Add = function ( editor ) {
8890

8991
var option = new UI.Row();
9092
option.setClass( 'option' );
91-
option.setTextContent( 'Cylinder' );
93+
option.setTextContent( strings.getKey( 'menubar/add/cylinder' ) );
9294
option.onClick( function () {
9395

9496
var geometry = new THREE.CylinderBufferGeometry( 1, 1, 1, 8, 1, false, 0, Math.PI * 2 );
@@ -104,7 +106,7 @@ Menubar.Add = function ( editor ) {
104106

105107
var option = new UI.Row();
106108
option.setClass( 'option' );
107-
option.setTextContent( 'Sphere' );
109+
option.setTextContent( strings.getKey( 'menubar/add/sphere' ) );
108110
option.onClick( function () {
109111

110112
var geometry = new THREE.SphereBufferGeometry( 1, 8, 6, 0, Math.PI * 2, 0, Math.PI );
@@ -120,7 +122,7 @@ Menubar.Add = function ( editor ) {
120122

121123
var option = new UI.Row();
122124
option.setClass( 'option' );
123-
option.setTextContent( 'Icosahedron' );
125+
option.setTextContent( strings.getKey( 'menubar/add/icosahedron' ) );
124126
option.onClick( function () {
125127

126128
var geometry = new THREE.IcosahedronGeometry( 1, 0 );
@@ -136,7 +138,7 @@ Menubar.Add = function ( editor ) {
136138

137139
var option = new UI.Row();
138140
option.setClass( 'option' );
139-
option.setTextContent( 'Torus' );
141+
option.setTextContent( strings.getKey( 'menubar/add/torus' ) );
140142
option.onClick( function () {
141143

142144
var geometry = new THREE.TorusBufferGeometry( 1, 0.4, 8, 6, Math.PI * 2 );
@@ -152,7 +154,7 @@ Menubar.Add = function ( editor ) {
152154

153155
var option = new UI.Row();
154156
option.setClass( 'option' );
155-
option.setTextContent( 'TorusKnot' );
157+
option.setTextContent( strings.getKey( 'menubar/add/torusknot' ) );
156158
option.onClick( function () {
157159

158160
var geometry = new THREE.TorusKnotBufferGeometry( 1, 0.4, 64, 8, 2, 3 );
@@ -197,7 +199,7 @@ Menubar.Add = function ( editor ) {
197199

198200
var option = new UI.Row();
199201
option.setClass( 'option' );
200-
option.setTextContent( 'Lathe' );
202+
option.setTextContent( strings.getKey( 'menubar/add/lathe' ) );
201203
option.onClick( function() {
202204

203205
var points = [
@@ -227,7 +229,7 @@ Menubar.Add = function ( editor ) {
227229

228230
var option = new UI.Row();
229231
option.setClass( 'option' );
230-
option.setTextContent( 'Sprite' );
232+
option.setTextContent( strings.getKey( 'menubar/add/sprite' ) );
231233
option.onClick( function () {
232234

233235
var sprite = new THREE.Sprite( new THREE.SpriteMaterial() );
@@ -246,7 +248,7 @@ Menubar.Add = function ( editor ) {
246248

247249
var option = new UI.Row();
248250
option.setClass( 'option' );
249-
option.setTextContent( 'PointLight' );
251+
option.setTextContent( strings.getKey( 'menubar/add/pointlight' ) );
250252
option.onClick( function () {
251253

252254
var color = 0xffffff;
@@ -265,7 +267,7 @@ Menubar.Add = function ( editor ) {
265267

266268
var option = new UI.Row();
267269
option.setClass( 'option' );
268-
option.setTextContent( 'SpotLight' );
270+
option.setTextContent( strings.getKey( 'menubar/add/spotlight' ) );
269271
option.onClick( function () {
270272

271273
var color = 0xffffff;
@@ -289,7 +291,7 @@ Menubar.Add = function ( editor ) {
289291

290292
var option = new UI.Row();
291293
option.setClass( 'option' );
292-
option.setTextContent( 'DirectionalLight' );
294+
option.setTextContent( strings.getKey( 'menubar/add/directionallight' ) );
293295
option.onClick( function () {
294296

295297
var color = 0xffffff;
@@ -310,7 +312,7 @@ Menubar.Add = function ( editor ) {
310312

311313
var option = new UI.Row();
312314
option.setClass( 'option' );
313-
option.setTextContent( 'HemisphereLight' );
315+
option.setTextContent( strings.getKey( 'menubar/add/hemispherelight' ) );
314316
option.onClick( function () {
315317

316318
var skyColor = 0x00aaff;
@@ -331,7 +333,7 @@ Menubar.Add = function ( editor ) {
331333

332334
var option = new UI.Row();
333335
option.setClass( 'option' );
334-
option.setTextContent( 'AmbientLight' );
336+
option.setTextContent( strings.getKey( 'menubar/add/ambientlight' ) );
335337
option.onClick( function() {
336338

337339
var color = 0x222222;
@@ -352,7 +354,7 @@ Menubar.Add = function ( editor ) {
352354

353355
var option = new UI.Row();
354356
option.setClass( 'option' );
355-
option.setTextContent( 'PerspectiveCamera' );
357+
option.setTextContent( strings.getKey( 'menubar/add/perspectivecamera' ) );
356358
option.onClick( function() {
357359

358360
var camera = new THREE.PerspectiveCamera( 50, 1, 1, 10000 );

editor/js/Menubar.Edit.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
Menubar.Edit = function ( editor ) {
66

7+
var strings = editor.strings;
8+
79
var container = new UI.Panel();
810
container.setClass( 'menu' );
911

1012
var title = new UI.Panel();
1113
title.setClass( 'title' );
12-
title.setTextContent( 'Edit' );
14+
title.setTextContent( strings.getKey( 'menubar/edit' ) );
1315
container.add( title );
1416

1517
var options = new UI.Panel();
@@ -20,7 +22,7 @@ Menubar.Edit = function ( editor ) {
2022

2123
var undo = new UI.Row();
2224
undo.setClass( 'option' );
23-
undo.setTextContent( 'Undo (Ctrl+Z)' );
25+
undo.setTextContent( strings.getKey( 'menubar/edit/undo' ) );
2426
undo.onClick( function () {
2527

2628
editor.undo();
@@ -32,7 +34,7 @@ Menubar.Edit = function ( editor ) {
3234

3335
var redo = new UI.Row();
3436
redo.setClass( 'option' );
35-
redo.setTextContent( 'Redo (Ctrl+Shift+Z)' );
37+
redo.setTextContent( strings.getKey( 'menubar/edit/redo' ) );
3638
redo.onClick( function () {
3739

3840
editor.redo();
@@ -44,7 +46,7 @@ Menubar.Edit = function ( editor ) {
4446

4547
var option = new UI.Row();
4648
option.setClass( 'option' );
47-
option.setTextContent( 'Clear History' );
49+
option.setTextContent( strings.getKey( 'menubar/edit/clear_history' ) );
4850
option.onClick( function () {
4951

5052
if ( confirm( 'The Undo/Redo History will be cleared. Are you sure?' ) ) {
@@ -86,7 +88,7 @@ Menubar.Edit = function ( editor ) {
8688

8789
var option = new UI.Row();
8890
option.setClass( 'option' );
89-
option.setTextContent( 'Clone' );
91+
option.setTextContent( strings.getKey( 'menubar/edit/clone' ) );
9092
option.onClick( function () {
9193

9294
var object = editor.selected;
@@ -104,7 +106,7 @@ Menubar.Edit = function ( editor ) {
104106

105107
var option = new UI.Row();
106108
option.setClass( 'option' );
107-
option.setTextContent( 'Delete (Del)' );
109+
option.setTextContent( strings.getKey( 'menubar/edit/delete' ) );
108110
option.onClick( function () {
109111

110112
var object = editor.selected;
@@ -121,7 +123,7 @@ Menubar.Edit = function ( editor ) {
121123

122124
var option = new UI.Row();
123125
option.setClass( 'option' );
124-
option.setTextContent( 'Minify Shaders' );
126+
option.setTextContent( strings.getKey( 'menubar/edit/minify_shaders' ) );
125127
option.onClick( function() {
126128

127129
var root = editor.selected || editor.scene;

editor/js/Menubar.Examples.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
Menubar.Examples = function ( editor ) {
66

7+
var strings = editor.strings;
8+
79
var container = new UI.Panel();
810
container.setClass( 'menu' );
911

1012
var title = new UI.Panel();
1113
title.setClass( 'title' );
12-
title.setTextContent( 'Examples' );
14+
title.setTextContent( strings.getKey( 'menubar/examples' ) );
1315
container.add( title );
1416

1517
var options = new UI.Panel();

editor/js/Menubar.File.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ Menubar.File = function ( editor ) {
1515
//
1616

1717
var config = editor.config;
18+
var strings = editor.strings;
1819

1920
var container = new UI.Panel();
2021
container.setClass( 'menu' );
2122

2223
var title = new UI.Panel();
2324
title.setClass( 'title' );
24-
title.setTextContent( 'File' );
25+
title.setTextContent( strings.getKey( 'menubar/file' ) );
2526
container.add( title );
2627

2728
var options = new UI.Panel();
@@ -32,7 +33,7 @@ Menubar.File = function ( editor ) {
3233

3334
var option = new UI.Row();
3435
option.setClass( 'option' );
35-
option.setTextContent( 'New' );
36+
option.setTextContent( strings.getKey( 'menubar/file/new' ) );
3637
option.onClick( function () {
3738

3839
if ( confirm( 'Any unsaved data will be lost. Are you sure?' ) ) {
@@ -67,7 +68,7 @@ Menubar.File = function ( editor ) {
6768

6869
var option = new UI.Row();
6970
option.setClass( 'option' );
70-
option.setTextContent( 'Import' );
71+
option.setTextContent( strings.getKey( 'menubar/file/import' ) );
7172
option.onClick( function () {
7273

7374
fileInput.click();
@@ -83,7 +84,7 @@ Menubar.File = function ( editor ) {
8384

8485
var option = new UI.Row();
8586
option.setClass( 'option' );
86-
option.setTextContent( 'Export Geometry' );
87+
option.setTextContent( strings.getKey( 'menubar/file/export/geometry' ) );
8788
option.onClick( function () {
8889

8990
var object = editor.selected;
@@ -126,7 +127,7 @@ Menubar.File = function ( editor ) {
126127

127128
var option = new UI.Row();
128129
option.setClass( 'option' );
129-
option.setTextContent( 'Export Object' );
130+
option.setTextContent( strings.getKey( 'menubar/file/export/object' ) );
130131
option.onClick( function () {
131132

132133
var object = editor.selected;
@@ -160,7 +161,7 @@ Menubar.File = function ( editor ) {
160161

161162
var option = new UI.Row();
162163
option.setClass( 'option' );
163-
option.setTextContent( 'Export Scene' );
164+
option.setTextContent( strings.getKey( 'menubar/file/export/scene' ) );
164165
option.onClick( function () {
165166

166167
var output = editor.scene.toJSON();
@@ -189,7 +190,7 @@ Menubar.File = function ( editor ) {
189190

190191
var option = new UI.Row();
191192
option.setClass( 'option' );
192-
option.setTextContent( 'Export DAE' );
193+
option.setTextContent( strings.getKey( 'menubar/file/export/dae' ) );
193194
option.onClick( function () {
194195

195196
var exporter = new THREE.ColladaExporter();
@@ -207,7 +208,7 @@ Menubar.File = function ( editor ) {
207208

208209
var option = new UI.Row();
209210
option.setClass( 'option' );
210-
option.setTextContent( 'Export GLB' );
211+
option.setTextContent( strings.getKey( 'menubar/file/export/glb' ) );
211212
option.onClick( function () {
212213

213214
var exporter = new THREE.GLTFExporter();
@@ -227,7 +228,7 @@ Menubar.File = function ( editor ) {
227228

228229
var option = new UI.Row();
229230
option.setClass( 'option' );
230-
option.setTextContent( 'Export GLTF' );
231+
option.setTextContent( strings.getKey( 'menubar/file/export/gltf' ) );
231232
option.onClick( function () {
232233

233234
var exporter = new THREE.GLTFExporter();
@@ -246,7 +247,7 @@ Menubar.File = function ( editor ) {
246247

247248
var option = new UI.Row();
248249
option.setClass( 'option' );
249-
option.setTextContent( 'Export OBJ' );
250+
option.setTextContent( strings.getKey( 'menubar/file/export/obj' ) );
250251
option.onClick( function () {
251252

252253
var object = editor.selected;
@@ -269,7 +270,7 @@ Menubar.File = function ( editor ) {
269270

270271
var option = new UI.Row();
271272
option.setClass( 'option' );
272-
option.setTextContent( 'Export STL' );
273+
option.setTextContent( strings.getKey( 'menubar/file/export/stl' ) );
273274
option.onClick( function () {
274275

275276
var exporter = new THREE.STLExporter();
@@ -287,7 +288,7 @@ Menubar.File = function ( editor ) {
287288

288289
var option = new UI.Row();
289290
option.setClass( 'option' );
290-
option.setTextContent( 'Publish' );
291+
option.setTextContent( strings.getKey( 'menubar/file/publish' ) );
291292
option.onClick( function () {
292293

293294
var zip = new JSZip();

0 commit comments

Comments
 (0)