diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index 9dc2649e..fdb9c690 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -110,6 +110,16 @@ True Logic.Financial.Payout.resx + + True + True + Logic.Structure.Country.resx + + + True + True + Logic.Structure.Geography.resx + True True @@ -531,6 +541,14 @@ + + ResXFileCodeGenerator + Logic.Structure.Country.Designer.cs + + + ResXFileCodeGenerator + Logic.Structure.Geography.Designer.cs + diff --git a/Logic/Resources/Logic.Structure.Country.Designer.cs b/Logic/Resources/Logic.Structure.Country.Designer.cs new file mode 100644 index 00000000..a61ee299 --- /dev/null +++ b/Logic/Resources/Logic.Structure.Country.Designer.cs @@ -0,0 +1,117 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Logic.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Logic_Structure_Country { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Logic_Structure_Country() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Swarmops.Logic.Resources.Logic.Structure.Country", typeof(Logic_Structure_Country).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Denmark. + /// + internal static string Country_DK { + get { + return ResourceManager.GetString("Country_DK", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finland. + /// + internal static string Country_FI { + get { + return ResourceManager.GetString("Country_FI", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Ghana. + /// + internal static string Country_GH { + get { + return ResourceManager.GetString("Country_GH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Netherlands. + /// + internal static string Country_NL { + get { + return ResourceManager.GetString("Country_NL", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Norway. + /// + internal static string Country_NO { + get { + return ResourceManager.GetString("Country_NO", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sweden. + /// + internal static string Country_SE { + get { + return ResourceManager.GetString("Country_SE", resourceCulture); + } + } + } +} diff --git a/Logic/Resources/Logic.Structure.Country.resx b/Logic/Resources/Logic.Structure.Country.resx new file mode 100644 index 00000000..3334ee7a --- /dev/null +++ b/Logic/Resources/Logic.Structure.Country.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Denmark + + + Finland + + + Ghana + + + Netherlands + + + Norway + + + Sweden + + \ No newline at end of file diff --git a/Logic/Resources/Logic.Structure.Geography.Designer.cs b/Logic/Resources/Logic.Structure.Geography.Designer.cs new file mode 100644 index 00000000..8639e656 --- /dev/null +++ b/Logic/Resources/Logic.Structure.Geography.Designer.cs @@ -0,0 +1,261 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Logic.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Logic_Structure_Geography { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Logic_Structure_Geography() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Swarmops.Logic.Resources.Logic.Structure.Geography", typeof(Logic_Structure_Geography).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Central Europe. + /// + internal static string CentralEurope { + get { + return ResourceManager.GetString("CentralEurope", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Eastern Europe. + /// + internal static string EasternEurope { + get { + return ResourceManager.GetString("EasternEurope", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Europe. + /// + internal static string Europe { + get { + return ResourceManager.GetString("Europe", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Microstates. + /// + internal static string Microstates { + get { + return ResourceManager.GetString("Microstates", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Nordics. + /// + internal static string Nordics { + get { + return ResourceManager.GetString("Nordics", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Nothern Europe. + /// + internal static string NorthernEurope { + get { + return ResourceManager.GetString("NorthernEurope", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Southern Europe. + /// + internal static string SouthernEurope { + get { + return ResourceManager.GetString("SouthernEurope", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to East North Central. + /// + internal static string USA_EastNorthCentral { + get { + return ResourceManager.GetString("USA_EastNorthCentral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to East South Central. + /// + internal static string USA_EastSouthCentral { + get { + return ResourceManager.GetString("USA_EastSouthCentral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mid-Atlantic. + /// + internal static string USA_MidAtlantic { + get { + return ResourceManager.GetString("USA_MidAtlantic", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Midwest. + /// + internal static string USA_Midwest { + get { + return ResourceManager.GetString("USA_Midwest", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mountain. + /// + internal static string USA_Mountain { + get { + return ResourceManager.GetString("USA_Mountain", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New England. + /// + internal static string USA_NewEngland { + get { + return ResourceManager.GetString("USA_NewEngland", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Northeast. + /// + internal static string USA_Northeast { + get { + return ResourceManager.GetString("USA_Northeast", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Pacific. + /// + internal static string USA_Pacific { + get { + return ResourceManager.GetString("USA_Pacific", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to South. + /// + internal static string USA_South { + get { + return ResourceManager.GetString("USA_South", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to South Atlantic. + /// + internal static string USA_SouthAtlantic { + get { + return ResourceManager.GetString("USA_SouthAtlantic", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to West. + /// + internal static string USA_West { + get { + return ResourceManager.GetString("USA_West", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to West North Central. + /// + internal static string USA_WestNorthCentral { + get { + return ResourceManager.GetString("USA_WestNorthCentral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to West South Central. + /// + internal static string USA_WestSouthCentral { + get { + return ResourceManager.GetString("USA_WestSouthCentral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Western Europe. + /// + internal static string WesternEurope { + get { + return ResourceManager.GetString("WesternEurope", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Global. + /// + internal static string World { + get { + return ResourceManager.GetString("World", resourceCulture); + } + } + } +} diff --git a/Site5/App_GlobalResources/GeographyNames.resx b/Logic/Resources/Logic.Structure.Geography.resx similarity index 93% rename from Site5/App_GlobalResources/GeographyNames.resx rename to Logic/Resources/Logic.Structure.Geography.resx index 5393baa1..5b5535ae 100644 --- a/Site5/App_GlobalResources/GeographyNames.resx +++ b/Logic/Resources/Logic.Structure.Geography.resx @@ -120,24 +120,6 @@ Central Europe - - Denmark - - - Finland - - - Ghana - - - Netherlands - - - Norway - - - Sweden - Eastern Europe diff --git a/Logic/Resources/SourceResourceFiles.txt b/Logic/Resources/SourceResourceFiles.txt index 858ac117..123a1d43 100644 --- a/Logic/Resources/SourceResourceFiles.txt +++ b/Logic/Resources/SourceResourceFiles.txt @@ -4,6 +4,8 @@ Logic.Communications.Transmission.NotificationPayload.resx Logic.Financial.FinancialAccount.resx Logic.Financial.FinancialTransactionTagSetTypesStock.resx Logic.Financial.Payout.resx +Logic.Structure.Country.resx +Logic.Structure.Geography.resx Logic.Swarm.DashboardTodos.resx Logic.Swarm.ParticipantTitle.resx Logic.Swarm.Position.resx diff --git a/Logic/Structure/Country.cs b/Logic/Structure/Country.cs index 74537171..f7ed04ff 100644 --- a/Logic/Structure/Country.cs +++ b/Logic/Structure/Country.cs @@ -35,6 +35,21 @@ namespace Swarmops.Logic.Structure return new Country (basic); } + public string Localized + { + get + { + string tryLocalize = Resources.Logic_Structure_Country.ResourceManager.GetString("Country_" + this.Code); + + if (string.IsNullOrEmpty (tryLocalize)) + { + return Name + "*"; // a little flag to localize + } + + return tryLocalize; + } + } + // TODO: Cache these two functions, country info doesn't change public static Country FromIdentity (int identity) diff --git a/Logic/Structure/Geography.cs b/Logic/Structure/Geography.cs index 39efe1e0..72ce3a5e 100644 --- a/Logic/Structure/Geography.cs +++ b/Logic/Structure/Geography.cs @@ -145,6 +145,18 @@ namespace Swarmops.Logic.Structure return false; } + public string Localized + { + get + { + if (Name.StartsWith("[LOC]")) + { + return Resources.Logic_Structure_Geography.ResourceManager.GetString(Name.Substring(5)); + } + return Name; + } + } + public BasicGeographyDesignation[] GetGeographyDesignations() { return SwarmDb.GetDatabaseForReading().GetGeographyDesignationsForGeographyId (Identity); diff --git a/Site5/Automation/Json-GeographiesTree.aspx.cs b/Site5/Automation/Json-GeographiesTree.aspx.cs index 9494bcf6..85ccb859 100644 --- a/Site5/Automation/Json-GeographiesTree.aspx.cs +++ b/Site5/Automation/Json-GeographiesTree.aspx.cs @@ -89,14 +89,14 @@ namespace Swarmops.Frontend.Automation Geography geography = geographyNode.Data; Country country = null; - string geoName = TestLocalization (geography.Name); + string geoName = geography.Localized; if (_countryLookup.ContainsKey (geography.Identity)) { // Special case for country nodes: "[NativeName] ([LocalizedName])", e.g. "Deutschland (Tyskland)" for Germany when in Swedish country = _countryLookup[geography.Identity]; - string localizedCountryName = GeographyNames.ResourceManager.GetString("Country_" + country.Code); + string localizedCountryName = country.Localized; string nativeCountryName = geography.Name.Split ('(')[0].Trim(); if (localizedCountryName != nativeCountryName) @@ -110,7 +110,7 @@ namespace Swarmops.Frontend.Automation } string element = string.Format ("\"id\":{0},\"text\":\"{1}\"", geography.Identity, - JsonSanitize (TestLocalization (geoName))); + JsonSanitize (geoName)); if (country != null) { @@ -133,14 +133,5 @@ namespace Swarmops.Frontend.Automation return "[" + String.Join (",", elements.ToArray()) + "]"; } - - private string TestLocalization (string name) - { - if (name.StartsWith ("[LOC]")) - { - return GeographyNames.ResourceManager.GetString (name.Substring (5)); - } - return name; - } } } \ No newline at end of file diff --git a/Site5/Controls/v5/Base/ComboGeographies.ascx.cs b/Site5/Controls/v5/Base/ComboGeographies.ascx.cs index 8eac8f16..16f4053c 100644 --- a/Site5/Controls/v5/Base/ComboGeographies.ascx.cs +++ b/Site5/Controls/v5/Base/ComboGeographies.ascx.cs @@ -18,12 +18,7 @@ namespace Swarmops.Controls.Base { ParentGeographyId = value.ParentIdentity; RootGeographyId = value.Identity; - RootGeographyName = value.Name; - - if (value.Name.StartsWith ("[LOC]")) - { - RootGeographyName = GeographyNames.ResourceManager.GetString (value.Name.Substring (5)); - } + RootGeographyName = value.Localized; } } diff --git a/Site5/Pages/v5/Ledgers/TaxForms/PayrollForms.aspx.cs b/Site5/Pages/v5/Ledgers/TaxForms/PayrollForms.aspx.cs index cce82f7e..75063879 100644 --- a/Site5/Pages/v5/Ledgers/TaxForms/PayrollForms.aspx.cs +++ b/Site5/Pages/v5/Ledgers/TaxForms/PayrollForms.aspx.cs @@ -2,6 +2,7 @@ using System.Globalization; using System.Web.UI.WebControls; using Swarmops.Logic.Security; +using Swarmops.Logic.Structure; namespace Swarmops.Frontend.Pages.v5.Ledgers.TaxForms { @@ -25,7 +26,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers.TaxForms { // TODO: DETERMINE COUNTRIES ON PAYROLL - this.DropCountries.Items.Add (new ListItem(Resources.GeographyNames.Country_SE, "SE")); + this.DropCountries.Items.Add (new ListItem(Country.FromCode ("SE").Localized, "SE")); Localize(); } diff --git a/Site5/Pages/v5/Swarm/AddPerson.aspx.cs b/Site5/Pages/v5/Swarm/AddPerson.aspx.cs index 5f6aee11..d0b1f263 100644 --- a/Site5/Pages/v5/Swarm/AddPerson.aspx.cs +++ b/Site5/Pages/v5/Swarm/AddPerson.aspx.cs @@ -49,11 +49,7 @@ namespace Swarmops.Frontend.Pages.v5.Swarm foreach (Country country in allCountries) { - string countryLocalName = GeographyNames.ResourceManager.GetString ("Country_" + country.Code); - if (string.IsNullOrEmpty (countryLocalName)) - { - countryLocalName = country.Name + "*"; // In English. Asterisk indicates resource missing. - } + string countryLocalName = country.Localized; string countryDisplay = country.Code + " " + countryLocalName; this.DropCountries.Items.Add (new ListItem (countryDisplay, country.Code)); }