Refactor: Moved loc for Geography, Country to Logic

This commit is contained in:
Rick Falkvinge
2015-05-02 15:18:31 +02:00
parent 539b2aafcc
commit 6e2905cb84
12 changed files with 570 additions and 42 deletions
+18
View File
@@ -110,6 +110,16 @@
<DesignTime>True</DesignTime>
<DependentUpon>Logic.Financial.Payout.resx</DependentUpon>
</Compile>
<Compile Include="Resources\Logic.Structure.Country.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Logic.Structure.Country.resx</DependentUpon>
</Compile>
<Compile Include="Resources\Logic.Structure.Geography.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Logic.Structure.Geography.resx</DependentUpon>
</Compile>
<Compile Include="Resources\Logic.Swarm.DashboardTodos.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@@ -531,6 +541,14 @@
<EmbeddedResource Include="Resources\Logic.Financial.Payout.ru-RU.resx" />
<EmbeddedResource Include="Resources\Logic.Financial.Payout.sv-SE.resx" />
<EmbeddedResource Include="Resources\Logic.Financial.Payout.zh-CN.resx" />
<EmbeddedResource Include="Resources\Logic.Structure.Country.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Logic.Structure.Country.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Logic.Structure.Geography.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Logic.Structure.Geography.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Logic.Swarm.DashboardTodos.af-ZA.resx" />
<EmbeddedResource Include="Resources\Logic.Swarm.DashboardTodos.ar-SA.resx" />
<EmbeddedResource Include="Resources\Logic.Swarm.DashboardTodos.da-DK.resx" />
+117
View File
@@ -0,0 +1,117 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Swarmops.Logic.Resources {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// 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() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[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;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Denmark.
/// </summary>
internal static string Country_DK {
get {
return ResourceManager.GetString("Country_DK", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Finland.
/// </summary>
internal static string Country_FI {
get {
return ResourceManager.GetString("Country_FI", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Ghana.
/// </summary>
internal static string Country_GH {
get {
return ResourceManager.GetString("Country_GH", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Netherlands.
/// </summary>
internal static string Country_NL {
get {
return ResourceManager.GetString("Country_NL", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Norway.
/// </summary>
internal static string Country_NO {
get {
return ResourceManager.GetString("Country_NO", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Sweden.
/// </summary>
internal static string Country_SE {
get {
return ResourceManager.GetString("Country_SE", resourceCulture);
}
}
}
}
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Country_DK" xml:space="preserve">
<value>Denmark</value>
</data>
<data name="Country_FI" xml:space="preserve">
<value>Finland</value>
</data>
<data name="Country_GH" xml:space="preserve">
<value>Ghana</value>
</data>
<data name="Country_NL" xml:space="preserve">
<value>Netherlands</value>
</data>
<data name="Country_NO" xml:space="preserve">
<value>Norway</value>
</data>
<data name="Country_SE" xml:space="preserve">
<value>Sweden</value>
</data>
</root>
+261
View File
@@ -0,0 +1,261 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Swarmops.Logic.Resources {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// 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() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[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;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Central Europe.
/// </summary>
internal static string CentralEurope {
get {
return ResourceManager.GetString("CentralEurope", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Eastern Europe.
/// </summary>
internal static string EasternEurope {
get {
return ResourceManager.GetString("EasternEurope", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Europe.
/// </summary>
internal static string Europe {
get {
return ResourceManager.GetString("Europe", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Microstates.
/// </summary>
internal static string Microstates {
get {
return ResourceManager.GetString("Microstates", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Nordics.
/// </summary>
internal static string Nordics {
get {
return ResourceManager.GetString("Nordics", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Nothern Europe.
/// </summary>
internal static string NorthernEurope {
get {
return ResourceManager.GetString("NorthernEurope", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Southern Europe.
/// </summary>
internal static string SouthernEurope {
get {
return ResourceManager.GetString("SouthernEurope", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to East North Central.
/// </summary>
internal static string USA_EastNorthCentral {
get {
return ResourceManager.GetString("USA_EastNorthCentral", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to East South Central.
/// </summary>
internal static string USA_EastSouthCentral {
get {
return ResourceManager.GetString("USA_EastSouthCentral", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Mid-Atlantic.
/// </summary>
internal static string USA_MidAtlantic {
get {
return ResourceManager.GetString("USA_MidAtlantic", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Midwest.
/// </summary>
internal static string USA_Midwest {
get {
return ResourceManager.GetString("USA_Midwest", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Mountain.
/// </summary>
internal static string USA_Mountain {
get {
return ResourceManager.GetString("USA_Mountain", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to New England.
/// </summary>
internal static string USA_NewEngland {
get {
return ResourceManager.GetString("USA_NewEngland", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Northeast.
/// </summary>
internal static string USA_Northeast {
get {
return ResourceManager.GetString("USA_Northeast", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Pacific.
/// </summary>
internal static string USA_Pacific {
get {
return ResourceManager.GetString("USA_Pacific", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to South.
/// </summary>
internal static string USA_South {
get {
return ResourceManager.GetString("USA_South", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to South Atlantic.
/// </summary>
internal static string USA_SouthAtlantic {
get {
return ResourceManager.GetString("USA_SouthAtlantic", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to West.
/// </summary>
internal static string USA_West {
get {
return ResourceManager.GetString("USA_West", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to West North Central.
/// </summary>
internal static string USA_WestNorthCentral {
get {
return ResourceManager.GetString("USA_WestNorthCentral", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to West South Central.
/// </summary>
internal static string USA_WestSouthCentral {
get {
return ResourceManager.GetString("USA_WestSouthCentral", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Western Europe.
/// </summary>
internal static string WesternEurope {
get {
return ResourceManager.GetString("WesternEurope", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Global.
/// </summary>
internal static string World {
get {
return ResourceManager.GetString("World", resourceCulture);
}
}
}
}
@@ -120,24 +120,6 @@
<data name="CentralEurope" xml:space="preserve">
<value>Central Europe</value>
</data>
<data name="Country_DK" xml:space="preserve">
<value>Denmark</value>
</data>
<data name="Country_FI" xml:space="preserve">
<value>Finland</value>
</data>
<data name="Country_GH" xml:space="preserve">
<value>Ghana</value>
</data>
<data name="Country_NL" xml:space="preserve">
<value>Netherlands</value>
</data>
<data name="Country_NO" xml:space="preserve">
<value>Norway</value>
</data>
<data name="Country_SE" xml:space="preserve">
<value>Sweden</value>
</data>
<data name="EasternEurope" xml:space="preserve">
<value>Eastern Europe</value>
</data>
+2
View File
@@ -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
+15
View File
@@ -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)
+12
View File
@@ -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);
+3 -12
View File
@@ -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;
}
}
}
@@ -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;
}
}
@@ -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();
}
+1 -5
View File
@@ -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));
}