Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support i18n #461

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 120 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"update_engine_exports": "run-python3 tools/update_engine_exports.py"
},
"devDependencies": {
"@rollup/plugin-json": "6.1.0",
"@types/node": "^20.1.0",
"esbuild": "^0.19.0",
"eslint": "^8.29.0",
Expand All @@ -76,6 +77,7 @@
"@simonwep/pickr": "1.9.0",
"draco3d": "1.5.6",
"fflate": "0.8.1",
"i18next": "23.10.1",
"occt-import-js": "0.0.21",
"rhino3dm": "8.0.1",
"three": "0.158.0",
Expand Down
4 changes: 3 additions & 1 deletion source/engine/import/importerbim.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { ColorToMaterialConverter } from './importerutils.js';
import { Property, PropertyGroup, PropertyType } from '../model/property.js';
import { Unit } from '../model/unit.js';

import { t } from '../../website/i18next.js';

export class ImporterBim extends ImporterBase
{
constructor ()
Expand Down Expand Up @@ -170,7 +172,7 @@ export class ImporterBim extends ImporterBase
}

let info = source.info;
let propertyGroup = new PropertyGroup ('Info');
let propertyGroup = new PropertyGroup (t('Info'));
AddProperty (propertyGroup, 'Guid', source.guid);
AddProperty (propertyGroup, 'Type', source.type);
for (let propertyName in info) {
Expand Down
10 changes: 6 additions & 4 deletions source/engine/import/importergltf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { Property, PropertyGroup, PropertyType } from '../model/property.js';
import { Triangle } from '../model/triangle.js';
import { ImporterBase } from './importerbase.js';

import { t } from '../../website/i18next.js';

const GltfComponentType =
{
BYTE : 5120,
Expand Down Expand Up @@ -641,7 +643,7 @@ export class ImporterGltf extends ImporterBase
}
}

this.ImportProperties (this.model, gltf.asset, 'Asset properties');
this.ImportProperties (this.model, gltf.asset, t('Asset properties'));
this.ImportScene (gltf);
}

Expand Down Expand Up @@ -809,7 +811,7 @@ export class ImporterGltf extends ImporterBase
this.ImportPrimitive (gltf, primitive, mesh);
}

this.ImportProperties (mesh, gltfMesh.extras, 'Mesh properties');
this.ImportProperties (mesh, gltfMesh.extras, t('Mesh properties'));
}

ImportPrimitive (gltf, primitive, mesh)
Expand Down Expand Up @@ -1006,7 +1008,7 @@ export class ImporterGltf extends ImporterBase
this.ImportNode (gltf, gltfNode, rootNode);
}

this.ImportProperties (this.model, scene.extras, 'Scene properties');
this.ImportProperties (this.model, scene.extras, t('Scene properties'));
}

ImportNode (gltf, gltfNode, parentNode)
Expand Down Expand Up @@ -1058,7 +1060,7 @@ export class ImporterGltf extends ImporterBase

if (gltfNode.mesh !== undefined) {
let mesh = this.model.GetMesh (gltfNode.mesh);
this.ImportProperties (mesh, gltfNode.extras, 'Node properties');
this.ImportProperties (mesh, gltfNode.extras, t('Node properties'));
node.AddMeshIndex (gltfNode.mesh);
}
}
Expand Down
4 changes: 3 additions & 1 deletion source/website/dialogs.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { AddDiv } from '../engine/viewer/domutils.js';
import { ButtonDialog, ListPopup } from './dialog.js';

import { t } from './i18next.js';

export function ShowMessageDialog (title, message, subMessage)
{
let dialog = new ButtonDialog ();
let contentDiv = dialog.Init (title, [
{
name : 'OK',
name : t('OK'),
onClick () {
dialog.Close ();
}
Expand Down
20 changes: 11 additions & 9 deletions source/website/exportdialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { DownloadArrayBufferAsFile } from './utils.js';
import { CookieGetStringVal, CookieSetStringVal } from './cookiehandler.js';
import { HandleEvent } from './eventhandler.js';

import { t } from './i18next.js';

import * as fflate from 'fflate';

function AddSelectWithCookieSave (parentElement, cookieKey, options, defaultSelectedIndex, onChange)
Expand Down Expand Up @@ -53,8 +55,8 @@ class ModelExporterUI
return AddSelectWithCookieSave (parameterValueDiv, cookieKey, values, defaultIndex);
}

this.visibleOnlySelect = AddSelectItem (parametersDiv, 'Scope', 'ov_last_scope', ['Entire Model', 'Visible Only'], 1);
this.rotationSelect = AddSelectItem (parametersDiv, 'Rotation', 'ov_last_rotation', ['No Rotation', '-90 Degrees', '90 Degrees'], 0);
this.visibleOnlySelect = AddSelectItem (parametersDiv, t('Scope'), 'ov_last_scope', [t('Entire Model'), t('Visible Only')], 1);
this.rotationSelect = AddSelectItem (parametersDiv, t('Rotation'), 'ov_last_rotation', [t('No Rotation'), t('-90 Degrees'), t('90 Degrees')], 0);
}

ExportModel (model, callbacks)
Expand All @@ -77,15 +79,15 @@ class ModelExporterUI
let exporterModel = new ExporterModel (model, settings);
if (exporterModel.MeshInstanceCount () === 0) {
ShowMessageDialog (
'Export Failed',
'The model doesn\'t contain any meshes.',
t('Export Failed'),
t('The model doesn\'t contain any meshes.'),
null
);
return;
}

let progressDialog = new ProgressDialog ();
progressDialog.Init ('Exporting Model');
progressDialog.Init (t('Exporting Model'));
progressDialog.Open ();

RunTaskAsync (() => {
Expand Down Expand Up @@ -142,24 +144,24 @@ class ExportDialog
Open (model, viewer)
{
let mainDialog = new ButtonDialog ();
let contentDiv = mainDialog.Init ('Export', [
let contentDiv = mainDialog.Init (t('Export'), [
{
name : 'Close',
name : t('Close'),
subClass : 'outline',
onClick () {
mainDialog.Close ();
}
},
{
name : 'Export',
name : t('Export'),
onClick : () => {
mainDialog.Close ();
this.ExportFormat (model, viewer);
}
}
]);

let text = 'Select the format from the list below, and adjust the settings of the selected format.';
let text = t('Select the format from the list below, and adjust the settings of the selected format.');
AddDiv (contentDiv, 'ov_dialog_section', text);

let formatRow = AddDiv (contentDiv, 'ov_dialog_row');
Expand Down
Loading