コード例 #1
0
ファイル: User.custom.cs プロジェクト: ammoti/Generated
        partial void OnCultureValidation(ref TranslationEnum?error)
        {
            if (!Cultures.IsSupported(this.Culture))
            {
                error = TranslationEnum.ModelUserCultureBadValueOrFormat;
            }

            if (this.Culture.Length != 2)
            {
                System.Diagnostics.Debugger.Break();

                // The Culture must be 2 characters long

                error = TranslationEnum.ModelUserCultureBadValueOrFormat;
            }
        }
コード例 #2
0
        /// <summary>
        /// Retrieves the message translation from the inner cache if the entry exists.
        /// If not, use the ITranslationService service to retrieve it from the database (and stores it into the inner cache).
        /// </summary>
        ///
        /// <param name="translationKey">
        /// Translation key.
        /// </param>
        ///
        /// <param name="culture">
        /// Culture (VahapYigit.Test.Core.Cultures class).
        /// </param>
        ///
        /// <param name="args">
        /// Optional arguments to format the message.
        /// </param>
        ///
        /// <returns>
        /// The message.
        /// </returns>
        public string GetMessage(TranslationEnum translationKey, string culture, params object[] args)
        {
            string message = "N.C.";

            if (!Cultures.IsSupported(culture))
            {
                culture = Cultures.Default;
            }

            var translation = this.Resolve(translationKey);

            if (translation != null)
            {
                message = translation.Value[culture];

                if (!args.IsNullOrEmpty() && message != null)
                {
                    message = string.Format(message, args);
                }
            }

            return(message);
        }