1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

JS: Converted/updated translation code to TS, fixed some comment counts

- Migrated translation service to TS, stripping a lot of now unused code
  along the way.
- Added test to cover translation service.
- Fixed some comment count issues, where it was not showing correct
  value. or updating, on comment create or delete.
This commit is contained in:
Dan Brown
2024-10-07 22:55:10 +01:00
parent 8b9bcc1768
commit d22413b931
8 changed files with 152 additions and 146 deletions

View File

@ -1,6 +1,6 @@
import {EventManager} from './services/events.ts';
import {HttpManager} from './services/http.ts';
import Translations from './services/translations';
import {Translator} from './services/translations.ts';
import * as componentMap from './components';
import {ComponentStore} from './services/components.ts';
@ -22,16 +22,10 @@ window.importVersioned = function importVersioned(moduleName) {
return import(importPath);
};
// Set events and http services on window
// Set events, http & translation services on window
window.$http = new HttpManager();
window.$events = new EventManager();
// Translation setup
// Creates a global function with name 'trans' to be used in the same way as the Laravel translation system
const translator = new Translations();
window.trans = translator.get.bind(translator);
window.trans_choice = translator.getPlural.bind(translator);
window.trans_plural = translator.parsePlural.bind(translator);
window.$trans = new Translator();
// Load & initialise components
window.$components = new ComponentStore();