Skip to content

Language Support #1

@werddomain

Description

@werddomain

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:

  1. Default (Render all language with class error when myresource.fr.resx exist)
  2. Model Only (Render a simple class without any value, will be filled when the page load)
    like interface IMyRess
  3. 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;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions