Skip to content

Commit d10b3a1

Browse files
committed
Use the localization technology in the website code.
1 parent 449ce84 commit d10b3a1

14 files changed

+148
-134
lines changed

source/website/dialogs.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { AddDiv } from '../engine/viewer/domutils.js';
22
import { ButtonDialog, ListPopup } from './dialog.js';
3+
import { Loc } from '../engine/core/localization.js';
34

45
export function ShowMessageDialog (title, message, subMessage)
56
{
67
let dialog = new ButtonDialog ();
78
let contentDiv = dialog.Init (title, [
89
{
9-
name : 'OK',
10+
name : Loc ('OK'),
1011
onClick () {
1112
dialog.Close ();
1213
}

source/website/exportdialog.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ShowMessageDialog } from './dialogs.js';
1111
import { DownloadArrayBufferAsFile } from './utils.js';
1212
import { CookieGetStringVal, CookieSetStringVal } from './cookiehandler.js';
1313
import { HandleEvent } from './eventhandler.js';
14+
import { Loc } from '../engine/core/localization.js';
1415

1516
import * as fflate from 'fflate';
1617

@@ -53,8 +54,8 @@ class ModelExporterUI
5354
return AddSelectWithCookieSave (parameterValueDiv, cookieKey, values, defaultIndex);
5455
}
5556

56-
this.visibleOnlySelect = AddSelectItem (parametersDiv, 'Scope', 'ov_last_scope', ['Entire Model', 'Visible Only'], 1);
57-
this.rotationSelect = AddSelectItem (parametersDiv, 'Rotation', 'ov_last_rotation', ['No Rotation', '-90 Degrees', '90 Degrees'], 0);
57+
this.visibleOnlySelect = AddSelectItem (parametersDiv, Loc ('Scope'), 'ov_last_scope', [Loc ('Entire Model'), Loc ('Visible Only')], 1);
58+
this.rotationSelect = AddSelectItem (parametersDiv, Loc ('Rotation'), 'ov_last_rotation', [Loc ('No Rotation'), Loc ('-90 Degrees'), Loc ('90 Degrees')], 0);
5859
}
5960

6061
ExportModel (model, callbacks)
@@ -77,15 +78,15 @@ class ModelExporterUI
7778
let exporterModel = new ExporterModel (model, settings);
7879
if (exporterModel.MeshInstanceCount () === 0) {
7980
ShowMessageDialog (
80-
'Export Failed',
81-
'The model doesn\'t contain any meshes.',
81+
Loc ('Export Failed'),
82+
Loc ('The model doesn\'t contain any meshes.'),
8283
null
8384
);
8485
return;
8586
}
8687

8788
let progressDialog = new ProgressDialog ();
88-
progressDialog.Init ('Exporting Model');
89+
progressDialog.Init (Loc ('Exporting Model'));
8990
progressDialog.Open ();
9091

9192
RunTaskAsync (() => {
@@ -142,24 +143,24 @@ class ExportDialog
142143
Open (model, viewer)
143144
{
144145
let mainDialog = new ButtonDialog ();
145-
let contentDiv = mainDialog.Init ('Export', [
146+
let contentDiv = mainDialog.Init (Loc ('Export'), [
146147
{
147-
name : 'Close',
148+
name : Loc ('Close'),
148149
subClass : 'outline',
149150
onClick () {
150151
mainDialog.Close ();
151152
}
152153
},
153154
{
154-
name : 'Export',
155+
name : Loc ('Export'),
155156
onClick : () => {
156157
mainDialog.Close ();
157158
this.ExportFormat (model, viewer);
158159
}
159160
}
160161
]);
161162

162-
let text = 'Select the format from the list below, and adjust the settings of the selected format.';
163+
let text = Loc ('Select the format from the list below, and adjust the settings of the selected format.');
163164
AddDiv (contentDiv, 'ov_dialog_section', text);
164165

165166
let formatRow = AddDiv (contentDiv, 'ov_dialog_row');

source/website/measuretool.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BigEps, IsEqualEps, RadDeg } from '../engine/geometry/geometry.js';
22
import { AddDiv, ClearDomElement } from '../engine/viewer/domutils.js';
33
import { AddSvgIconElement, IsDarkTextNeededForColor } from './utils.js';
4+
import { Loc } from '../engine/core/localization.js';
45

56
import * as THREE from 'three';
67
import { ColorComponentToFloat, RGBColor } from '../engine/model/color.js';
@@ -231,9 +232,9 @@ export class MeasureTool
231232
this.panel.style.backgroundColor = 'transparent';
232233
}
233234
if (this.markers.length === 0) {
234-
this.panel.innerHTML = 'Select a point.';
235+
this.panel.innerHTML = Loc ('Select a point.');
235236
} else if (this.markers.length === 1) {
236-
this.panel.innerHTML = 'Select another point.';
237+
this.panel.innerHTML = Loc ('Select another point.');
237238
} else {
238239
let calcResult = CalculateMarkerValues (this.markers[0], this.markers[1]);
239240

source/website/navigatorfilespanel.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { SetDomElementHeight, GetDomElementOuterHeight } from '../engine/viewer/domutils.js';
22
import { NavigatorPanel } from './navigatorpanel.js';
33
import { TreeViewButton, TreeViewButtonItem, TreeViewGroupItem, TreeViewSingleItem } from './treeview.js';
4+
import { Loc } from '../engine/core/localization.js';
45

56
export class NavigatorFilesPanel extends NavigatorPanel
67
{
@@ -11,7 +12,7 @@ export class NavigatorFilesPanel extends NavigatorPanel
1112

1213
GetName ()
1314
{
14-
return 'Files';
15+
return Loc ('Files');
1516
}
1617

1718
GetIcon ()
@@ -38,7 +39,7 @@ export class NavigatorFilesPanel extends NavigatorPanel
3839
const missingFiles = importResult.missingFiles;
3940

4041
if (missingFiles.length > 0) {
41-
let missingFilesItem = new TreeViewGroupItem ('Missing Files', null);
42+
let missingFilesItem = new TreeViewGroupItem (Loc ('Missing Files'), null);
4243
missingFilesItem.ShowChildren (true);
4344
this.treeView.AddChild (missingFilesItem);
4445
for (let i = 0; i < missingFiles.length; i++) {
@@ -51,7 +52,7 @@ export class NavigatorFilesPanel extends NavigatorPanel
5152
item.AppendButton (browseButton);
5253
missingFilesItem.AddChild (item);
5354
}
54-
let filesItem = new TreeViewGroupItem ('Available Files', null);
55+
let filesItem = new TreeViewGroupItem (Loc ('Available Files'), null);
5556
filesItem.ShowChildren (true);
5657
this.treeView.AddChild (filesItem);
5758
for (let i = 0; i < usedFiles.length; i++) {

source/website/navigatormaterialspanel.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CalculatePopupPositionToElementBottomRight, ShowListPopup } from './dia
33
import { MaterialItem } from './navigatoritems.js';
44
import { NavigatorPanel, NavigatorPopupButton } from './navigatorpanel.js';
55
import { GetMaterialName, GetMeshName } from './utils.js';
6+
import { Loc, FLoc } from '../engine/core/localization.js';
67

78
class NavigatorMeshesPopupButton extends NavigatorPopupButton
89
{
@@ -19,7 +20,7 @@ class NavigatorMeshesPopupButton extends NavigatorPopupButton
1920
return;
2021
}
2122

22-
let meshesText = 'Meshes (' + this.meshInstanceArray.length + ')';
23+
let meshesText = FLoc ('Meshes ({0})', this.meshInstanceArray.length);
2324
this.buttonText.innerHTML = meshesText;
2425
}
2526

@@ -74,7 +75,7 @@ export class NavigatorMaterialsPanel extends NavigatorPanel
7475

7576
GetName ()
7677
{
77-
return 'Materials';
78+
return Loc ('Materials');
7879
}
7980

8081
GetIcon ()

source/website/navigatormeshespanel.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { CalculatePopupPositionToElementBottomRight, ShowListPopup } from './dia
44
import { MeshItem, NavigatorItemRecurse, NodeItem } from './navigatoritems.js';
55
import { NavigatorPanel, NavigatorPopupButton } from './navigatorpanel.js';
66
import { AddSvgIconElement, GetMaterialName, GetMeshName, GetNodeName, SetSvgIconImageElement } from './utils.js';
7+
import { Loc, FLoc } from '../engine/core/localization.js';
78

89
const MeshesPanelMode =
910
{
@@ -27,7 +28,7 @@ class NavigatorMaterialsPopupButton extends NavigatorPopupButton
2728
return;
2829
}
2930

30-
let materialsText = 'Materials (' + this.materialInfoArray.length + ')';
31+
let materialsText = FLoc ('Materials ({0})', this.materialInfoArray.length);
3132
this.buttonText.innerHTML = materialsText;
3233
}
3334

@@ -86,7 +87,7 @@ export class NavigatorMeshesPanel extends NavigatorPanel
8687

8788
GetName ()
8889
{
89-
return 'Meshes';
90+
return Loc ('Meshes');
9091
}
9192

9293
GetIcon ()
@@ -228,38 +229,38 @@ export class NavigatorMeshesPanel extends NavigatorPanel
228229

229230
this.buttons = {
230231
flatList : {
231-
name : 'Flat list',
232+
name : Loc ('Flat list'),
232233
icon : 'flat_list',
233234
div : null,
234235
iconDiv : null
235236
},
236237
treeView : {
237-
name : 'Tree view',
238+
name : Loc ('Tree view'),
238239
icon : 'tree_view',
239240
div : null,
240241
iconDiv : null
241242
},
242243
separator : null,
243244
expandAll : {
244-
name : 'Expand all',
245+
name : Loc ('Expand all'),
245246
icon : 'expand',
246247
div : null,
247248
iconDiv : null
248249
},
249250
collapseAll : {
250-
name : 'Collapse all',
251+
name : Loc ('Collapse all'),
251252
icon : 'collapse',
252253
div : null,
253254
iconDiv : null
254255
},
255256
showHideMeshes : {
256-
name : 'Show/hide meshes',
257+
name : Loc ('Show/hide meshes'),
257258
icon : 'visible',
258259
div : null,
259260
iconDiv : null
260261
},
261262
fitToWindow : {
262-
name : 'Fit meshes to window',
263+
name : Loc ('Fit meshes to window'),
263264
icon : 'fit',
264265
div : null,
265266
iconDiv : null

source/website/openurldialog.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import { ReadLines } from '../engine/import/importerutils.js';
22
import { AddDiv, CreateDomElement } from '../engine/viewer/domutils.js';
33
import { ButtonDialog } from './dialog.js';
4+
import { Loc } from '../engine/core/localization.js';
45

56
export function ShowOpenUrlDialog (onOk)
67
{
78
let dialog = new ButtonDialog ();
89
let urlsTextArea = CreateDomElement ('textarea', 'ov_dialog_textarea');
9-
let contentDiv = dialog.Init ('Open from url', [
10+
let contentDiv = dialog.Init (Loc ('Open from url'), [
1011
{
11-
name : 'Cancel',
12+
name : Loc ('Cancel'),
1213
subClass : 'outline',
1314
onClick () {
1415
dialog.Close ();
1516
}
1617
},
1718
{
18-
name : 'OK',
19+
name : Loc ('OK'),
1920
onClick () {
2021
let urls = [];
2122
ReadLines (urlsTextArea.value, (line) => {
@@ -26,7 +27,7 @@ export function ShowOpenUrlDialog (onOk)
2627
}
2728
}
2829
]);
29-
let text = 'Here you can load models based on their urls. You can add more lines if your model builds up from multiple files.';
30+
let text = Loc ('Here you can load models based on their urls. You can add more lines if your model builds up from multiple files.');
3031
AddDiv (contentDiv, 'ov_dialog_section', text);
3132
contentDiv.appendChild (urlsTextArea);
3233
dialog.Open ();

source/website/sharingdialog.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ShowMessageDialog } from './dialogs.js';
66
import { ButtonDialog } from './dialog.js';
77
import { CopyToClipboard } from './utils.js';
88
import { HandleEvent } from './eventhandler.js';
9+
import { Loc } from '../engine/core/localization.js';
910

1011
export function ShowSharingDialog (fileList, settings, viewer)
1112
{
@@ -19,8 +20,8 @@ export function ShowSharingDialog (fileList, settings, viewer)
1920

2021
function AddCopyableTextInput (parentDiv, getText)
2122
{
22-
let copyText = 'Copy';
23-
let copiedText = 'Copied';
23+
let copyText = Loc ('Copy');
24+
let copiedText = Loc ('Copied');
2425
let container = AddDiv (parentDiv, 'ov_dialog_copyable_input');
2526
let input = AddDomElement (container, 'input', null);
2627
input.setAttribute ('type', 'text');
@@ -47,7 +48,7 @@ export function ShowSharingDialog (fileList, settings, viewer)
4748
}
4849

4950
let section = AddDiv (parentDiv, 'ov_dialog_section');
50-
AddDiv (section, 'ov_dialog_inner_title', 'Sharing Link');
51+
AddDiv (section, 'ov_dialog_inner_title', Loc ('Sharing Link'));
5152
let sharingLinkInput = AddCopyableTextInput (section, () => {
5253
HandleEvent ('model_shared', 'sharing_link');
5354
return GetSharingLink (modelFiles);
@@ -88,13 +89,13 @@ export function ShowSharingDialog (fileList, settings, viewer)
8889
let useCurrentSettings = true;
8990
let section = AddDiv (parentDiv, 'ov_dialog_section');
9091
section.style.marginTop = '20px';
91-
AddDiv (section, 'ov_dialog_inner_title', 'Embedding Code');
92+
AddDiv (section, 'ov_dialog_inner_title', Loc ('Embedding Code'));
9293
let optionsSection = AddDiv (section, 'ov_dialog_section');
9394
let embeddingCodeInput = AddCopyableTextInput (section, () => {
9495
HandleEvent ('model_shared', 'embedding_code');
9596
return GetEmbeddingCode (modelFiles, useCurrentSettings, settings, viewer);
9697
});
97-
AddCheckboxLine (optionsSection, 'Use customized settings', 'embed_current_settings', (checked) => {
98+
AddCheckboxLine (optionsSection, Loc ('Use customized settings', 'embed_current_settings'), (checked) => {
9899
useCurrentSettings = checked;
99100
embeddingCodeInput.value = GetEmbeddingCode (modelFiles, useCurrentSettings, settings, viewer);
100101
});
@@ -104,8 +105,8 @@ export function ShowSharingDialog (fileList, settings, viewer)
104105

105106
if (!fileList.IsOnlyUrlSource ()) {
106107
return ShowMessageDialog (
107-
'Sharing Failed',
108-
'Sharing works only if you load files by url. Please upload your model files to a web server, open them by url, and try embedding again.',
108+
Loc ('Sharing Failed'),
109+
Loc ('Sharing works only if you load files by url. Please upload your model files to a web server, open them by url, and try embedding again.'),
109110
null
110111
);
111112
}
@@ -120,9 +121,9 @@ export function ShowSharingDialog (fileList, settings, viewer)
120121
}
121122

122123
let dialog = new ButtonDialog ();
123-
let contentDiv = dialog.Init ('Share', [
124+
let contentDiv = dialog.Init (Loc ('Share'), [
124125
{
125-
name : 'Close',
126+
name : Loc ('Close'),
126127
onClick () {
127128
dialog.Close ();
128129
}

0 commit comments

Comments
 (0)