Ejemplo n.º 1
0
        private string Localize(Dictionary <string, string> translations)
        {
            if (!translations.ContainsKey(selectedLanguage.ToString()))
            {
                return(translations.ContainsKey("en") ? translations["en"] : "No translation");
            }

            return(translations[selectedLanguage.ToString()]);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Given the english string, and then a dictionary of localized versions of the string,
 /// return the string of the current selected language
 /// Pretty much copy&pasted from Json Assets
 /// </summary>
 /// <param name="english">the english string</param>
 /// <param name="translations">each key is a language code with the value being the translated string</param>
 /// <returns>The string of the current language if available, english as a default</returns>
 public static string Localize(string english, Dictionary <string, string> translations)
 {
     if (_selectedLanguage == LocalizedContentManager.LanguageCode.en)
     {
         return(english);
     }
     if (translations == null || !translations.ContainsKey(_selectedLanguage.ToString()))
     {
         return(english);
     }
     return(translations[_selectedLanguage.ToString()]);
 }
Ejemplo n.º 3
0
        /// <summary>Update the current context.</summary>
        /// <param name="language">The current language.</param>
        /// <param name="date">The current in-game date (if applicable).</param>
        /// <param name="weather">The current in-game weather (if applicable).</param>
        /// <param name="dayEvent">The day event (e.g. wedding or festival) occurring today (if applicable).</param>
        /// <param name="spouse">The current player's internal spouse name (if applicable).</param>
        /// <param name="seenEvents">The event IDs which the player has seen.</param>
        /// <param name="mailFlags">The mail flags set for the player.</param>
        /// <param name="friendships">The current player's friendship details.</param>
        public void Set(LocalizedContentManager.LanguageCode language, SDate date, Weather?weather, string dayEvent, string spouse, int[] seenEvents, string[] mailFlags, IEnumerable <KeyValuePair <string, Friendship> > friendships)
        {
            // optional date
            if (date != null)
            {
                this.Set(ConditionKey.Day, date.Day.ToString(CultureInfo.InvariantCulture));
                this.Set(ConditionKey.DayOfWeek, date.DayOfWeek.ToString().ToLower());
                this.Set(ConditionKey.Season, date.Season.ToLower());
            }
            else
            {
                this.Set(ConditionKey.Day);
                this.Set(ConditionKey.DayOfWeek);
                this.Set(ConditionKey.Season);
            }

            // other basic conditions
            this.Set(ConditionKey.DayEvent, dayEvent);
            this.Set(ConditionKey.HasFlag, mailFlags);
            this.Set(ConditionKey.HasSeenEvent, seenEvents?.Select(p => p.ToString()).ToArray());
            this.Set(ConditionKey.Language, language.ToString().ToLower());
            this.Set(ConditionKey.Spouse, spouse);
            this.Set(ConditionKey.Weather, weather?.ToString().ToLower());

            // NPC friendship conditions
            this.RemoveAll(ConditionType.Hearts, ConditionType.Relationship);
            if (friendships != null)
            {
                foreach (KeyValuePair <string, Friendship> friendship in friendships)
                {
                    this.Set(new ConditionKey(ConditionType.Hearts, friendship.Key), (friendship.Value.Points / NPC.friendshipPointsPerHeartLevel).ToString());
                    this.Set(new ConditionKey(ConditionType.Relationship, friendship.Key), friendship.Value.Status.ToString());
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>Update the current context.</summary>
        /// <param name="language">The current language.</param>
        /// <param name="date">The current in-game date (if applicable).</param>
        /// <param name="weather">The current in-game weather (if applicable).</param>
        public void Update(LocalizedContentManager.LanguageCode language, SDate date, Weather?weather)
        {
            // language
            this.Values[ConditionKey.Language] = language.ToString().ToLower();

            // optional date
            this.Values[ConditionKey.Day]       = date?.Day.ToString(CultureInfo.InvariantCulture);
            this.Values[ConditionKey.DayOfWeek] = date?.DayOfWeek.ToString().ToLower();
            this.Values[ConditionKey.Season]    = date?.Season.ToLower();

            // weather
            this.Values[ConditionKey.Weather] = weather?.ToString().ToLower();
        }
Ejemplo n.º 5
0
        /// <summary>Update the current context.</summary>
        /// <param name="language">The current language.</param>
        /// <param name="date">The current in-game date (if applicable).</param>
        /// <param name="weather">The current in-game weather (if applicable).</param>
        /// <param name="dayEvent">The day event (e.g. wedding or festival) occurring today (if applicable).</param>
        /// <param name="spouse">The current player's internal spouse name (if applicable).</param>
        /// <param name="seenEvents">The event IDs which the player has seen.</param>
        /// <param name="mailFlags">The mail flags set for the player.</param>
        public void Set(LocalizedContentManager.LanguageCode language, SDate date, Weather?weather, string dayEvent, string spouse, int[] seenEvents, string[] mailFlags)
        {
            // optional date
            if (date != null)
            {
                this.Set(ConditionKey.Day, date.Day.ToString(CultureInfo.InvariantCulture));
                this.Set(ConditionKey.DayOfWeek, date.DayOfWeek.ToString().ToLower());
                this.Set(ConditionKey.Season, date.Season.ToLower());
            }
            else
            {
                this.Set(ConditionKey.Day);
                this.Set(ConditionKey.DayOfWeek);
                this.Set(ConditionKey.Season);
            }

            // other conditions
            this.Set(ConditionKey.DayEvent, dayEvent);
            this.Set(ConditionKey.HasFlag, mailFlags);
            this.Set(ConditionKey.HasSeenEvent, seenEvents?.Select(p => p.ToString()).ToArray());
            this.Set(ConditionKey.Language, language.ToString().ToLower());
            this.Set(ConditionKey.Spouse, spouse);
            this.Set(ConditionKey.Weather, weather?.ToString().ToLower());
        }
Ejemplo n.º 6
0
 private Dictionary <string, string> GetTranslationsForLocale(LocalizedContentManager.LanguageCode locale)
 {
     return(locale == LocalizedContentManager.LanguageCode.en ? this._defaultTranslations : this._api.Json.ReadJson <Dictionary <string, string> >($"i18n/{locale.ToString()}.json", this._contentSource, settings => { }));
 }