示例#1
0
        private EnumTranslator InitTranslations()
        {
            DictionaryEnumTranslationSource <VehicleType> germanTranslations = new DictionaryEnumTranslationSource <VehicleType>(new CultureInfo("de"));

            germanTranslations.DefaultTranslations = new Dictionary <VehicleType, string>
            {
                { VehicleType.Bicycle, "Fahrrad" },
                { VehicleType.Car, "Auto" },
                { VehicleType.Motorbike, "Motorrad" },
                { VehicleType.Scooter, "Roller" }
            };

            germanTranslations.PluralTranslations = new Dictionary <VehicleType, string>
            {
                { VehicleType.Bicycle, "Fahrräder" },
                { VehicleType.Car, "Autos" },
                { VehicleType.Motorbike, "Motorräder" },
                { VehicleType.Scooter, "Roller" }
            };

            DictionaryEnumTranslationSource <VehicleType> englishTranslations = new DictionaryEnumTranslationSource <VehicleType>(new CultureInfo("en"));

            englishTranslations.DefaultTranslations = new Dictionary <VehicleType, string>
            {
                { VehicleType.Bicycle, "bicycle" },
                { VehicleType.Car, "car" },
                { VehicleType.Motorbike, "motorbike" },
                { VehicleType.Scooter, "scooter" }
            };

            englishTranslations.PluralTranslations = new Dictionary <VehicleType, string>
            {
                { VehicleType.Bicycle, "bicycles" },
                { VehicleType.Car, "cars" },
                { VehicleType.Motorbike, "motorbikes" },
                { VehicleType.Scooter, "scooters" }
            };

            EnumTranslator enumTranslator = new EnumTranslator();

            enumTranslator.RegisterTranslationSource(germanTranslations);
            enumTranslator.RegisterTranslationSource(englishTranslations);

            return(enumTranslator);
        }