I like the idea of this node module. But i get error when i have "Res.resx", "Res.en-us.resx", "Res.fr.resx" in asp.net Core. Culture are get on each request, not at build.
It will be nice to be able to chose from different output model:
- Default (Render all language with class error when myresource.fr.resx exist)
- Model Only (Render a simple class without any value, will be filled when the page load)
like interface IMyRess
- Implementation of culture on the client side.
ModelOnly:
the model will be filled by the user, with a helper ex: <script>App.Ressources.MyRess.MyValue = "Ma valleur";</script>
ClientSide:
Generate a Model with a method inside to load it with the culture, ex : App.MyRess .Load('fr');
something like this:
resxToTypeScript.execute('App.Ressources', paths.InjectableModuleRessourcesResx, paths.InjectableModuleRessourcesTS, 'en');//"en" is the default culture
module App.Ressources {
export class MyRess {
//en is the default culture
public static AvaliableLanguage: string[] = ["en", "fr", "en-us"];
public static CurrentCulture: string;
public static GetResource(culture?: string): IMyRess {
if (this.CurrentCulture == null)
this.CurrentCulture = navigator.language || navigator["userLanguage"]; //Not really sure about this one
if (culture == null)
culture = this.CurrentCulture;
switch (culture) {
case "en-us":
return this.Culture_en_us();
case "fr":
return this.Culture_fr();
case "en":
default:
return this.Culture_en();
}
}
public static Culture_fr(): IMyRess
{
return {
MyValue: "Ma valeur"
};
}
public static Culture_en(): IMyRess {
return {
MyValue: "My value"
};
}
public static Culture_en_us(): IMyRess {
return {
MyValue: "My value"
};
}
}
export interface IMyRess {
MyValue: string;
}
}
I like the idea of this node module. But i get error when i have "Res.resx", "Res.en-us.resx", "Res.fr.resx" in asp.net Core. Culture are get on each request, not at build.
It will be nice to be able to chose from different output model:
like interface IMyRess
ModelOnly:
the model will be filled by the user, with a helper ex: <script>App.Ressources.MyRess.MyValue = "Ma valleur";</script>
ClientSide:
Generate a Model with a method inside to load it with the culture, ex : App.MyRess .Load('fr');
something like this:
resxToTypeScript.execute('App.Ressources', paths.InjectableModuleRessourcesResx, paths.InjectableModuleRessourcesTS, 'en');//"en" is the default culture