コード例 #1
0
    public string Localize(string key, bool ignoreMissingKey = false)
    {
        string result = string.Empty;

        try{
            if (!_locDatabase.TryLocalize(key, out result))
            {
                if (ignoreMissingKey)
                {
                    if (LookupFailedSoft != null)
                    {
                        LookupFailedSoft(key, GetSelectedLanguage());
                    }
                }
                else
                {
                    this.LogError("No localization value found when trying to localize " + key);
                    if (LookupFailedHard != null)
                    {
                        LookupFailedHard(key, GetSelectedLanguage());
                    }
                }
            }
        } catch (NullReferenceException nre) {
            this.LogError(string.Format("NullReferenceException in LocalizationManager.Localize(): {0}, Stack:\n {1}", nre.Message, nre.StackTrace));
        } catch (Exception e) {
            this.LogError(string.Format("Exception in LocalizationManager.Localize(): {0}, Stack:\n {1}", e.Message, e.StackTrace));
        }

        return(result);
    }