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

Localization basics #3

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions dependencies/i18next.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<link rel="stylesheet" href="css/tabulator_midnight.css" />
<link rel="stylesheet" href="css/main.css" />

<script src="dependencies/i18next.min.js"></script>
<script src="dependencies/tree.js"></script>
<script type="importmap">
{
Expand Down
72 changes: 72 additions & 0 deletions src/localization/local-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
i18next.init({
lng : 'hu', // set the default language
resources : {
en : {
translation : {
test : 'Test',
File : 'File',
'Open TopoDroid file' : 'Open TopoDroid file',
'Open Polygon file' : 'Open Polygon file',
'Open JSON file' : 'Open JSON file',
'Export JSON' : 'Export JSON',
'Export PNG' : 'Export PNG',
Surface : 'Surface',
'Open PLY file' : 'Open PLY file',
Print : 'Print',
'Zoom to fit' : 'Zoom to fit',
'Zoom in' : 'Zoom in',
'Zoom out' : 'Zoom out',
Plan : 'Plan',
Profile : 'Profile',
'3D' : '3D',
'Bounding box' : 'Bounding box',
'Show beddings' : 'Show beddings',
'Show faults' : 'Show faults',
'Line color mode' : 'Line color mode',
'Grid position/visibility' : 'Grid position/visibility',
'Surface visibility' : 'Surface visibility',
'Locate point' : 'Locate point',
'Distance between points' : 'Distance between points',
'Edit cave sheet' : 'Edit cave sheet',
'Edit section attributes' : 'Edit section attributes',
'Edit component attributes' : 'Edit component attributes',
'Delete survey' : 'Do you want to delete survey {{survey}}?',
'Delete cave' : 'Do you want to delete cave {{cave}}?'
}
},
hu : {
translation : {
test : 'Teszt',
File : 'Fájl',
'Open TopoDroid file' : 'TopoDroid fájl megnyitása',
'Open Polygon file' : 'Polygon fájl megnyitása',
'Open JSON file' : 'JSON fájl megnyitása',
'Export JSON' : 'Export JSON',
'Export PNG' : 'Export PNG',
Surface : 'Felszín',
'Open PLY file' : 'PLY fájl megnyitása',
Print : 'Nyomtatás',
'Zoom to fit' : 'Mérethez igazítás',
'Zoom in' : 'Zoom be',
'Zoom out' : 'Zoom ki',
Plan : 'Alaprajz',
Profile : 'Hosszmetszet',
'3D' : '3D',
'Bounding box' : 'Befoglaló doboz',
'Show beddings' : 'Vetők megjelenítése',
'Show faults' : 'Hibák megjelenítése',
'Line color mode' : 'Line color mode',
'Grid position/visibility' : 'Négyzetháló pozíciója/láthatósága',
'Surface visibility' : 'Felszín láthatósága',
'Locate point' : 'Pont lokalizáció',
'Distance between points' : 'Távolság két pont között',
'Edit cave sheet' : 'Barlang adatlap szerkesztése',
'Edit section attributes' : 'Szakasz attribútumok szerkesztése',
'Edit component attributes' : 'Komponens attribútumok szerkesztése',
'Delete survey' : 'Törölni akarod az következő felmérést: {{survey}}?',
'Delete cave' : 'Törölni akarod az következő barlangot: {{cave}}?'
}
}
// Add other languages here
}
});
10 changes: 6 additions & 4 deletions src/ui/explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class ProjectExplorer {

showCaveContextMenu(cave) {
const menu = U.node`<ul class="menu-options">`;
const editCaveData = U.node`<li class="menu-option">Edit cave sheet</li>`;
const editCaveData = U.node(`<li class="menu-option">` + i18next.t('Edit cave sheet') + `</li>`);
editCaveData.onclick = () => {
this.editor = new CaveEditor(
this.db,
Expand All @@ -170,7 +170,7 @@ class ProjectExplorer {
this.contextMenuElement.style.display = 'none';
};

const editSectionAttributes = U.node`<li class="menu-option">Edit section attributes</li>`;
const editSectionAttributes = U.node(`<li class="menu-option">` + i18next.t('Edit section attributes') + `</li>`);
editSectionAttributes.onclick = () => {
this.editor = new SectionAttributeEditor(
this.db,
Expand All @@ -186,7 +186,9 @@ class ProjectExplorer {

};

const editComponentAttributes = U.node`<li class="menu-option">Edit component attributes</li>`;
const editComponentAttributes = U.node(
`<li class="menu-option">` + i18next.t('Edit component attributes') + `</li>`
);
editComponentAttributes.onclick = () => {
this.editor = new ComponentAttributeEditor(
this.db,
Expand Down Expand Up @@ -326,7 +328,7 @@ class ProjectExplorer {

} else if (event.target.id === 'delete') {
if (state.nodeType === 'survey') {
const result = confirm(`Do you want to delete survey '${state.survey.name}'?`);
const result = confirm(i18next.t('Delete survey', { survey: state.survey.name }));
if (result) {
this.db.deleteSurvey(state.cave.name, state.survey.name);
}
Expand Down
50 changes: 25 additions & 25 deletions src/ui/navbar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Exporter } from '../io/export.js';
import '../localization/local-setup.js';

class NavigationBar {

Expand All @@ -20,35 +21,35 @@ class NavigationBar {
#getMenus() {
return [
{
name : 'File',
name : i18next.t('File'),
elements : [
{
name : 'Open TopoDroid file',
name : i18next.t('Open TopoDroid file'),
click : () => {
document.getElementById('topodroidInput').click();
}
},
{
name : 'Open Polygon file',
name : i18next.t('Open Polygon file'),
click : function () {
document.getElementById('polygonInput').click();
}
},
{
name : 'Open JSON file',
name : i18next.t('Open JSON file'),
click : function () {
document.getElementById('jsonInput').click();
}
},
{ name: 'Export JSON', click: () => Exporter.exportCaves(this.db.caves) },
{ name: 'Export PNG', click: () => Exporter.exportPNG(this.scene) }
{ name: i18next.t('Export JSON'), click: () => Exporter.exportCaves(this.db.caves) },
{ name: i18next.t('Export PNG'), click: () => Exporter.exportPNG(this.scene) }
]
},
{
name : 'Surface',
name : i18next.t('Surface'),
elements : [
{
name : 'Open PLY file',
name : i18next.t('Open PLY file'),
click : function () {
document.getElementById('plyInput').click();
}
Expand All @@ -61,81 +62,80 @@ class NavigationBar {
#getIcons() {
return [
{
tooltip : 'Print',
tooltip : i18next.t('Print'),
icon : './icons/print.svg',
click : () => window.print()
},
{
tooltip : 'Zoom to fit',
tooltip : i18next.t('Zoom to fit'),
icon : './icons/zoom_fit.svg',
click : () => this.scene.fitScene(this.scene.computeBoundingBox())
},
{
tooltip : 'Zoom in',
tooltip : i18next.t('Zoom in'),
icon : './icons/zoom_in.svg',
click : () => this.scene.zoomWithStep(this.options.scene.zoomStep)
},
{
tooltip : 'Zoom out',
tooltip : i18next.t('Zoom out'),
icon : './icons/zoom_out.svg',
click : () => this.scene.zoomWithStep(-1 * this.options.scene.zoomStep)
},
{
tooltip : 'Plan',
tooltip : i18next.t('Plan'),
icon : './icons/plan.svg',
click : () => this.scene.lookAtPlan()
},
{
tooltip : 'Profile',
tooltip : i18next.t('Profile'),
icon : './icons/profile.svg',
click : () => this.scene.lookAtProfile()
},
{
tooltip : '3D',
tooltip : i18next.t('3D'),
icon : './icons/3d.svg',
click : () => this.scene.lookAt3D()
},
{
tooltip : 'Bounding box',
tooltip : i18next.t('Bounding box'),
icon : './icons/bounding_box.svg',
click : () => this.scene.toogleBoundingBox()
},
{
tooltip : 'Show beddings',
tooltip : i18next.t('Show beddings'),
icon : './icons/bedding.svg',
click : () => this.scene.tooglePlaneFor('bedding')
},
{
tooltip : 'Show faults',
tooltip : i18next.t('Show faults'),
icon : './icons/fault.svg',
click : () => this.scene.tooglePlaneFor('fault')
},
{
tooltip : 'Line color mode',
tooltip : i18next.t('Line color mode'),
icon : './icons/cl_color.svg',
click : () => this.scene.rollCenterLineColor()
},
{
tooltip : 'Grid position/visibility',
tooltip : i18next.t('Grid position/visibility'),
icon : './icons/grid.svg',
click : () => this.scene.grid.roll()
},
{
tooltip : 'Surface visibility',
tooltip : i18next.t('Surface visibility'),
icon : './icons/surface.svg',
click : () => this.scene.rollSurface()
},
{
tooltip : 'Locate point',
tooltip : i18next.t('Locate point'),
icon : './icons/locate.svg',
click : (event) => this.interactive.showLocateStationPanel(event.clientX)
click : (event) => this.interactive.showLocatePanel(event.clientX)
},
{
tooltip : 'Distance between points',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not delete this entry

tooltip : i18next.t('Distance between points'),
icon : './icons/distance.svg',
click : (event) => this.interactive.showShortestPathPanel(event.clientX)
}

];
}

Expand Down