-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.ts
More file actions
30 lines (24 loc) · 1.13 KB
/
Copy pathindex.ts
File metadata and controls
30 lines (24 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Binder } from '@hilla/form';
import { Router } from '@vaadin/router';
import { routes, ViewRoute } from "./routes";
import { uiStore } from './stores/app-store';
import { lang } from './util/localization';
export const router = new Router(document.querySelector('#outlet'));
router.setRoutes(routes);
window.addEventListener("vaadin-router-location-changed", (e) => {
const activeRoute = router.location.route as ViewRoute;
if (activeRoute.title) {
document.title = lang.getText(uiStore.lang, activeRoute.title);
} else {
document.title = lang.getText(uiStore.lang, "main-title");
}
});
Binder.interpolateMessageCallback = (message, validator, binderNode) => {
// Try to find a translation for the specific type of validator
let key = `validationError.${validator.name}`;
// Special case for DecimalMin and DecimalMax validators to use different message based on "inclusive" property
if (['validationError.DecimalMin', 'validationError.DecimalMax'].includes(key)) {
key += (validator as any).inclusive ? '.inclusive' : '.exclusive';
}
return lang.getText(uiStore.lang, key);
};