Skip to content

Commit

Permalink
Merge branch 'hotfix-0.9.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dymanoid committed Jun 25, 2018
2 parents 7ef414d + 581fe92 commit 62c8433
Show file tree
Hide file tree
Showing 14 changed files with 6,595 additions and 10,705 deletions.
16,932 changes: 6,247 additions & 10,685 deletions img/RealTime.pdn

Large diffs are not rendered by default.

Binary file modified img/RealTime_Thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions src/RealTime/Core/RealTimeMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public void OnEnabled()
Log.Info("The 'Real Time' mod has been enabled, version: " + modVersion);
config = ConfigurationProvider.LoadConfiguration();
localizationProvider = new LocalizationProvider(modPath);
LocaleManager.eventLocaleChanged += ApplyLanguage;
}

/// <summary>
Expand All @@ -60,7 +59,6 @@ public void OnDisabled()
{
Log.Info("The 'Real Time' mod has been disabled.");
ConfigurationProvider.SaveConfiguration(config);
LocaleManager.eventLocaleChanged -= ApplyLanguage;
config = null;
configUI = null;
}
Expand Down Expand Up @@ -138,10 +136,12 @@ private void ApplyLanguage()
return;
}

Log.Info($"The 'Real Time' mod changes the language to '{LocaleManager.instance.language}'.");
localizationProvider.LoadTranslation(LocaleManager.instance.language);
configUI?.Translate(localizationProvider);
core?.Translate(localizationProvider);
if (localizationProvider.LoadTranslation(LocaleManager.instance.language))
{
Log.Info($"The 'Real Time' mod changes the language to '{LocaleManager.instance.language}'.");
core?.Translate(localizationProvider);
configUI?.Translate(localizationProvider);
}
}
}
}
2 changes: 2 additions & 0 deletions src/RealTime/CustomBuildingAI/RealTimePrivateBuildingAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ internal sealed class RealTimePrivateBuildingAI
private readonly ITimeInfo timeInfo;
private readonly IToolManagerConnection toolManager;

#if !DEBUG
private uint lastConfigValue;
private double value;
#endif

public RealTimePrivateBuildingAI(RealTimeConfig config, ITimeInfo timeInfo, IToolManagerConnection toolManager)
{
Expand Down
30 changes: 23 additions & 7 deletions src/RealTime/Localization/LocalizationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ public LocalizationProvider(string rootPath)
localeStorage = Path.Combine(rootPath, LocaleFolder);
}

private enum LoadingResult
{
None,
Success,
Failure,
AlreadyLoaded
}

public string CurrentLanguage { get; private set; } = "en";

public CultureInfo CurrentCulture { get; private set; } = CultureInfo.CurrentCulture;
Expand All @@ -35,12 +43,15 @@ public string Translate(string id)
return NoLocale;
}

public void LoadTranslation(string language)
public bool LoadTranslation(string language)
{
if (!Load(language))
LoadingResult result = Load(language);
if (result == LoadingResult.Failure)
{
Load("en");
result = Load("en");
}

return result == LoadingResult.Success;
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "No security issues here")]
Expand Down Expand Up @@ -69,14 +80,19 @@ private static string GetLocaleNameFromLanguage(string language)
}
}

private bool Load(string language)
private LoadingResult Load(string language)
{
if (CurrentCulture.TwoLetterISOLanguageName == language && translation.Count != 0)
{
return LoadingResult.AlreadyLoaded;
}

translation.Clear();

string path = Path.Combine(localeStorage, language + FileExtension);
if (!File.Exists(path))
{
return false;
return LoadingResult.Failure;
}

try
Expand All @@ -101,11 +117,11 @@ private bool Load(string language)
catch
{
translation.Clear();
return false;
return LoadingResult.Failure;
}

CurrentLanguage = language;
return true;
return LoadingResult.Success;
}
}
}
48 changes: 48 additions & 0 deletions src/RealTime/Localization/Translations/es.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="es" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="1General" value="General" />
<translation id="IsWeekendEnabled" value="Enable Weekends" />
<translation id="IsWeekendEnabledTooltip" value="Cims don't go to work or school on weekends" />
<translation id="IsLunchtimeEnabled" value="Enable Lunch time" />
<translation id="IsLunchtimeEnabledTooltip" value="Cims should go out at lunch for food" />
<translation id="StopConstructionAtNight" value="Pause the building construction and upgrade at night time" />
<translation id="StopConstructionAtNightTooltip" value="The construction site workers need to sleep too" />
<translation id="ConstructionSpeed" value="Construction speed" />
<translation id="ConstructionSpeedTooltip" value="Buildings construction and upgrading speed" />

<translation id="2Quotas" value="Probabilities" />
<translation id="LunchQuota" value="Lunch probability" />
<translation id="LunchQuotaTooltip" value="The percentage of the Cims that will go out for lunch" />
<translation id="LocalBuildingSearchQuota" value="Local shopping ratio" />
<translation id="LocalBuildingSearchQuotaTooltip" value="The percentage of the population that will search for local shopping" />
<translation id="OnTimeQuota" value="On-time ratio" />
<translation id="OnTimeQuotaTooltip" value="The percentage of the Cims that will go to and leave their work or school on time" />

<translation id="3Events" value="Events" />
<translation id="EarliestHourEventStartWeekday" value="Earliest weekday event" />
<translation id="EarliestHourEventStartWeekdayTooltip" value="The earliest time when an event can start on a weekday" />
<translation id="LatestHourEventStartWeekday" value="Latest weekday event" />
<translation id="LatestHourEventStartWeekdayTooltip" value="The latest time when an event can start on a weekday" />
<translation id="EarliestHourEventStartWeekend" value="Earliest weekend event" />
<translation id="EarliestHourEventStartWeekendTooltip" value="The earliest time when an event can start on a weekend day" />
<translation id="LatestHourEventStartWeekend" value="Latest weekend event" />
<translation id="LatestHourEventStartWeekendTooltip" value="The latest time when an event can start on a weekend day" />

<translation id="4Time" value="Time" />
<translation id="MaxOvertime" value="Max. Overtime" />
<translation id="MaxOvertimeTooltip" value="The maximum overtime for the Cims - they come to work earlier or stay at work longer" />
<translation id="SchoolBegin" value="School start hour" />
<translation id="SchoolBeginTooltip" value="The school start daytime hour - the young Cims must be at school" />
<translation id="SchoolEnd" value="School end hour" />
<translation id="SchoolEndTooltip" value="The daytime hour when the young Cims return from school" />
<translation id="WorkBegin" value="Work start hour" />
<translation id="WorkBeginTooltip" value="The work start daytime hour - the adult Cims must be at work or university" />
<translation id="WorkEnd" value="Work end hour" />
<translation id="WorkEndTooltip" value="The daytime hour when the adult Cims return from work or university" />
<translation id="LunchBegin" value="Lunch begin hour" />
<translation id="LunchBeginTooltip" value="The daytime hour when the Cims go out for lunch" />
<translation id="LunchEnd" value="Lunch end hour" />
<translation id="LunchEndTooltip" value="The daytime hour when the Cims return from lunch back to work" />

</language>
48 changes: 48 additions & 0 deletions src/RealTime/Localization/Translations/fr.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="fr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="1General" value="General" />
<translation id="IsWeekendEnabled" value="Enable Weekends" />
<translation id="IsWeekendEnabledTooltip" value="Cims don't go to work or school on weekends" />
<translation id="IsLunchtimeEnabled" value="Enable Lunch time" />
<translation id="IsLunchtimeEnabledTooltip" value="Cims should go out at lunch for food" />
<translation id="StopConstructionAtNight" value="Pause the building construction and upgrade at night time" />
<translation id="StopConstructionAtNightTooltip" value="The construction site workers need to sleep too" />
<translation id="ConstructionSpeed" value="Construction speed" />
<translation id="ConstructionSpeedTooltip" value="Buildings construction and upgrading speed" />

<translation id="2Quotas" value="Probabilities" />
<translation id="LunchQuota" value="Lunch probability" />
<translation id="LunchQuotaTooltip" value="The percentage of the Cims that will go out for lunch" />
<translation id="LocalBuildingSearchQuota" value="Local shopping ratio" />
<translation id="LocalBuildingSearchQuotaTooltip" value="The percentage of the population that will search for local shopping" />
<translation id="OnTimeQuota" value="On-time ratio" />
<translation id="OnTimeQuotaTooltip" value="The percentage of the Cims that will go to and leave their work or school on time" />

<translation id="3Events" value="Events" />
<translation id="EarliestHourEventStartWeekday" value="Earliest weekday event" />
<translation id="EarliestHourEventStartWeekdayTooltip" value="The earliest time when an event can start on a weekday" />
<translation id="LatestHourEventStartWeekday" value="Latest weekday event" />
<translation id="LatestHourEventStartWeekdayTooltip" value="The latest time when an event can start on a weekday" />
<translation id="EarliestHourEventStartWeekend" value="Earliest weekend event" />
<translation id="EarliestHourEventStartWeekendTooltip" value="The earliest time when an event can start on a weekend day" />
<translation id="LatestHourEventStartWeekend" value="Latest weekend event" />
<translation id="LatestHourEventStartWeekendTooltip" value="The latest time when an event can start on a weekend day" />

<translation id="4Time" value="Time" />
<translation id="MaxOvertime" value="Max. Overtime" />
<translation id="MaxOvertimeTooltip" value="The maximum overtime for the Cims - they come to work earlier or stay at work longer" />
<translation id="SchoolBegin" value="School start hour" />
<translation id="SchoolBeginTooltip" value="The school start daytime hour - the young Cims must be at school" />
<translation id="SchoolEnd" value="School end hour" />
<translation id="SchoolEndTooltip" value="The daytime hour when the young Cims return from school" />
<translation id="WorkBegin" value="Work start hour" />
<translation id="WorkBeginTooltip" value="The work start daytime hour - the adult Cims must be at work or university" />
<translation id="WorkEnd" value="Work end hour" />
<translation id="WorkEndTooltip" value="The daytime hour when the adult Cims return from work or university" />
<translation id="LunchBegin" value="Lunch begin hour" />
<translation id="LunchBeginTooltip" value="The daytime hour when the Cims go out for lunch" />
<translation id="LunchEnd" value="Lunch end hour" />
<translation id="LunchEndTooltip" value="The daytime hour when the Cims return from lunch back to work" />

</language>
48 changes: 48 additions & 0 deletions src/RealTime/Localization/Translations/ko.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="ko" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="1General" value="General" />
<translation id="IsWeekendEnabled" value="Enable Weekends" />
<translation id="IsWeekendEnabledTooltip" value="Cims don't go to work or school on weekends" />
<translation id="IsLunchtimeEnabled" value="Enable Lunch time" />
<translation id="IsLunchtimeEnabledTooltip" value="Cims should go out at lunch for food" />
<translation id="StopConstructionAtNight" value="Pause the building construction and upgrade at night time" />
<translation id="StopConstructionAtNightTooltip" value="The construction site workers need to sleep too" />
<translation id="ConstructionSpeed" value="Construction speed" />
<translation id="ConstructionSpeedTooltip" value="Buildings construction and upgrading speed" />

<translation id="2Quotas" value="Probabilities" />
<translation id="LunchQuota" value="Lunch probability" />
<translation id="LunchQuotaTooltip" value="The percentage of the Cims that will go out for lunch" />
<translation id="LocalBuildingSearchQuota" value="Local shopping ratio" />
<translation id="LocalBuildingSearchQuotaTooltip" value="The percentage of the population that will search for local shopping" />
<translation id="OnTimeQuota" value="On-time ratio" />
<translation id="OnTimeQuotaTooltip" value="The percentage of the Cims that will go to and leave their work or school on time" />

<translation id="3Events" value="Events" />
<translation id="EarliestHourEventStartWeekday" value="Earliest weekday event" />
<translation id="EarliestHourEventStartWeekdayTooltip" value="The earliest time when an event can start on a weekday" />
<translation id="LatestHourEventStartWeekday" value="Latest weekday event" />
<translation id="LatestHourEventStartWeekdayTooltip" value="The latest time when an event can start on a weekday" />
<translation id="EarliestHourEventStartWeekend" value="Earliest weekend event" />
<translation id="EarliestHourEventStartWeekendTooltip" value="The earliest time when an event can start on a weekend day" />
<translation id="LatestHourEventStartWeekend" value="Latest weekend event" />
<translation id="LatestHourEventStartWeekendTooltip" value="The latest time when an event can start on a weekend day" />

<translation id="4Time" value="Time" />
<translation id="MaxOvertime" value="Max. Overtime" />
<translation id="MaxOvertimeTooltip" value="The maximum overtime for the Cims - they come to work earlier or stay at work longer" />
<translation id="SchoolBegin" value="School start hour" />
<translation id="SchoolBeginTooltip" value="The school start daytime hour - the young Cims must be at school" />
<translation id="SchoolEnd" value="School end hour" />
<translation id="SchoolEndTooltip" value="The daytime hour when the young Cims return from school" />
<translation id="WorkBegin" value="Work start hour" />
<translation id="WorkBeginTooltip" value="The work start daytime hour - the adult Cims must be at work or university" />
<translation id="WorkEnd" value="Work end hour" />
<translation id="WorkEndTooltip" value="The daytime hour when the adult Cims return from work or university" />
<translation id="LunchBegin" value="Lunch begin hour" />
<translation id="LunchBeginTooltip" value="The daytime hour when the Cims go out for lunch" />
<translation id="LunchEnd" value="Lunch end hour" />
<translation id="LunchEndTooltip" value="The daytime hour when the Cims return from lunch back to work" />

</language>
48 changes: 48 additions & 0 deletions src/RealTime/Localization/Translations/pl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="pl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="1General" value="General" />
<translation id="IsWeekendEnabled" value="Enable Weekends" />
<translation id="IsWeekendEnabledTooltip" value="Cims don't go to work or school on weekends" />
<translation id="IsLunchtimeEnabled" value="Enable Lunch time" />
<translation id="IsLunchtimeEnabledTooltip" value="Cims should go out at lunch for food" />
<translation id="StopConstructionAtNight" value="Pause the building construction and upgrade at night time" />
<translation id="StopConstructionAtNightTooltip" value="The construction site workers need to sleep too" />
<translation id="ConstructionSpeed" value="Construction speed" />
<translation id="ConstructionSpeedTooltip" value="Buildings construction and upgrading speed" />

<translation id="2Quotas" value="Probabilities" />
<translation id="LunchQuota" value="Lunch probability" />
<translation id="LunchQuotaTooltip" value="The percentage of the Cims that will go out for lunch" />
<translation id="LocalBuildingSearchQuota" value="Local shopping ratio" />
<translation id="LocalBuildingSearchQuotaTooltip" value="The percentage of the population that will search for local shopping" />
<translation id="OnTimeQuota" value="On-time ratio" />
<translation id="OnTimeQuotaTooltip" value="The percentage of the Cims that will go to and leave their work or school on time" />

<translation id="3Events" value="Events" />
<translation id="EarliestHourEventStartWeekday" value="Earliest weekday event" />
<translation id="EarliestHourEventStartWeekdayTooltip" value="The earliest time when an event can start on a weekday" />
<translation id="LatestHourEventStartWeekday" value="Latest weekday event" />
<translation id="LatestHourEventStartWeekdayTooltip" value="The latest time when an event can start on a weekday" />
<translation id="EarliestHourEventStartWeekend" value="Earliest weekend event" />
<translation id="EarliestHourEventStartWeekendTooltip" value="The earliest time when an event can start on a weekend day" />
<translation id="LatestHourEventStartWeekend" value="Latest weekend event" />
<translation id="LatestHourEventStartWeekendTooltip" value="The latest time when an event can start on a weekend day" />

<translation id="4Time" value="Time" />
<translation id="MaxOvertime" value="Max. Overtime" />
<translation id="MaxOvertimeTooltip" value="The maximum overtime for the Cims - they come to work earlier or stay at work longer" />
<translation id="SchoolBegin" value="School start hour" />
<translation id="SchoolBeginTooltip" value="The school start daytime hour - the young Cims must be at school" />
<translation id="SchoolEnd" value="School end hour" />
<translation id="SchoolEndTooltip" value="The daytime hour when the young Cims return from school" />
<translation id="WorkBegin" value="Work start hour" />
<translation id="WorkBeginTooltip" value="The work start daytime hour - the adult Cims must be at work or university" />
<translation id="WorkEnd" value="Work end hour" />
<translation id="WorkEndTooltip" value="The daytime hour when the adult Cims return from work or university" />
<translation id="LunchBegin" value="Lunch begin hour" />
<translation id="LunchBeginTooltip" value="The daytime hour when the Cims go out for lunch" />
<translation id="LunchEnd" value="Lunch end hour" />
<translation id="LunchEndTooltip" value="The daytime hour when the Cims return from lunch back to work" />

</language>
Loading

0 comments on commit 62c8433

Please sign in to comment.