Added localization to top-level geonames

This commit is contained in:
Rick Falkvinge
2014-10-11 20:54:37 +02:00
parent 452bc956ff
commit 7fc6b6831d
5 changed files with 166 additions and 92 deletions
@@ -0,0 +1,139 @@
<?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="EasternEurope" xml:space="preserve">
<value>Eastern Europe</value>
<comment>(East of former Iron Curtain)</comment>
</data>
<data name="Europe" xml:space="preserve">
<value>Europe</value>
</data>
<data name="Nordics" xml:space="preserve">
<value>Nordics</value>
<comment>(Finland Denmark Norway Sweden Iceland)</comment>
</data>
<data name="WesternEurope" xml:space="preserve">
<value>Western Europe</value>
<comment>(West of former Iron Curtain)</comment>
</data>
<data name="World" xml:space="preserve">
<value>World</value>
<comment>Root geography</comment>
</data>
</root>
+17 -2
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using Swarmops.Logic.Structure;
namespace Swarmops.Frontend.Automation
@@ -9,6 +10,8 @@ namespace Swarmops.Frontend.Automation
{
protected void Page_Load(object sender, EventArgs e)
{
GetAuthenticationDataAndCulture();
Response.ContentType = "application/json";
int rootGeographyId = Geography.RootIdentity;
@@ -23,7 +26,7 @@ namespace Swarmops.Frontend.Automation
// Is this stuff in cache already?
string cacheKey = "Geographies-Json-" + rootGeographyId.ToString(CultureInfo.InvariantCulture);
string cacheKey = "Geographies-Json-" + rootGeographyId.ToString(CultureInfo.InvariantCulture) + "-" + Thread.CurrentThread.CurrentCulture.Name;
string accountsJson =
(string) Cache[cacheKey];
@@ -75,7 +78,7 @@ namespace Swarmops.Frontend.Automation
foreach (Geography geography in treeMap[node])
{
string element = string.Format("\"id\":{0},\"text\":\"{1}\"", geography.Identity,
JsonSanitize(geography.Name));
JsonSanitize(TestLocalization(geography.Name)));
if (treeMap.ContainsKey(geography.Identity))
{
@@ -88,5 +91,17 @@ namespace Swarmops.Frontend.Automation
return "[" + String.Join(",", elements.ToArray()) + "]";
}
private string TestLocalization(string name)
{
if (name.StartsWith("[LOC]"))
{
return Resources.GeographyNames.ResourceManager.GetString(name.Substring(5));
}
else
{
return name;
}
}
}
}
@@ -20,7 +20,12 @@ namespace Swarmops.Controls.Base
set
{
this.RootGeographyId = value.Identity;
RootGeographyName = value.Name;
RootGeographyName = value.Name;
if (value.Name.StartsWith("[LOC]"))
{
RootGeographyName = Resources.GeographyNames.ResourceManager.GetString(value.Name.Substring(5));
}
}
}
}
+3 -88
View File
@@ -14,93 +14,10 @@
<script type="text/javascript">
$(document).ready(function () {
<asp:Repeater ID="RepeaterTagDropScript" runat="server"><ItemTemplate>
$('#DropTags<%# Eval("TagSetId") %>').combotree({
animate: true,
height: 30
});
$('#SpanDropTags<%# Eval("TagSetId") %> span.combo input.combo-text').click(function () {
$('#SpanDropTags<%# Eval("TagSetId") %> span.combo span span.combo-arrow').click();
});
</ItemTemplate></asp:Repeater>
});
function validateFields() {
var isValid = true;
isValid = validateTextField('#<%=this.TextAccount.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorBankAccount" />") && isValid;
isValid = validateTextField('#<%=this.TextClearing.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorBankClearing" />") && isValid;
isValid = validateTextField('#<%=this.TextBank.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorBankName" />") && isValid;
if ($('#<%=this.ComboBudgets.ClientID %>_DropBudgets').combotree('tree').tree('getSelected') == null) {
isValid = false;
$('#<%=this.ComboBudgets.ClientID %>_SpanBudgets').addClass("entryError");
alertify.error("<asp:Literal runat="server" ID="LiteralErrorBudget" />");
}
<asp:Repeater ID="RepeaterErrorCheckTags" runat="server"><ItemTemplate>
if ($('#DropTags<%# Eval("TagSetId") %>').combotree('tree').tree('getSelected') == null) {
isValid = false;
$('#SpanDropTags<%# Eval("TagSetId") %>').addClass("entryError");
alertify.error('<%=Resources.Pages.Financial.FileExpenseClaim_ValidationError_MissingTag.Replace("'", "''") %>');
}
</ItemTemplate></asp:Repeater>
isValid = validateTextField('#<%=this.TextPurpose.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorPurpose" />") && isValid;
$.ajax({
type: "POST",
url: "/Automation/FieldValidation.asmx/IsAmountValid",
data: "{'amount': '" + escape($('#<%=this.TextAmount.ClientID %>').val()) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false, // blocks until function returns - race conditions otherwise
success: function (msg) {
if (msg.d != true) {
isValid = false;
$('#TextAmount').addClass("entryError");
alertify.error("<asp:Literal runat="server" ID="LiteralErrorAmount" />");
$('#<%=this.TextAmount.ClientID %>').focus();
}
}
});
$.ajax({
type: "POST",
url: "/Automation/FieldValidation.asmx/AreDocumentsUploaded",
data: "{'guidString': '<%=this.FileUpload.GuidString %>'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false, // blocks until function returns - race conditions otherwise
success: function (msg) {
if (msg.d != true) {
isValid = false;
$('#TextAmount').addClass("entryError");
alertify.error("<asp:Literal runat="server" ID="LiteralErrorDocuments" />");
}
}
});
return isValid;
}
function validateTextField (fieldId, message) {
if ($(fieldId).val().length == 0) {
alertify.error(message);
$(fieldId).addClass("entryError");
$(fieldId).focus();
return false;
}
return true;
}
</script>
@@ -108,12 +25,10 @@
<asp:Content ID="Content5" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<asp:HiddenField ID="HiddenTagSetIdentifiers" runat="server"/>
<div class="entryFields">
<asp:TextBox runat="server" ID="TextAmount" CssClass="alignRight" />&#8203;<br/>
<asp:TextBox runat="server" ID="TextPurpose" />&#8203;<br/>
<Swarmops5:ComboBudgets ID="ComboBudgets" runat="server" />&nbsp;<br/>
<asp:Repeater ID="RepeaterTagDrop" runat="server"><ItemTemplate><span id="SpanDropTags<%# Eval("TagSetId") %>"><select class="easyui-combotree" url="/Automation/Json-TransactionTagsTree.aspx?TagSetId=<%# Eval("TagSetId") %>" name="DropTags<%# Eval("TagSetId") %>" id="DropTags<%# Eval("TagSetId") %>" animate="true" style="width:300px"></select></span>&nbsp;<br/></ItemTemplate></asp:Repeater>
<asp:TextBox runat="server" ID="TextOrganizationName" />&#8203;<br/>
<asp:DropDownList runat="server" ID="DropCurrencies"/>
<asp:DropDownList runat="server" ID="DropPeopleLabel" />
&nbsp;<br/><!-- placeholder for label-side H2 -->
+1 -1
View File
@@ -389,7 +389,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
// Initialize the root geography (which becomes #1 if everything works)
int rootGeographyId = SwarmDb.GetDatabaseForWriting().CreateGeography("World", 0);
int rootGeographyId = SwarmDb.GetDatabaseForWriting().CreateGeography("[LOC]World", 0);
// Get the list of countries