Hi Neil,
I'm not saying that this is a good idea (for most people) or will never break (it DEFINITELY will with future developments) but you can roll your own Pub/Sub events, hook them into certain parts of the code and then listen for those events firing. This has the benefit that you place this code in the LO script (not individual pages):
// VERY simple Pub/Sub implementation modified from https://gist.github.com/addyosmani/1321768
var XENITH = (function($, X) {
var topics = {};
X.Event = function( id ) {
var callbacks,
topic = id && topics[ id ];
if ( !topic ) {
callbacks = $.Callbacks();
topic = {
publish: callbacks.fire,
subscribe: callbacks.add,
unsubscribe: callbacks.remove
};
if ( id ) topics[ id ] = topic;
}
return topic;
};
return X;
}(jQuery, XENITH || {}));
// Patch Xenith code to publish page_changed event
eval(x_changePageStep6.toString().split('').reverse().join('').replace("}", "").split('').reverse().join('') + "XENITH.Event( 'page_changed' ).publish(x_currentPage+1);\r\n}");
// Hook the new event and fire off some others that are hookable
XENITH.Event( 'page_changed' ).subscribe(function(page_no){
if (x_pageInfo[x_currentPage].built === false) {
XENITH.Event( 'page_first_loaded' ).publish(x_currentPage+1);
}
else {
XENITH.Event( 'page_reloaded' ).publish(x_currentPage+1);
}
});
// Hook our custom 'page_first_loaded' event
XENITH.Event( 'page_first_loaded' ).subscribe(function(page_no){
console.log("Page # " + page_no + " loaded for first time..." );
});
// Hook our custom 'page_reloaded' event
XENITH.Event( 'page_reloaded' ).subscribe(function(page_no){
console.log("Page # " + page_no + " was reloaded..." );
});
Ideally, future developments will automatically publish a load of 'events' at various points in the lifecycle of the LO and you would be able to subscribe to these and do something. Things like 'glossary_window_open', 'fullscreen', etc etc. None of these are hooked 'YET' in the main code but they may be in the future. In the meantime i've used function.toString() to get the javascript in a function, modify it to publish a topic and then rewrite the function. Goes without saying that you should only do this once in the lifecycle of a LO otherwise if will publish the same topic multiple times.
Example above just console logs the page number and whether the page has first loaded or reloaded... should be easy to add your translation code in there somewhere. I'll leave that as an exercise for you but if you need help then just reply here and i'll see it.
Use at your own risk!
Regards,
John