예제 #1
0
        /// <summary>
        /// The get text, with a Specific Language.
        /// </summary>
        /// <param name="page">
        /// The page.
        /// </param>
        /// <param name="tag">
        /// The tag.
        /// </param>
        /// <param name="languageFile">
        /// The Language file
        /// </param>
        /// <returns>
        /// The get text.
        /// </returns>
        public string GetText([NotNull] string page, [NotNull] string tag, [NotNull] string languageFile)
        {
            string localizedText;

            if (languageFile.IsSet())
            {
                var localization = new YafLocalization();
                localization.LoadTranslation(languageFile);
                localizedText = localization.GetText(page, tag);
            }
            else
            {
                localizedText = this.GetLocalizedTextInternal(page, tag);
            }

            if (localizedText == null)
            {
#if !DEBUG
                string filename;

                if (languageFile.IsSet())
                {
                    filename = languageFile;
                }
                else
                {
                    if (YafContext.Current.PageIsNull() || YafContext.Current.LanguageFile == string.Empty ||
                        YafContext.Current.LanguageFile == string.Empty ||
                        !YafContext.Current.Get <YafBoardSettings>().AllowUserLanguage)
                    {
                        filename = YafContext.Current.Get <YafBoardSettings>().Language;
                    }
                    else
                    {
                        filename = YafContext.Current.LanguageFile;
                    }
                }


                if (filename == string.Empty)
                {
                    filename = "english.xml";
                }

                HttpContext.Current.Cache.Remove("Localizer." + filename);
#endif
                YafContext.Current.Get <ILogger>()
                .Log(
                    YafContext.Current.PageUserID,
                    $"{page.ToLower()}.ascx",
                    $"Missing Translation For {page.ToUpper()}.{tag.ToUpper()}");

                return(string.Format("[{1}.{0}]", tag.ToUpper(), page.ToUpper()));
            }

            localizedText = localizedText.Replace("[b]", "<b>");
            localizedText = localizedText.Replace("[/b]", "</b>");

            return(localizedText);
        }
예제 #2
0
    /// <summary>
    /// The get text, with a Specific Language.
    /// </summary>
    /// <param name="page">
    /// The page.
    /// </param>
    /// <param name="tag">
    /// The tag.
    /// </param>
    /// <param name="languageFile">
    /// The Language file
    /// </param>
    /// <returns>
    /// The get text.
    /// </returns>
    public string GetText([NotNull] string page, [NotNull] string tag, [NotNull] string languageFile)
    {
      string localizedText;

      if (!string.IsNullOrEmpty(languageFile))
      {
        var localization = new YafLocalization();
        localization.LoadTranslation(languageFile);
        localizedText = localization.GetText(page, tag);
      }
      else
      {
        localizedText = this.GetLocalizedTextInternal(page, tag);
      }

      if (localizedText == null)
      {
#if !DEBUG
            string filename;

            if (!string.IsNullOrEmpty(languageFile))
            {
                filename = languageFile;
            }
            else
            {
                if (YafContext.Current.PageIsNull() ||
                 YafContext.Current.LanguageFile == string.Empty ||
                 YafContext.Current.LanguageFile == string.Empty ||
                 !YafContext.Current.Get<YafBoardSettings>().AllowUserLanguage)
                {
                    filename = YafContext.Current.Get<YafBoardSettings>().Language;
                }
                else
                {
                    filename = YafContext.Current.LanguageFile;
                }
            }
            

            if (filename == string.Empty) filename = "english.xml";

            HttpContext.Current.Cache.Remove("Localizer." + filename);
#endif
          YafContext.Current.Get<ILogger>()
                    .Log(
                        YafContext.Current.PageUserID,
                        page.ToLower() + ".ascx",
                        "Missing Translation For {1}.{0}".FormatWith(tag.ToUpper(), page.ToUpper()),
                        EventLogTypes.Error);

        return "[{1}.{0}]".FormatWith(tag.ToUpper(), page.ToUpper());
      }

      localizedText = localizedText.Replace("[b]", "<b>");
      localizedText = localizedText.Replace("[/b]", "</b>");

      return localizedText;
    }
예제 #3
0
        /// <summary>
        /// Get all time zones.
        /// </summary>
        /// <param name="forceLanguage">
        /// The force language.
        /// </param>
        /// <returns>
        /// Returns a Data Table with all time zones.
        /// </returns>
        public static DataTable TimeZones(string forceLanguage)
        {
            var localization = new YafLocalization();
            localization.LoadTranslation(forceLanguage);

            return TimeZones(localization);
        }
예제 #4
0
        /// <summary>
        /// Reads a template from the language file
        /// </summary>
        /// <param name="templateName">
        /// The template Name.
        /// </param>
        /// <param name="templateLanguageFile">
        /// The template Language File.
        /// </param>
        /// <returns>
        /// The template
        /// </returns>
        private string ReadTemplate(string templateName, string templateLanguageFile)
        {
            if (!templateName.IsSet())
            {
                return null;
            }

            if (!templateLanguageFile.IsSet())
            {
                return this.Get<ILocalization>().GetText("TEMPLATES", templateName);
            }

            var localization = new YafLocalization();
            localization.LoadTranslation(templateLanguageFile);
            return localization.GetText("TEMPLATES", templateName);
        }
예제 #5
0
        /// <summary>
        /// Gets all country names list(localized).
        /// </summary>
        /// <param name="forceLanguage">
        /// The force a specific language.
        /// </param>
        /// <returns>
        /// Returns a Data Table with all country names list(localized)
        /// </returns>
        public static DataTable Country(string forceLanguage)
        {
            var localization = new YafLocalization();
            localization.LoadTranslation(forceLanguage);

            return Country(localization);
        }