My dynamic javascript object holds all the resources (translation strings) for my app. Here's how it is structured:
var ResourceManager = (function () {
function ResourceManager() {
var currentLanguage = $('#activeLanguage').html();
this.resources = {
get Aanmelden() {
switch (currentLanguage) {
case "en-GB":
return "Register";
case "nl-NL":
return "Aanmelden";
default:
return "Aanmelden";
}
},
get AlgemeenOpslaan() {
switch (currentLanguage) {
case "en-GB":
return "Save";
case "nl-NL":
return "Opslaan";
default:
return "Opslaan";
}
}
};
}
return ResourceManager;
}());
The interesting part is that I can use intellisense to access my translations, similar to MVC functionality. Is there a way to achieve the same feature when using TypeScript? The challenge lies in being able to do:
declare class ResourceManager {
}
However, this does not offer intellisense for the methods of this class. I prefer using javascript over typescript because dynamically building a typescript file doesn't automatically compile it into the desired javascript file for the client.
Does anyone have suggestions on either utilizing a typescript resource file instead of javascript or enabling intellisense for the javascript object in other typescript files?