80 changed files with 1535 additions and 2157 deletions
@ -0,0 +1,225 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: trubra |
||||||
|
* Date: 2014-01-28 |
||||||
|
* Time: 10:09 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Collections.ObjectModel; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Windows; |
||||||
|
using System.Linq; |
||||||
|
using ICSharpCode.WpfDesign.Designer.Xaml; |
||||||
|
using ICSharpCode.WpfDesign.XamlDom; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.Designer.OutlineView |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of OutlineNodeBase.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class OutlineNodeBase : INotifyPropertyChanged, IOutlineNode |
||||||
|
{ |
||||||
|
|
||||||
|
protected abstract void UpdateChildren(); |
||||||
|
//Used to check if element can enter other containers
|
||||||
|
protected static PlacementType DummyPlacementType; |
||||||
|
|
||||||
|
protected OutlineNodeBase(DesignItem designItem) |
||||||
|
{ |
||||||
|
DesignItem = designItem; |
||||||
|
|
||||||
|
|
||||||
|
var hidden = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance; |
||||||
|
if (hidden != null && (bool)hidden) { |
||||||
|
_isDesignTimeVisible = false; |
||||||
|
((FrameworkElement)DesignItem.Component).Visibility = Visibility.Hidden; |
||||||
|
} |
||||||
|
|
||||||
|
var locked = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance; |
||||||
|
if (locked != null && (bool)locked) { |
||||||
|
_isDesignTimeLocked = true; |
||||||
|
} |
||||||
|
|
||||||
|
//TODO
|
||||||
|
|
||||||
|
DesignItem.NameChanged += new EventHandler(DesignItem_NameChanged); |
||||||
|
DesignItem.PropertyChanged += new PropertyChangedEventHandler(DesignItem_PropertyChanged); |
||||||
|
} |
||||||
|
|
||||||
|
public DesignItem DesignItem { get; set; } |
||||||
|
|
||||||
|
public ISelectionService SelectionService |
||||||
|
{ |
||||||
|
get { return DesignItem.Services.Selection; } |
||||||
|
} |
||||||
|
|
||||||
|
bool isExpanded = true; |
||||||
|
|
||||||
|
public bool IsExpanded |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return isExpanded; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
isExpanded = value; |
||||||
|
RaisePropertyChanged("IsExpanded"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
bool isSelected; |
||||||
|
|
||||||
|
public bool IsSelected |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return isSelected; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
if (isSelected != value) { |
||||||
|
isSelected = value; |
||||||
|
SelectionService.SetSelectedComponents(new[] { DesignItem }, |
||||||
|
value ? SelectionTypes.Add : SelectionTypes.Remove); |
||||||
|
RaisePropertyChanged("IsSelected"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
bool _isDesignTimeVisible = true; |
||||||
|
|
||||||
|
public bool IsDesignTimeVisible |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return _isDesignTimeVisible; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
_isDesignTimeVisible = value; |
||||||
|
var ctl = DesignItem.Component as UIElement; |
||||||
|
if(ctl!=null) |
||||||
|
ctl.Visibility = _isDesignTimeVisible ? Visibility.Visible : Visibility.Hidden; |
||||||
|
|
||||||
|
RaisePropertyChanged("IsDesignTimeVisible"); |
||||||
|
|
||||||
|
if (!value) |
||||||
|
DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).SetValue(true); |
||||||
|
else |
||||||
|
DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).Reset(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
bool _isDesignTimeLocked = false; |
||||||
|
|
||||||
|
public bool IsDesignTimeLocked |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return _isDesignTimeLocked; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
_isDesignTimeLocked = value; |
||||||
|
((XamlDesignItem)DesignItem).IsDesignTimeLocked = _isDesignTimeLocked; |
||||||
|
|
||||||
|
RaisePropertyChanged("IsDesignTimeLocked"); |
||||||
|
|
||||||
|
// if (value)
|
||||||
|
// DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).SetValue(true);
|
||||||
|
// else
|
||||||
|
// DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).Reset();
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ObservableCollection<IOutlineNode> children = new ObservableCollection<IOutlineNode>(); |
||||||
|
|
||||||
|
public ObservableCollection<IOutlineNode> Children |
||||||
|
{ |
||||||
|
get { return children; } |
||||||
|
} |
||||||
|
|
||||||
|
public string Name |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
if (string.IsNullOrEmpty(DesignItem.Name)) { |
||||||
|
return DesignItem.ComponentType.Name; |
||||||
|
} |
||||||
|
return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void DesignItem_NameChanged(object sender, EventArgs e) |
||||||
|
{ |
||||||
|
RaisePropertyChanged("Name"); |
||||||
|
} |
||||||
|
|
||||||
|
void DesignItem_PropertyChanged(object sender, PropertyChangedEventArgs e) |
||||||
|
{ |
||||||
|
if (e.PropertyName == DesignItem.ContentPropertyName) { |
||||||
|
UpdateChildren(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public bool CanInsert(IEnumerable<IOutlineNode> nodes, IOutlineNode after, bool copy) |
||||||
|
{ |
||||||
|
var placementBehavior = DesignItem.GetBehavior<IPlacementBehavior>(); |
||||||
|
if (placementBehavior == null) |
||||||
|
return false; |
||||||
|
var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType); |
||||||
|
if (operation != null) { |
||||||
|
bool canEnter = placementBehavior.CanEnterContainer(operation, true); |
||||||
|
operation.Abort(); |
||||||
|
return canEnter; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
public virtual void Insert(IEnumerable<IOutlineNode> nodes, IOutlineNode after, bool copy) |
||||||
|
{ |
||||||
|
using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList())) |
||||||
|
{ |
||||||
|
if (copy) { |
||||||
|
nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList(); |
||||||
|
} else { |
||||||
|
foreach (var node in nodes) { |
||||||
|
node.DesignItem.Remove(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
var index = after == null ? 0 : Children.IndexOf(after) + 1; |
||||||
|
|
||||||
|
var content = DesignItem.ContentProperty; |
||||||
|
if (content.IsCollection) { |
||||||
|
foreach (var node in nodes) { |
||||||
|
content.CollectionElements.Insert(index++, node.DesignItem); |
||||||
|
} |
||||||
|
} else { |
||||||
|
content.SetValue(nodes.First().DesignItem); |
||||||
|
} |
||||||
|
moveTransaction.Commit(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#region INotifyPropertyChanged Members
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged; |
||||||
|
|
||||||
|
public void RaisePropertyChanged(string name) |
||||||
|
{ |
||||||
|
if (PropertyChanged != null) |
||||||
|
{ |
||||||
|
PropertyChanged(this, new PropertyChangedEventArgs(name)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
} |
||||||
|
} |
@ -1,32 +0,0 @@ |
|||||||
using System.Reflection; |
|
||||||
using System.Runtime.CompilerServices; |
|
||||||
|
|
||||||
// Information about this assembly is defined by the following
|
|
||||||
// attributes.
|
|
||||||
//
|
|
||||||
// change them to the information which is associated with the assembly
|
|
||||||
// you compile.
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("")] |
|
||||||
[assembly: AssemblyDescription("")] |
|
||||||
[assembly: AssemblyConfiguration("")] |
|
||||||
[assembly: AssemblyCompany("")] |
|
||||||
[assembly: AssemblyProduct("")] |
|
||||||
[assembly: AssemblyCopyright("")] |
|
||||||
[assembly: AssemblyTrademark("")] |
|
||||||
[assembly: AssemblyCulture("")] |
|
||||||
|
|
||||||
// The assembly version has following format :
|
|
||||||
//
|
|
||||||
// Major.Minor.Build.Revision
|
|
||||||
//
|
|
||||||
// You can specify all values by your own or you can build default build and revision
|
|
||||||
// numbers with the '*' character (the default):
|
|
||||||
|
|
||||||
[assembly: AssemblyVersion("2.0.0.1")] |
|
||||||
|
|
||||||
// The following attributes specify the key for the sign of your assembly. See the
|
|
||||||
// .NET Framework documentation for more information about signing.
|
|
||||||
// This is not required, if you don't want signing let these attributes like they're.
|
|
||||||
[assembly: AssemblyDelaySign(false)] |
|
||||||
[assembly: AssemblyKeyFile("")] |
|
@ -1,44 +0,0 @@ |
|||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||||
<PropertyGroup> |
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
||||||
<ProductVersion>8.0.40607</ProductVersion> |
|
||||||
<SchemaVersion>2.0</SchemaVersion> |
|
||||||
<ProjectGuid>{244dd983-dc60-42f7-9bb9-35b7b5c8b737}</ProjectGuid> |
|
||||||
<RootNamespace>NewProject</RootNamespace> |
|
||||||
<AssemblyName>LocalizationDbToResFile</AssemblyName> |
|
||||||
<OutputTarget>Exe</OutputTarget> |
|
||||||
<WarningLevel>4</WarningLevel> |
|
||||||
<NoStdLib>False</NoStdLib> |
|
||||||
<NoConfig>False</NoConfig> |
|
||||||
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
||||||
<DebugSymbols>True</DebugSymbols> |
|
||||||
<Optimize>True</Optimize> |
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
|
||||||
<OutputPath>\</OutputPath> |
|
||||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
||||||
<DebugSymbols>True</DebugSymbols> |
|
||||||
<Optimize>True</Optimize> |
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
|
||||||
<OutputPath>\</OutputPath> |
|
||||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
|
||||||
</PropertyGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Reference Include="System" /> |
|
||||||
<Reference Include="System.Data" /> |
|
||||||
<Reference Include="System.Drawing" /> |
|
||||||
<Reference Include="System.Windows.Forms" /> |
|
||||||
<Reference Include="System.Xml" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Compile Include="AssemblyInfo.cs" /> |
|
||||||
<Compile Include="Main.cs" /> |
|
||||||
</ItemGroup> |
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
|
||||||
</Project> |
|
@ -1,4 +0,0 @@ |
|||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> |
|
||||||
</Project> |
|
@ -1,120 +0,0 @@ |
|||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
// substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Data; |
|
||||||
using System.Data.OleDb; |
|
||||||
using System.IO; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Text; |
|
||||||
|
|
||||||
namespace Assemble { |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This tool is written especially for SharpDevelop to translate the
|
|
||||||
/// database that containes the localization information to resasm files.
|
|
||||||
/// Resasm compiles these files to resource files which are used for sharpdevelop.
|
|
||||||
/// </summary>
|
|
||||||
class MainClass |
|
||||||
{ |
|
||||||
static OleDbConnection myConnection; |
|
||||||
|
|
||||||
/// <remarks>
|
|
||||||
/// Open the database connection (LocalizeDb.mdb must exists
|
|
||||||
/// in the Application.StartupPath)
|
|
||||||
/// </remarks>
|
|
||||||
static void Open() |
|
||||||
{ |
|
||||||
string connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + |
|
||||||
Application.StartupPath + |
|
||||||
Path.DirectorySeparatorChar + "LocalizeDb.mdb;"; |
|
||||||
myConnection = new OleDbConnection(connection); |
|
||||||
myConnection.Open(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <remarks>
|
|
||||||
/// Parses a string, if it has " or \n sequences in it
|
|
||||||
/// and puts them into the string as backslash code sequences
|
|
||||||
/// </remarks>
|
|
||||||
static string ConvertIllegalChars(string str) |
|
||||||
{ |
|
||||||
StringBuilder newString = new StringBuilder(); |
|
||||||
for (int i = 0; i < str.Length; ++i) { |
|
||||||
switch (str[i]) { |
|
||||||
case '\r': |
|
||||||
break; |
|
||||||
case '\n': |
|
||||||
newString.Append("\\n"); |
|
||||||
break; |
|
||||||
case '"': |
|
||||||
newString.Append("\\\""); |
|
||||||
break; |
|
||||||
case '\\': |
|
||||||
newString.Append("\\\\"); |
|
||||||
break; |
|
||||||
default: |
|
||||||
newString.Append(str[i]); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
return newString.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
public static void Main(string[] args) |
|
||||||
{ |
|
||||||
Open(); |
|
||||||
string lang = "PrimaryResLangValue"; |
|
||||||
StreamWriter writer = null; |
|
||||||
|
|
||||||
// gets the /F: parameter for the filename
|
|
||||||
// gets the /T: parameter for the language to extract
|
|
||||||
foreach (string param in args) { |
|
||||||
string par = param; |
|
||||||
if (par.StartsWith("/F:")) { |
|
||||||
par = par.Substring(3); |
|
||||||
writer = new StreamWriter(par, false, new UTF8Encoding());; |
|
||||||
} |
|
||||||
if (par.StartsWith("/T:")) { |
|
||||||
par = par.Substring(3); |
|
||||||
lang = par; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// now select all database entries and write
|
|
||||||
// the resasm file (if no /F: is specified it prints to stdout)
|
|
||||||
OleDbCommand myOleDbCommand = new OleDbCommand("SELECT * FROM Localization", myConnection); |
|
||||||
OleDbDataReader reader = myOleDbCommand.ExecuteReader(); |
|
||||||
while (reader.Read()) { |
|
||||||
string val = ConvertIllegalChars(reader[lang].ToString()).Trim(); |
|
||||||
if (val.Length > 0) { |
|
||||||
string str = reader["ResourceName"].ToString() + " = \"" + val + "\""; |
|
||||||
if (writer == null) { |
|
||||||
Console.WriteLine(str); |
|
||||||
} else { |
|
||||||
writer.WriteLine(str); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
reader.Close(); |
|
||||||
if (writer != null) { |
|
||||||
writer.Close(); |
|
||||||
} |
|
||||||
myConnection.Close(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,83 +0,0 @@ |
|||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
// substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Drawing; |
|
||||||
using System.Resources; |
|
||||||
using System.IO; |
|
||||||
using System.Text; |
|
||||||
using System.Drawing.Imaging; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Runtime.Serialization.Formatters.Binary; |
|
||||||
using System.Xml; |
|
||||||
|
|
||||||
public class TranslationBuilder |
|
||||||
{ |
|
||||||
static void Assemble(string pattern) |
|
||||||
{ |
|
||||||
string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), pattern); |
|
||||||
|
|
||||||
foreach (string file in files) { |
|
||||||
if (Path.GetExtension(file).ToUpper() == ".XML") { |
|
||||||
try { |
|
||||||
XmlDocument doc = new XmlDocument(); |
|
||||||
doc.Load(file); |
|
||||||
string resfilename = "StringResources." + doc.DocumentElement.Attributes["language"].InnerText + ".resources"; |
|
||||||
ResourceWriter rw = new ResourceWriter(resfilename); |
|
||||||
|
|
||||||
foreach (XmlElement el in doc.DocumentElement.ChildNodes) { |
|
||||||
rw.AddResource(el.Attributes["name"].InnerText, |
|
||||||
el.InnerText); |
|
||||||
} |
|
||||||
|
|
||||||
rw.Generate(); |
|
||||||
rw.Close(); |
|
||||||
} catch (Exception e) { |
|
||||||
Console.WriteLine("Error while processing " + file + " :"); |
|
||||||
Console.WriteLine(e.ToString()); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static void ShowHelp() |
|
||||||
{ |
|
||||||
Console.WriteLine(".NET Translation Builder Version 0.1"); |
|
||||||
Console.WriteLine("Copyright (C) Mike Krueger 2001. Released under GPL.\n"); |
|
||||||
Console.WriteLine(" Translation Builder Options Options\n"); |
|
||||||
Console.WriteLine(" - INPUT FILES -"); |
|
||||||
Console.WriteLine("<wildcard> translates the given xml files into resource files"); |
|
||||||
} |
|
||||||
|
|
||||||
public static void Main(string[] args) |
|
||||||
{ |
|
||||||
if (args.Length == 0) { |
|
||||||
ShowHelp(); |
|
||||||
} |
|
||||||
foreach (string param in args) { |
|
||||||
string par = param.ToUpper(); |
|
||||||
if (par == "/?" || par == "/H" || par== "-?" || par == "-H" || par == "?") { |
|
||||||
ShowHelp(); |
|
||||||
return; |
|
||||||
} else { |
|
||||||
Assemble(param); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,43 +0,0 @@ |
|||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||||
<PropertyGroup> |
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
||||||
<ProductVersion>8.0.40607</ProductVersion> |
|
||||||
<SchemaVersion>2.0</SchemaVersion> |
|
||||||
<ProjectGuid>{6084d932-aafb-4335-831a-519226095ba6}</ProjectGuid> |
|
||||||
<RootNamespace>NewProject</RootNamespace> |
|
||||||
<AssemblyName>LocalizationXmlToResFile</AssemblyName> |
|
||||||
<OutputTarget>Exe</OutputTarget> |
|
||||||
<WarningLevel>4</WarningLevel> |
|
||||||
<NoStdLib>False</NoStdLib> |
|
||||||
<NoConfig>False</NoConfig> |
|
||||||
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
||||||
<DebugSymbols>True</DebugSymbols> |
|
||||||
<Optimize>True</Optimize> |
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
|
||||||
<OutputPath>..\bin\Debug\</OutputPath> |
|
||||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
||||||
<DebugSymbols>True</DebugSymbols> |
|
||||||
<Optimize>True</Optimize> |
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
|
||||||
<OutputPath>..\bin\Release\</OutputPath> |
|
||||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
|
||||||
</PropertyGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Reference Include="System" /> |
|
||||||
<Reference Include="System.Data" /> |
|
||||||
<Reference Include="System.Drawing" /> |
|
||||||
<Reference Include="System.Windows.Forms" /> |
|
||||||
<Reference Include="System.Xml" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Compile Include="LocalizationXmlToResFile.cs" /> |
|
||||||
</ItemGroup> |
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
|
||||||
</Project> |
|
@ -1,4 +0,0 @@ |
|||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> |
|
||||||
</Project> |
|
@ -0,0 +1 @@ |
|||||||
|
resget --url "http://translation.sharpdevelop.net/resources/" --format "resx" --branch 500 --targetDir "%~dp0\..\..\..\data\resources" --overwrite true |
@ -0,0 +1,4 @@ |
|||||||
|
This tool downloads the translation .resx files from the online translation database. |
||||||
|
|
||||||
|
The source code for ResGet can be found at: |
||||||
|
https://github.com/icsharpcode/ResourceFirstTranslations/tree/master/src/ResGet |
Binary file not shown.
@ -0,0 +1,26 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<configuration> |
||||||
|
<startup> |
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> |
||||||
|
</startup> |
||||||
|
<system.diagnostics> |
||||||
|
<trace autoflush="true"> |
||||||
|
<listeners> |
||||||
|
<add name="logListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="resget.log" /> |
||||||
|
<add name="consoleListener" type="System.Diagnostics.ConsoleTraceListener" /> |
||||||
|
</listeners> |
||||||
|
</trace> |
||||||
|
</system.diagnostics> |
||||||
|
<runtime> |
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
||||||
|
<dependentAssembly> |
||||||
|
<assemblyIdentity name="System.Net.Http.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> |
||||||
|
<bindingRedirect oldVersion="0.0.0.0-2.2.22.0" newVersion="2.2.22.0" /> |
||||||
|
</dependentAssembly> |
||||||
|
<dependentAssembly> |
||||||
|
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> |
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.2.22.0" newVersion="4.2.22.0" /> |
||||||
|
</dependentAssembly> |
||||||
|
</assemblyBinding> |
||||||
|
</runtime> |
||||||
|
</configuration> |
@ -1,66 +0,0 @@ |
|||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
// substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.IO; |
|
||||||
using System.Linq; |
|
||||||
using System.Xml.Linq; |
|
||||||
|
|
||||||
namespace StringResourceTool |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Description of BuildResourceFiles.
|
|
||||||
/// </summary>
|
|
||||||
public class BuildResourceFiles |
|
||||||
{ |
|
||||||
// map of languages with different name in the database
|
|
||||||
static readonly Dictionary<string, string> codeMap = new Dictionary<string, string> { |
|
||||||
{ "br", "pt-br" }, |
|
||||||
{ "cn-gb", "zh" } |
|
||||||
}; |
|
||||||
|
|
||||||
public static void Build(ResourceDatabase db, string resourceDir, Action<string> debugOutput) |
|
||||||
{ |
|
||||||
XDocument languageDefinition = XDocument.Load(Path.Combine(resourceDir, "languages/LanguageDefinition.xml")); |
|
||||||
var languageCodes = languageDefinition.Root.Elements().Select(e => e.Attribute("code").Value); |
|
||||||
|
|
||||||
foreach (LanguageTable language in db.Languages) { |
|
||||||
string databaseCode = language.LanguageName; |
|
||||||
string code = codeMap.ContainsKey(databaseCode) ? codeMap[databaseCode] : databaseCode; |
|
||||||
|
|
||||||
string filename; |
|
||||||
if (code == "en") |
|
||||||
filename = Path.Combine(resourceDir, "StringResources.resx"); |
|
||||||
else |
|
||||||
filename = Path.Combine(resourceDir, "StringResources." + code + ".resx"); |
|
||||||
if (File.Exists(filename)) { |
|
||||||
language.SaveAsResx(filename, code == "en"); |
|
||||||
} else if (language.Entries.Count > 0.5 * db.Languages[0].Entries.Count) { |
|
||||||
debugOutput("Language " + code + " is more than 50% complete but not present in resourceDir"); |
|
||||||
} |
|
||||||
|
|
||||||
if (language.Entries.Count > 0.75 * db.Languages[0].Entries.Count && !languageCodes.Contains(code)) { |
|
||||||
debugOutput("Language " + code + " is more than 75% complete but not defined in LanguageDefinition.xml"); |
|
||||||
} else if (language.Entries.Count < 0.75 * db.Languages[0].Entries.Count && languageCodes.Contains(code)) { |
|
||||||
debugOutput("Language " + code + " is less than 75% complete but defined in LanguageDefinition.xml"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,44 +0,0 @@ |
|||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
// substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Net; |
|
||||||
|
|
||||||
namespace StringResourceTool |
|
||||||
{ |
|
||||||
public class CookieAwareWebClient : WebClient |
|
||||||
{ |
|
||||||
CookieContainer container; |
|
||||||
|
|
||||||
public CookieAwareWebClient(CookieContainer container) |
|
||||||
{ |
|
||||||
if (container == null) |
|
||||||
throw new ArgumentNullException("container"); |
|
||||||
this.container = container; |
|
||||||
} |
|
||||||
|
|
||||||
protected override WebRequest GetWebRequest(Uri address) |
|
||||||
{ |
|
||||||
WebRequest request = base.GetWebRequest(address); |
|
||||||
if (request is HttpWebRequest) { |
|
||||||
(request as HttpWebRequest).CookieContainer = container; |
|
||||||
} |
|
||||||
return request; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,578 +0,0 @@ |
|||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
// substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.Drawing; |
|
||||||
using System.IO; |
|
||||||
using System.Linq; |
|
||||||
using System.Net; |
|
||||||
using System.Resources; |
|
||||||
using System.Text; |
|
||||||
using System.Text.RegularExpressions; |
|
||||||
using System.Threading; |
|
||||||
using System.Threading.Tasks; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
namespace StringResourceTool |
|
||||||
{ |
|
||||||
public class MainForm : System.Windows.Forms.Form |
|
||||||
{ |
|
||||||
public MainForm() |
|
||||||
{ |
|
||||||
//
|
|
||||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
|
||||||
//
|
|
||||||
InitializeComponent(); |
|
||||||
try { |
|
||||||
using (StreamReader r = new StreamReader("password.txt")) { |
|
||||||
userNameTextBox.Text = r.ReadLine(); |
|
||||||
passwordTextBox.Text = r.ReadLine(); |
|
||||||
} |
|
||||||
savePasswordCheckBox.Checked = true; |
|
||||||
} catch {} |
|
||||||
|
|
||||||
Dictionary<string, string> languages = new Dictionary<string, string>() { |
|
||||||
{ "cz", "Czech" }, |
|
||||||
{ "nl", "Dutch" }, |
|
||||||
{ "fr", "French" }, |
|
||||||
{ "de", "German" }, |
|
||||||
{ "it", "Italian" }, |
|
||||||
{ "pt", "Portuguese" }, |
|
||||||
{ "es", "Spanish" }, |
|
||||||
{ "se", "Swedish" }, |
|
||||||
{ "goisern", "Goiserisch" }, |
|
||||||
{ "ru", "Russian" }, |
|
||||||
{ "br", "Brazilian Portuguese" }, |
|
||||||
{ "pl", "Polish" }, |
|
||||||
{ "jp", "Japanese" }, |
|
||||||
{ "th", "Thai" }, |
|
||||||
{ "kr", "Korean" }, |
|
||||||
{ "dk", "Danish" }, |
|
||||||
{ "hu", "Hungarian" }, |
|
||||||
{ "ro", "Romanian" }, |
|
||||||
{ "cn-gb", "Chinese Simplified" }, |
|
||||||
{ "cn-big", "Chinese Traditional" }, |
|
||||||
{ "ca", "Catalan" }, |
|
||||||
{ "bg", "Bulgarian" }, |
|
||||||
{ "urdu", "Urdu" }, |
|
||||||
{ "be", "Belarusian" }, |
|
||||||
{ "el", "Greek" }, |
|
||||||
{ "tr", "Turkish" }, |
|
||||||
{ "sk", "Slovak" }, |
|
||||||
{ "lt", "Lithuanian" }, |
|
||||||
{ "he", "Hebrew" }, |
|
||||||
{ "sl", "Slovenian" }, |
|
||||||
{ "es-mx", "Spanish (Mexico)" }, |
|
||||||
{ "af", "Afrikaans" }, |
|
||||||
{ "vi", "Vietnamese" }, |
|
||||||
{ "ar", "Arabic" }, |
|
||||||
{ "no", "Norwegian" }, |
|
||||||
{ "fa", "Persian" }, |
|
||||||
{ "sr", "Serbian" }, |
|
||||||
{ "fi", "Finnish" }, |
|
||||||
{ "hr", "Croatian" }, |
|
||||||
{ "id", "Indonesian" } |
|
||||||
}; |
|
||||||
|
|
||||||
// Clear the combobox
|
|
||||||
comboBox1.DataSource = null; |
|
||||||
comboBox1.Items.Clear(); |
|
||||||
|
|
||||||
// Bind the combobox
|
|
||||||
comboBox1.DataSource = new BindingSource(languages, null); |
|
||||||
comboBox1.DisplayMember = "Value"; |
|
||||||
comboBox1.ValueMember = "Key"; |
|
||||||
} |
|
||||||
|
|
||||||
[STAThread] |
|
||||||
public static void Main(string[] args) |
|
||||||
{ |
|
||||||
if (args.Length == 3) { |
|
||||||
try { |
|
||||||
string userName, password; |
|
||||||
using (StreamReader r = new StreamReader("password.txt")) { |
|
||||||
userName = r.ReadLine(); |
|
||||||
password = r.ReadLine(); |
|
||||||
} |
|
||||||
TranslationServer server = new TranslationServer(new TextBox()); |
|
||||||
if (!server.Login(userName, password)) { |
|
||||||
MessageBox.Show("Login failed"); |
|
||||||
return; |
|
||||||
} |
|
||||||
server.AddResourceString(args[0], args[1], args[2]); |
|
||||||
MessageBox.Show("Resource string added to database on server"); |
|
||||||
return; |
|
||||||
} catch (Exception ex) { |
|
||||||
MessageBox.Show(ex.ToString()); |
|
||||||
} |
|
||||||
} |
|
||||||
Application.EnableVisualStyles(); |
|
||||||
Application.Run(new MainForm()); |
|
||||||
} |
|
||||||
|
|
||||||
#region Windows Forms Designer generated code
|
|
||||||
/// <summary>
|
|
||||||
/// This method is required for Windows Forms designer support.
|
|
||||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
|
||||||
/// not be able to load this method if it was changed manually.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent() |
|
||||||
{ |
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox(); |
|
||||||
this.comboBox1 = new System.Windows.Forms.ComboBox(); |
|
||||||
this.label3 = new System.Windows.Forms.Label(); |
|
||||||
this.deleteStringsButton = new System.Windows.Forms.Button(); |
|
||||||
this.button4 = new System.Windows.Forms.Button(); |
|
||||||
this.savePasswordCheckBox = new System.Windows.Forms.CheckBox(); |
|
||||||
this.button3 = new System.Windows.Forms.Button(); |
|
||||||
this.passwordTextBox = new System.Windows.Forms.TextBox(); |
|
||||||
this.userNameTextBox = new System.Windows.Forms.TextBox(); |
|
||||||
this.label2 = new System.Windows.Forms.Label(); |
|
||||||
this.label1 = new System.Windows.Forms.Label(); |
|
||||||
this.button2 = new System.Windows.Forms.Button(); |
|
||||||
this.button1 = new System.Windows.Forms.Button(); |
|
||||||
this.outputTextBox = new System.Windows.Forms.TextBox(); |
|
||||||
this.button5 = new System.Windows.Forms.Button(); |
|
||||||
this.groupBox1.SuspendLayout(); |
|
||||||
this.SuspendLayout(); |
|
||||||
//
|
|
||||||
// groupBox1
|
|
||||||
//
|
|
||||||
this.groupBox1.Controls.Add(this.comboBox1); |
|
||||||
this.groupBox1.Controls.Add(this.label3); |
|
||||||
this.groupBox1.Controls.Add(this.deleteStringsButton); |
|
||||||
this.groupBox1.Controls.Add(this.button4); |
|
||||||
this.groupBox1.Controls.Add(this.savePasswordCheckBox); |
|
||||||
this.groupBox1.Controls.Add(this.button3); |
|
||||||
this.groupBox1.Controls.Add(this.passwordTextBox); |
|
||||||
this.groupBox1.Controls.Add(this.userNameTextBox); |
|
||||||
this.groupBox1.Controls.Add(this.label2); |
|
||||||
this.groupBox1.Controls.Add(this.label1); |
|
||||||
this.groupBox1.Location = new System.Drawing.Point(12, 12); |
|
||||||
this.groupBox1.Name = "groupBox1"; |
|
||||||
this.groupBox1.Size = new System.Drawing.Size(597, 100); |
|
||||||
this.groupBox1.TabIndex = 0; |
|
||||||
this.groupBox1.TabStop = false; |
|
||||||
this.groupBox1.Text = "Translation server"; |
|
||||||
//
|
|
||||||
// comboBox1
|
|
||||||
//
|
|
||||||
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; |
|
||||||
this.comboBox1.FormattingEnabled = true; |
|
||||||
this.comboBox1.Items.AddRange(new object[] { |
|
||||||
"cz\">Czech</option>", |
|
||||||
"<option value=\"nl\">Dutch</option>", |
|
||||||
"<option value=\"fr\">French</option>", |
|
||||||
"<option selected=\"\" value=\"de\">German</option>", |
|
||||||
"<option value=\"it\">Italian</option>", |
|
||||||
"<option value=\"pt\">Portuguese</option>", |
|
||||||
"<option value=\"es\">Spanish</option>", |
|
||||||
"<option value=\"se\">Swedish</option>", |
|
||||||
"<option value=\"goisern\">Goiserisch</option>", |
|
||||||
"<option value=\"ru\">Russian</option>", |
|
||||||
"<option value=\"br\">Brazilian Portuguese</option>", |
|
||||||
"<option value=\"pl\">Polish</option>", |
|
||||||
"<option value=\"jp\">Japanese</option>", |
|
||||||
"<option value=\"th\">Thai</option>", |
|
||||||
"<option value=\"kr\">Korean</option>", |
|
||||||
"<option value=\"dk\">Danish</option>", |
|
||||||
"<option value=\"hu\">Hungarian</option>", |
|
||||||
"<option value=\"ro\">Romanian</option>", |
|
||||||
"<option value=\"cn-gb\">Chinese Simplified</option>", |
|
||||||
"<option value=\"cn-big\">Chinese Traditional</option>", |
|
||||||
"<option value=\"ca\">Catalan</option>", |
|
||||||
"<option value=\"bg\">Bulgarian</option>", |
|
||||||
"<option value=\"urdu\">Urdu</option>", |
|
||||||
"<option value=\"be\">Belarusian</option>", |
|
||||||
"<option value=\"el\">Greek</option>", |
|
||||||
"<option value=\"tr\">Turkish</option>", |
|
||||||
"<option value=\"sk\">Slovak</option>", |
|
||||||
"<option value=\"lt\">Lithuanian</option>", |
|
||||||
"<option value=\"he\">Hebrew</option>", |
|
||||||
"<option value=\"sl\">Slovenian</option>", |
|
||||||
"<option value=\"es-mx\">Spanish (Mexico)</option>", |
|
||||||
"<option value=\"af\">Afrikaans</option>", |
|
||||||
"<option value=\"vi\">Vietnamese</option>", |
|
||||||
"<option value=\"ar\">Arabic</option>", |
|
||||||
"<option value=\"no\">Norwegian</option>", |
|
||||||
"<option value=\"fa\">Persian</option>", |
|
||||||
"<option value=\"sr\">Serbian</option>", |
|
||||||
"<option value=\"fi\">Finnish</option>", |
|
||||||
"<option value=\"hr\">Croatian</option>", |
|
||||||
"<option value=\"id\">Indonesian </option>"}); |
|
||||||
this.comboBox1.Location = new System.Drawing.Point(76, 65); |
|
||||||
this.comboBox1.Name = "comboBox1"; |
|
||||||
this.comboBox1.Size = new System.Drawing.Size(121, 21); |
|
||||||
this.comboBox1.TabIndex = 9; |
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
this.label3.AutoSize = true; |
|
||||||
this.label3.Location = new System.Drawing.Point(12, 68); |
|
||||||
this.label3.Name = "label3"; |
|
||||||
this.label3.Size = new System.Drawing.Size(58, 13); |
|
||||||
this.label3.TabIndex = 8; |
|
||||||
this.label3.Text = "Language:"; |
|
||||||
//
|
|
||||||
// deleteStringsButton
|
|
||||||
//
|
|
||||||
this.deleteStringsButton.Enabled = false; |
|
||||||
this.deleteStringsButton.Location = new System.Drawing.Point(411, 20); |
|
||||||
this.deleteStringsButton.Name = "deleteStringsButton"; |
|
||||||
this.deleteStringsButton.Size = new System.Drawing.Size(144, 23); |
|
||||||
this.deleteStringsButton.TabIndex = 7; |
|
||||||
this.deleteStringsButton.Text = "Delete resource strings"; |
|
||||||
this.deleteStringsButton.Click += new System.EventHandler(this.DeleteStringsButtonClick); |
|
||||||
//
|
|
||||||
// button4
|
|
||||||
//
|
|
||||||
this.button4.Enabled = false; |
|
||||||
this.button4.Location = new System.Drawing.Point(292, 20); |
|
||||||
this.button4.Name = "button4"; |
|
||||||
this.button4.Size = new System.Drawing.Size(113, 23); |
|
||||||
this.button4.TabIndex = 6; |
|
||||||
this.button4.Text = "Download database"; |
|
||||||
this.button4.Click += new System.EventHandler(this.DownloadButtonClick); |
|
||||||
//
|
|
||||||
// savePasswordCheckBox
|
|
||||||
//
|
|
||||||
this.savePasswordCheckBox.Location = new System.Drawing.Point(182, 44); |
|
||||||
this.savePasswordCheckBox.Name = "savePasswordCheckBox"; |
|
||||||
this.savePasswordCheckBox.Size = new System.Drawing.Size(104, 24); |
|
||||||
this.savePasswordCheckBox.TabIndex = 5; |
|
||||||
this.savePasswordCheckBox.Text = "Save password"; |
|
||||||
//
|
|
||||||
// button3
|
|
||||||
//
|
|
||||||
this.button3.Location = new System.Drawing.Point(182, 20); |
|
||||||
this.button3.Name = "button3"; |
|
||||||
this.button3.Size = new System.Drawing.Size(75, 23); |
|
||||||
this.button3.TabIndex = 4; |
|
||||||
this.button3.Text = "Login"; |
|
||||||
this.button3.Click += new System.EventHandler(this.Button3Click); |
|
||||||
//
|
|
||||||
// passwordTextBox
|
|
||||||
//
|
|
||||||
this.passwordTextBox.Location = new System.Drawing.Point(76, 42); |
|
||||||
this.passwordTextBox.Name = "passwordTextBox"; |
|
||||||
this.passwordTextBox.PasswordChar = '●'; |
|
||||||
this.passwordTextBox.Size = new System.Drawing.Size(100, 20); |
|
||||||
this.passwordTextBox.TabIndex = 3; |
|
||||||
this.passwordTextBox.UseSystemPasswordChar = true; |
|
||||||
//
|
|
||||||
// userNameTextBox
|
|
||||||
//
|
|
||||||
this.userNameTextBox.Location = new System.Drawing.Point(76, 19); |
|
||||||
this.userNameTextBox.Name = "userNameTextBox"; |
|
||||||
this.userNameTextBox.Size = new System.Drawing.Size(100, 20); |
|
||||||
this.userNameTextBox.TabIndex = 1; |
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
this.label2.Location = new System.Drawing.Point(6, 40); |
|
||||||
this.label2.Name = "label2"; |
|
||||||
this.label2.Size = new System.Drawing.Size(64, 23); |
|
||||||
this.label2.TabIndex = 2; |
|
||||||
this.label2.Text = "Password:"; |
|
||||||
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; |
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.Location = new System.Drawing.Point(6, 17); |
|
||||||
this.label1.Name = "label1"; |
|
||||||
this.label1.Size = new System.Drawing.Size(64, 23); |
|
||||||
this.label1.TabIndex = 0; |
|
||||||
this.label1.Text = "Username:"; |
|
||||||
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; |
|
||||||
//
|
|
||||||
// button2
|
|
||||||
//
|
|
||||||
this.button2.Location = new System.Drawing.Point(141, 118); |
|
||||||
this.button2.Name = "button2"; |
|
||||||
this.button2.Size = new System.Drawing.Size(124, 23); |
|
||||||
this.button2.TabIndex = 2; |
|
||||||
this.button2.Text = "Find missing strings"; |
|
||||||
this.button2.Click += new System.EventHandler(this.Button2Click); |
|
||||||
//
|
|
||||||
// button1
|
|
||||||
//
|
|
||||||
this.button1.Location = new System.Drawing.Point(11, 118); |
|
||||||
this.button1.Name = "button1"; |
|
||||||
this.button1.Size = new System.Drawing.Size(124, 23); |
|
||||||
this.button1.TabIndex = 1; |
|
||||||
this.button1.Text = "Find unused strings"; |
|
||||||
this.button1.Click += new System.EventHandler(this.Button1Click); |
|
||||||
//
|
|
||||||
// outputTextBox
|
|
||||||
//
|
|
||||||
this.outputTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
|
||||||
| System.Windows.Forms.AnchorStyles.Left) |
|
||||||
| System.Windows.Forms.AnchorStyles.Right))); |
|
||||||
this.outputTextBox.Location = new System.Drawing.Point(12, 147); |
|
||||||
this.outputTextBox.Multiline = true; |
|
||||||
this.outputTextBox.Name = "outputTextBox"; |
|
||||||
this.outputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; |
|
||||||
this.outputTextBox.Size = new System.Drawing.Size(597, 309); |
|
||||||
this.outputTextBox.TabIndex = 3; |
|
||||||
//
|
|
||||||
// button5
|
|
||||||
//
|
|
||||||
this.button5.Location = new System.Drawing.Point(271, 118); |
|
||||||
this.button5.Name = "button5"; |
|
||||||
this.button5.Size = new System.Drawing.Size(280, 23); |
|
||||||
this.button5.TabIndex = 4; |
|
||||||
this.button5.Text = "Upload resources (check language! dangerous!)"; |
|
||||||
this.button5.UseVisualStyleBackColor = true; |
|
||||||
this.button5.Click += new System.EventHandler(this.Button5Click); |
|
||||||
//
|
|
||||||
// MainForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
|
||||||
this.ClientSize = new System.Drawing.Size(621, 468); |
|
||||||
this.Controls.Add(this.button5); |
|
||||||
this.Controls.Add(this.groupBox1); |
|
||||||
this.Controls.Add(this.button2); |
|
||||||
this.Controls.Add(this.button1); |
|
||||||
this.Controls.Add(this.outputTextBox); |
|
||||||
this.Name = "MainForm"; |
|
||||||
this.Text = "StringResourceTool"; |
|
||||||
this.groupBox1.ResumeLayout(false); |
|
||||||
this.groupBox1.PerformLayout(); |
|
||||||
this.ResumeLayout(false); |
|
||||||
this.PerformLayout(); |
|
||||||
} |
|
||||||
private System.Windows.Forms.Label label3; |
|
||||||
private System.Windows.Forms.ComboBox comboBox1; |
|
||||||
private System.Windows.Forms.Button button5; |
|
||||||
private System.Windows.Forms.Button deleteStringsButton; |
|
||||||
private System.Windows.Forms.Button button4; |
|
||||||
private System.Windows.Forms.CheckBox savePasswordCheckBox; |
|
||||||
private System.Windows.Forms.Button button3; |
|
||||||
private System.Windows.Forms.TextBox passwordTextBox; |
|
||||||
private System.Windows.Forms.TextBox userNameTextBox; |
|
||||||
private System.Windows.Forms.Label label2; |
|
||||||
private System.Windows.Forms.Label label1; |
|
||||||
private System.Windows.Forms.GroupBox groupBox1; |
|
||||||
private System.Windows.Forms.Button button2; |
|
||||||
private System.Windows.Forms.Button button1; |
|
||||||
private System.Windows.Forms.TextBox outputTextBox; |
|
||||||
#endregion
|
|
||||||
|
|
||||||
void Button1Click(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
button1.Enabled = false; |
|
||||||
Display(FindMissing(FindResourceStrings(), FindUsedStrings())); |
|
||||||
button1.Enabled = true; |
|
||||||
} |
|
||||||
|
|
||||||
void Button2Click(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
button2.Enabled = false; |
|
||||||
Display(FindMissing(FindUsedStrings(), FindResourceStrings())); |
|
||||||
button2.Enabled = true; |
|
||||||
} |
|
||||||
|
|
||||||
void Display(List<string> list) |
|
||||||
{ |
|
||||||
StringBuilder b = new StringBuilder(); |
|
||||||
foreach (string entry in list) { |
|
||||||
b.AppendLine(entry); |
|
||||||
} |
|
||||||
outputTextBox.Text = b.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>Gets entries in t1 that are missing from t2.</summary>
|
|
||||||
List<string> FindMissing(HashSet<string> t1, HashSet<string> t2) |
|
||||||
{ |
|
||||||
return t1.Except(t2).OrderBy(s=>s).ToList(); |
|
||||||
} |
|
||||||
|
|
||||||
HashSet<string> FindUsedStrings() |
|
||||||
{ |
|
||||||
HashSet<string> t = new HashSet<string>(); |
|
||||||
FindUsedStrings(t, @"..\..\..\..\.."); |
|
||||||
return t; |
|
||||||
} |
|
||||||
void FindUsedStrings(HashSet<string> t, string path) |
|
||||||
{ |
|
||||||
foreach (string subPath in Directory.GetDirectories(path)) { |
|
||||||
if (!(subPath.EndsWith(".svn") || subPath.EndsWith("\\obj"))) { |
|
||||||
FindUsedStrings(t, subPath); |
|
||||||
} |
|
||||||
} |
|
||||||
foreach (string fileName in Directory.EnumerateFiles(path)) { |
|
||||||
switch (Path.GetExtension(fileName).ToLowerInvariant()) { |
|
||||||
case ".cs": |
|
||||||
case ".boo": |
|
||||||
FindUsedStrings(fileName, t, resourceService); |
|
||||||
break; |
|
||||||
case ".xaml": |
|
||||||
FindUsedStrings(fileName, t, xamlLocalize, xamlLocalizeElementSyntax); |
|
||||||
break; |
|
||||||
case ".resx": |
|
||||||
case ".resources": |
|
||||||
case ".dll": |
|
||||||
case ".exe": |
|
||||||
case ".pdb": |
|
||||||
break; |
|
||||||
default: |
|
||||||
FindUsedStrings(fileName, t); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
const string resourceNameRegex = @"[\.\w\d]+"; |
|
||||||
|
|
||||||
readonly static Regex pattern = new Regex(@"\$\{res:(" + resourceNameRegex + @")\}", RegexOptions.Compiled); |
|
||||||
readonly static Regex resourceService = new Regex(@"ResourceService.GetString\(\""(" + resourceNameRegex + @")\""\)", RegexOptions.Compiled); |
|
||||||
readonly static Regex xamlLocalize = new Regex(@"\{\w+:Localize\s+(" + resourceNameRegex + @")\}", RegexOptions.Compiled); |
|
||||||
readonly static Regex xamlLocalizeElementSyntax = new Regex(@"\<\w+:LocalizeExtension\s+Key\s*=\s*[""'](" + resourceNameRegex + @")[""']", RegexOptions.Compiled); |
|
||||||
|
|
||||||
void FindUsedStrings(string fileName, HashSet<string> t, params Regex[] extraPatterns) |
|
||||||
{ |
|
||||||
StreamReader sr = File.OpenText(fileName); |
|
||||||
string content = sr.ReadToEnd(); |
|
||||||
sr.Close(); |
|
||||||
foreach (Match m in pattern.Matches(content)) { |
|
||||||
//Debug.WriteLine(fileName);
|
|
||||||
t.Add(m.Groups[1].Captures[0].Value); |
|
||||||
} |
|
||||||
foreach (var extraPattern in extraPatterns) { |
|
||||||
foreach (Match m in extraPattern.Matches(content)) { |
|
||||||
//Debug.WriteLine(fileName);
|
|
||||||
t.Add(m.Groups[1].Captures[0].Value); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
const string srcDir = @"..\..\..\..\"; |
|
||||||
HashSet<string> FindResourceStrings() |
|
||||||
{ |
|
||||||
var rs = new ResXResourceReader(srcDir + @"..\data\resources\StringResources.resx"); |
|
||||||
HashSet<string> t = new HashSet<string>(); |
|
||||||
foreach (DictionaryEntry e in rs) { |
|
||||||
t.Add(e.Key.ToString()); |
|
||||||
} |
|
||||||
rs.Close(); |
|
||||||
return t; |
|
||||||
} |
|
||||||
|
|
||||||
TranslationServer server; |
|
||||||
|
|
||||||
void Button3Click(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
server = new TranslationServer(outputTextBox); |
|
||||||
if (savePasswordCheckBox.Checked) { |
|
||||||
using (StreamWriter w = new StreamWriter("password.txt")) { |
|
||||||
w.WriteLine(userNameTextBox.Text); |
|
||||||
w.WriteLine(passwordTextBox.Text); |
|
||||||
} |
|
||||||
} else { |
|
||||||
File.Delete("password.txt"); |
|
||||||
} |
|
||||||
if (server.Login(userNameTextBox.Text, passwordTextBox.Text)) { |
|
||||||
button4.Enabled = true; |
|
||||||
deleteStringsButton.Enabled = true; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void DownloadButtonClick(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
EventHandler onDownloadFinished = delegate { |
|
||||||
outputTextBox.Text += "\r\nLoading database..."; |
|
||||||
Application.DoEvents(); |
|
||||||
|
|
||||||
ResourceDatabase db = ResourceDatabase.Load("LocalizeDb_DL_Corsavy.mdb"); |
|
||||||
outputTextBox.Text += "\r\nCreating resource files..."; |
|
||||||
Application.DoEvents(); |
|
||||||
BuildResourceFiles.Build(db, Path.Combine(srcDir, "../data/resources"), |
|
||||||
text => { outputTextBox.Text += "\r\n" + text; Application.DoEvents();}); |
|
||||||
|
|
||||||
outputTextBox.Text += "\r\nBuilding SharpDevelop..."; |
|
||||||
RunBatch(Path.Combine(srcDir, ".."), "debugbuild.bat", null); |
|
||||||
}; |
|
||||||
server.DownloadDatabase("LocalizeDb_DL_Corsavy.mdb", onDownloadFinished); |
|
||||||
//onDownloadFinished(null, null);
|
|
||||||
} |
|
||||||
|
|
||||||
void RunBatch(string dir, string batchFile, MethodInvoker exitCallback) |
|
||||||
{ |
|
||||||
BeginInvoke(new MethodInvoker(delegate { |
|
||||||
outputTextBox.Text += "\r\nRun " + dir + batchFile + "..."; |
|
||||||
})); |
|
||||||
ProcessStartInfo psi = new ProcessStartInfo("cmd", "/c " + batchFile); |
|
||||||
psi.WorkingDirectory = dir; |
|
||||||
Process p = Process.Start(psi); |
|
||||||
if (exitCallback != null) { |
|
||||||
p.EnableRaisingEvents = true; |
|
||||||
p.Exited += delegate { |
|
||||||
p.Dispose(); |
|
||||||
exitCallback(); |
|
||||||
}; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void DeleteStringsButtonClick(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
List<string> list = new List<string>(); |
|
||||||
string preview = ""; |
|
||||||
foreach (string line in outputTextBox.Lines) { |
|
||||||
if (line.Length > 0) { |
|
||||||
list.Add(line); |
|
||||||
if (preview.Length == 0) { |
|
||||||
preview = line; |
|
||||||
} else if (preview.Length < 100) { |
|
||||||
preview += ", " + line; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
if (MessageBox.Show("Do you really want to delete the " + list.Count + " resource strings (" + preview + ")" |
|
||||||
, "Delete resources", MessageBoxButtons.YesNo) == DialogResult.Yes) { |
|
||||||
server.DeleteResourceStrings(list.ToArray()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void Button5Click(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
server.SetLanguage(comboBox1.SelectedValue.ToString()); |
|
||||||
using (OpenFileDialog dialog = new OpenFileDialog()) { |
|
||||||
dialog.Filter = "String resources (.resources)|*.resources"; |
|
||||||
if (dialog.ShowDialog() != DialogResult.OK) return; |
|
||||||
ImportResourcesFile(dialog.FileName); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void ImportResourcesFile(string fileName) |
|
||||||
{ |
|
||||||
using (ResourceReader r = new ResourceReader(fileName)) { |
|
||||||
IDictionaryEnumerator enumerator = r.GetEnumerator(); |
|
||||||
while (enumerator.MoveNext()) { |
|
||||||
try { |
|
||||||
server.UpdateTranslation(enumerator.Key.ToString(), enumerator.Value.ToString()); |
|
||||||
} catch (WebException ex) { |
|
||||||
outputTextBox.AppendText(Environment.NewLine + "could not update: " + enumerator.Key + ": " + ex.Message); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,120 +0,0 @@ |
|||||||
<?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> |
|
||||||
</root> |
|
@ -1,103 +0,0 @@ |
|||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
// substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Data.OleDb; |
|
||||||
using System.Linq; |
|
||||||
using System.Resources; |
|
||||||
using System.Xml.Linq; |
|
||||||
|
|
||||||
namespace StringResourceTool |
|
||||||
{ |
|
||||||
public class ResourceDatabase |
|
||||||
{ |
|
||||||
public readonly List<LanguageTable> Languages = new List<LanguageTable>(); |
|
||||||
|
|
||||||
public static ResourceDatabase Load(string databaseFile) |
|
||||||
{ |
|
||||||
string connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + |
|
||||||
databaseFile + ";"; |
|
||||||
using (var myConnection = new OleDbConnection(connection)) { |
|
||||||
myConnection.Open(); |
|
||||||
ResourceDatabase db = new ResourceDatabase(); |
|
||||||
using (OleDbCommand myOleDbCommand = new OleDbCommand("SELECT * FROM Localization", myConnection)) { |
|
||||||
using (OleDbDataReader reader = myOleDbCommand.ExecuteReader()) { |
|
||||||
string[] fieldNames = Enumerable.Range(0, reader.FieldCount).Select(i => reader.GetName(i)).ToArray(); |
|
||||||
db.Languages.Add(new LanguageTable("en")); |
|
||||||
foreach (string fieldName in fieldNames) { |
|
||||||
if (fieldName.StartsWith("lang-")) |
|
||||||
db.Languages.Add(new LanguageTable(fieldName.Substring(5))); |
|
||||||
} |
|
||||||
while (reader.Read()) { |
|
||||||
ResourceEntry primaryEntry = new ResourceEntry { |
|
||||||
Key = reader["ResourceName"].ToString(), |
|
||||||
Description = reader["PrimaryPurpose"].ToString(), |
|
||||||
Value = reader["PrimaryResLangValue"].ToString() |
|
||||||
}; |
|
||||||
db.Languages[0].Entries.Add(primaryEntry.Key, primaryEntry); |
|
||||||
for (int i = 1; i < db.Languages.Count; i++) { |
|
||||||
string val = reader["lang-" + db.Languages[i].LanguageName].ToString(); |
|
||||||
if (!string.IsNullOrEmpty(val)) { |
|
||||||
ResourceEntry entry = new ResourceEntry { |
|
||||||
Key = primaryEntry.Key, |
|
||||||
Description = primaryEntry.Description, |
|
||||||
Value = val |
|
||||||
}; |
|
||||||
db.Languages[i].Entries.Add(entry.Key, entry); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return db; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class LanguageTable |
|
||||||
{ |
|
||||||
public readonly string LanguageName; |
|
||||||
public readonly Dictionary<string, ResourceEntry> Entries = new Dictionary<string, ResourceEntry>(); |
|
||||||
|
|
||||||
public LanguageTable(string languageName) |
|
||||||
{ |
|
||||||
this.LanguageName = languageName; |
|
||||||
} |
|
||||||
|
|
||||||
public void SaveAsResx(string filename, bool includeDescriptions) |
|
||||||
{ |
|
||||||
using (ResXResourceWriter writer = new ResXResourceWriter(filename)) { |
|
||||||
foreach (ResourceEntry entry in Entries.Values.OrderBy(e => e.Key, StringComparer.OrdinalIgnoreCase)) { |
|
||||||
string normalizedValue = entry.Value.Replace("\r", "").Replace("\n", Environment.NewLine); |
|
||||||
if (includeDescriptions) { |
|
||||||
string normalizedDescription = entry.Description.Replace("\r", "").Replace("\n", Environment.NewLine); |
|
||||||
writer.AddResource(new ResXDataNode(entry.Key, normalizedValue) { Comment = normalizedDescription }); |
|
||||||
} else { |
|
||||||
writer.AddResource(entry.Key, normalizedValue); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class ResourceEntry |
|
||||||
{ |
|
||||||
public string Key, Description, Value; |
|
||||||
} |
|
||||||
} |
|
@ -1,71 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||||
<PropertyGroup> |
|
||||||
<OutputType>WinExe</OutputType> |
|
||||||
<RootNamespace>StringResourceTool</RootNamespace> |
|
||||||
<AssemblyName>StringResourceTool</AssemblyName> |
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
||||||
<ProjectGuid>{197537EA-78F4-4434-904C-C81B19459FE7}</ProjectGuid> |
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
|
||||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> |
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
|
||||||
<NoStdLib>False</NoStdLib> |
|
||||||
<WarningLevel>4</WarningLevel> |
|
||||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
|
||||||
<TargetFrameworkProfile /> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
|
||||||
<OutputPath>bin\Debug\</OutputPath> |
|
||||||
<Optimize>False</Optimize> |
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
||||||
<DebugSymbols>true</DebugSymbols> |
|
||||||
<DebugType>Full</DebugType> |
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
|
||||||
<OutputPath>bin\Release\</OutputPath> |
|
||||||
<Optimize>True</Optimize> |
|
||||||
<DefineConstants>TRACE</DefineConstants> |
|
||||||
<DebugSymbols>False</DebugSymbols> |
|
||||||
<DebugType>None</DebugType> |
|
||||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
|
||||||
<RegisterForComInterop>False</RegisterForComInterop> |
|
||||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
|
||||||
<BaseAddress>4194304</BaseAddress> |
|
||||||
<PlatformTarget>x86</PlatformTarget> |
|
||||||
<FileAlignment>4096</FileAlignment> |
|
||||||
</PropertyGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Reference Include="System" /> |
|
||||||
<Reference Include="System.Core"> |
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
|
||||||
</Reference> |
|
||||||
<Reference Include="System.Data" /> |
|
||||||
<Reference Include="System.Drawing" /> |
|
||||||
<Reference Include="System.Web" /> |
|
||||||
<Reference Include="System.Windows.Forms" /> |
|
||||||
<Reference Include="System.Xml" /> |
|
||||||
<Reference Include="System.Xml.Linq"> |
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
|
||||||
</Reference> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Compile Include="BuildResourceFiles.cs" /> |
|
||||||
<Compile Include="CookieAwareWebClient.cs" /> |
|
||||||
<Compile Include="MainForm.cs" /> |
|
||||||
<Compile Include="ResourceDatabase.cs" /> |
|
||||||
<Compile Include="TranslationServer.cs" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<EmbeddedResource Include="MainForm.resx"> |
|
||||||
<DependentUpon>MainForm.cs</DependentUpon> |
|
||||||
</EmbeddedResource> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<None Include="app.config" /> |
|
||||||
</ItemGroup> |
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
|
||||||
</Project> |
|
@ -1,24 +0,0 @@ |
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 11.00 |
|
||||||
# Visual Studio 2010 |
|
||||||
# SharpDevelop 5.0 |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringResourceTool", "StringResourceTool.csproj", "{197537EA-78F4-4434-904C-C81B19459FE7}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringResourceToolAddIn", "..\StringResourceToolAddIn\StringResourceToolAddIn.csproj", "{3648E209-B853-4168-BFB5-7A60EAF316F8}" |
|
||||||
EndProject |
|
||||||
Global |
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|
||||||
Debug|Any CPU = Debug|Any CPU |
|
||||||
Release|Any CPU = Release|Any CPU |
|
||||||
EndGlobalSection |
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|
||||||
{197537EA-78F4-4434-904C-C81B19459FE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{197537EA-78F4-4434-904C-C81B19459FE7}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{197537EA-78F4-4434-904C-C81B19459FE7}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{197537EA-78F4-4434-904C-C81B19459FE7}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{3648E209-B853-4168-BFB5-7A60EAF316F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{3648E209-B853-4168-BFB5-7A60EAF316F8}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{3648E209-B853-4168-BFB5-7A60EAF316F8}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{3648E209-B853-4168-BFB5-7A60EAF316F8}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
EndGlobalSection |
|
||||||
EndGlobal |
|
@ -1,163 +0,0 @@ |
|||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
// substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.IO; |
|
||||||
using System.Net; |
|
||||||
using System.Text; |
|
||||||
using System.Web; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
namespace StringResourceTool |
|
||||||
{ |
|
||||||
public class TranslationServer |
|
||||||
{ |
|
||||||
TextBox output; |
|
||||||
string baseURL = "http://developer.sharpdevelop.net/corsavy/translation/"; |
|
||||||
|
|
||||||
public TranslationServer(TextBox output) |
|
||||||
{ |
|
||||||
this.output = output; |
|
||||||
this.cookieContainer = new CookieContainer(); |
|
||||||
this.wc = new CookieAwareWebClient(cookieContainer); |
|
||||||
} |
|
||||||
|
|
||||||
CookieContainer cookieContainer; |
|
||||||
CookieAwareWebClient wc; |
|
||||||
|
|
||||||
public bool Login(string user, string pwd) |
|
||||||
{ |
|
||||||
output.Text = "Contacting server..."; |
|
||||||
Application.DoEvents(); |
|
||||||
System.Threading.Thread.Sleep(50); |
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(baseURL + "logon.asp"); |
|
||||||
request.ContentType = "application/x-www-form-urlencoded"; |
|
||||||
string postString = "uname=" + user + "&upwd=" + HttpUtility.UrlEncode(pwd); |
|
||||||
request.ContentLength = postString.Length; |
|
||||||
request.CookieContainer = cookieContainer; |
|
||||||
request.Method = "POST"; |
|
||||||
request.AllowAutoRedirect = false; |
|
||||||
Stream s = request.GetRequestStream(); |
|
||||||
using (StreamWriter w = new StreamWriter(s)) { |
|
||||||
w.Write(postString); |
|
||||||
} |
|
||||||
s.Close(); |
|
||||||
string result; |
|
||||||
using (StreamReader r = new StreamReader(request.GetResponse().GetResponseStream())) { |
|
||||||
result = r.ReadToEnd(); |
|
||||||
} |
|
||||||
if (result.Contains("You couldn't be logged on")) { |
|
||||||
output.Text += "\r\nInvalid username/password."; |
|
||||||
return false; |
|
||||||
} |
|
||||||
output.Text += "\r\nLogin successful."; |
|
||||||
return true; |
|
||||||
} |
|
||||||
public void DownloadDatabase(string targetFile, EventHandler successCallback) |
|
||||||
{ |
|
||||||
wc.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs e) { |
|
||||||
output.BeginInvoke((MethodInvoker)delegate { |
|
||||||
output.Text = "Download: " + e.ProgressPercentage + "%"; |
|
||||||
}); |
|
||||||
}; |
|
||||||
wc.DownloadDataCompleted += delegate(object sender, DownloadDataCompletedEventArgs e) { |
|
||||||
output.BeginInvoke((MethodInvoker)delegate { |
|
||||||
if (e.Error != null) |
|
||||||
output.Text = e.Error.ToString(); |
|
||||||
else |
|
||||||
output.Text = "Download complete."; |
|
||||||
}); |
|
||||||
if (e.Error == null) { |
|
||||||
using (FileStream fs = new FileStream(targetFile, FileMode.Create, FileAccess.Write)) { |
|
||||||
fs.Write(e.Result, 0, e.Result.Length); |
|
||||||
} |
|
||||||
successCallback(this, EventArgs.Empty); |
|
||||||
} |
|
||||||
wc.Dispose(); |
|
||||||
}; |
|
||||||
wc.DownloadDataAsync(new Uri(baseURL + "CompactNdownload.asp")); |
|
||||||
} |
|
||||||
|
|
||||||
public void AddResourceString(string idx, string value, string purpose) |
|
||||||
{ |
|
||||||
wc.Headers.Set("Content-Type", "application/x-www-form-urlencoded"); |
|
||||||
wc.UploadString(new Uri(baseURL + "owners_AddNew.asp"), |
|
||||||
"Idx=" + Uri.EscapeDataString(idx) |
|
||||||
+ "&PrimaryResLangValue=" + Uri.EscapeDataString(value) |
|
||||||
+ "&PrimaryPurpose=" + Uri.EscapeDataString(purpose)); |
|
||||||
} |
|
||||||
|
|
||||||
public void UpdateTranslation(string idx, string newValue) |
|
||||||
{ |
|
||||||
newValue = HttpUtility.UrlEncode(newValue, Encoding.Default); |
|
||||||
wc.Headers.Set("Content-Type", "application/x-www-form-urlencoded"); |
|
||||||
wc.UploadString(new Uri(baseURL + "translation_edit.asp"), |
|
||||||
"Idx=" + Uri.EscapeDataString(idx) |
|
||||||
+ "&Localization=" + newValue); |
|
||||||
} |
|
||||||
|
|
||||||
public void DeleteResourceStrings(string[] idx) |
|
||||||
{ |
|
||||||
const int threadCount = 3; // 3 parallel calls
|
|
||||||
output.Text = "Deleting..."; |
|
||||||
int index = 0; |
|
||||||
int finishCount = 0; |
|
||||||
EventHandler callback = null; |
|
||||||
callback = delegate { |
|
||||||
lock (idx) { |
|
||||||
if (index < idx.Length) { |
|
||||||
DeleteResourceString(idx[index++], callback); |
|
||||||
} else { |
|
||||||
finishCount += 1; |
|
||||||
if (finishCount == threadCount) { |
|
||||||
output.BeginInvoke((MethodInvoker)delegate { |
|
||||||
output.Text += "\r\nFinished."; |
|
||||||
output.Text += "\r\nYou have to re-download the database to see the changes."; |
|
||||||
}); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
}; |
|
||||||
for (int i = 0; i < threadCount; i++) { |
|
||||||
callback(null, null); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void DeleteResourceString(string idx, EventHandler callback) |
|
||||||
{ |
|
||||||
wc.Headers.Set("Content-Type", "application/x-www-form-urlencoded"); |
|
||||||
wc.UploadStringCompleted += delegate { |
|
||||||
output.BeginInvoke((MethodInvoker)delegate { |
|
||||||
output.Text += "\r\nDeleted " + idx; |
|
||||||
}); |
|
||||||
wc.Dispose(); |
|
||||||
if (callback != null) |
|
||||||
callback(this, EventArgs.Empty); |
|
||||||
}; |
|
||||||
wc.UploadStringAsync(new Uri(baseURL + "owners_delete.asp"), |
|
||||||
"Idx=" + Uri.EscapeDataString(idx) + "&ReallyDelete=on"); |
|
||||||
} |
|
||||||
|
|
||||||
public void SetLanguage(string language) |
|
||||||
{ |
|
||||||
wc.Headers.Set("Content-Type", "application/x-www-form-urlencoded"); |
|
||||||
wc.UploadString(new Uri(baseURL + "SelectLanguage.asp"), |
|
||||||
"Language=" + Uri.EscapeDataString(language)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,6 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<configuration> |
|
||||||
<startup> |
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> |
|
||||||
</startup> |
|
||||||
</configuration> |
|
@ -1,37 +0,0 @@ |
|||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
// substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
using System.Reflection; |
|
||||||
|
|
||||||
[assembly: AssemblyTitle("StringResourceToolAddIn")] |
|
||||||
[assembly: AssemblyDescription("Macro AddIn for SharpDevelop 2.0")] |
|
||||||
[assembly: AssemblyConfiguration("")] |
|
||||||
[assembly: AssemblyCompany("")] |
|
||||||
[assembly: AssemblyProduct("SharpDevelop")] |
|
||||||
[assembly: AssemblyCopyright("")] |
|
||||||
[assembly: AssemblyTrademark("")] |
|
||||||
[assembly: AssemblyCulture("")] |
|
||||||
|
|
||||||
// The assembly version has following format :
|
|
||||||
//
|
|
||||||
// Major.Minor.Build.Revision
|
|
||||||
//
|
|
||||||
// You can specify all values by your own or you can build default build and revision
|
|
||||||
// numbers with the '*' character (the default):
|
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.0.*")] |
|
@ -1,100 +0,0 @@ |
|||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
// substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.IO; |
|
||||||
using System.Resources; |
|
||||||
using System.Text; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
|
|
||||||
namespace StringResourceToolAddIn |
|
||||||
{ |
|
||||||
public class ToolCommand1 : AbstractMenuCommand |
|
||||||
{ |
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
// Here an example that shows how to access the current text document:
|
|
||||||
|
|
||||||
var textEditor = SD.GetActiveViewContentService<ITextEditor>(); |
|
||||||
if (textEditor == null) { |
|
||||||
// active content is not a text editor control
|
|
||||||
return; |
|
||||||
} |
|
||||||
if (textEditor.SelectionLength == 0) |
|
||||||
return; |
|
||||||
// get the selected text:
|
|
||||||
string text = textEditor.SelectedText; |
|
||||||
|
|
||||||
string sdSrcPath = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), |
|
||||||
"../../../.."); |
|
||||||
string resxFile = Path.Combine(sdSrcPath, "../data/Resources/StringResources.resx"); |
|
||||||
|
|
||||||
using (ResXResourceReader r = new ResXResourceReader(resxFile)) { |
|
||||||
IDictionaryEnumerator en = r.GetEnumerator(); |
|
||||||
// Goes through the enumerator, printing out the key and value pairs.
|
|
||||||
while (en.MoveNext()) { |
|
||||||
if (object.Equals(en.Value, text)) { |
|
||||||
SetText(textEditor, en.Key.ToString(), text); |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string resourceName = MessageService.ShowInputBox("Add Resource", "Please enter the name for the new resource.\n" + |
|
||||||
"This should be a namespace-like construct, please see what the names of resources in the same component are.", SD.PropertyService.Get("ResourceToolLastResourceName", "")); |
|
||||||
if (resourceName == null || resourceName.Length == 0) return; |
|
||||||
PropertyService.Set("ResourceToolLastResourceName", resourceName); |
|
||||||
|
|
||||||
string purpose = MessageService.ShowInputBox("Add Resource", "Enter resource purpose (may be empty)", ""); |
|
||||||
if (purpose == null) return; |
|
||||||
|
|
||||||
SetText(textEditor, resourceName, text); |
|
||||||
|
|
||||||
string path = Path.GetFullPath(Path.Combine(sdSrcPath, "Tools/StringResourceTool/bin/Debug")); |
|
||||||
ProcessStartInfo info = new ProcessStartInfo(path + "\\StringResourceTool.exe", |
|
||||||
"\"" + resourceName + "\" " |
|
||||||
+ "\"" + text + "\" " |
|
||||||
+ "\"" + purpose + "\""); |
|
||||||
info.WorkingDirectory = path; |
|
||||||
try { |
|
||||||
Process.Start(info); |
|
||||||
} catch (Exception ex) { |
|
||||||
MessageService.ShowException(ex, "Error starting " + info.FileName); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void SetText(ITextEditor textEditor, string resourceName, string oldText) |
|
||||||
{ |
|
||||||
// ensure caret is at start of selection / deselect text
|
|
||||||
textEditor.Select(textEditor.SelectionStart, 0); |
|
||||||
// replace the selected text with the new text:
|
|
||||||
string newText; |
|
||||||
if (Path.GetExtension(textEditor.FileName) == ".xaml") |
|
||||||
newText = "{core:Localize " + resourceName + "}"; |
|
||||||
else |
|
||||||
newText = "$" + "{res:" + resourceName + "}"; |
|
||||||
// Replace() takes the arguments: start offset to replace, length of the text to remove, new text
|
|
||||||
textEditor.Document.Replace(textEditor.Caret.Offset, oldText.Length, newText); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,19 +0,0 @@ |
|||||||
<AddIn name = "StringResourceToolAddIn" |
|
||||||
author = "Daniel Grunwald" |
|
||||||
description = "Provides a shortcut (Ctrl+Shift+R) to upload the selected text into the translation database"> |
|
||||||
|
|
||||||
<Manifest> |
|
||||||
<Identity name="ICSharpCode.Internal.StringResourceToolAddIn" version="@StringResourceToolAddIn.dll"/> |
|
||||||
</Manifest> |
|
||||||
|
|
||||||
<Runtime> |
|
||||||
<Import assembly = "StringResourceToolAddIn.dll"/> |
|
||||||
</Runtime> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Workbench/Tools"> |
|
||||||
<MenuItem id = "StringResourceToolAddInCommand1" |
|
||||||
label = "StringResourceToolAddIn" |
|
||||||
shortcut = "Control|Shift|R" |
|
||||||
class = "StringResourceToolAddIn.ToolCommand1"/> |
|
||||||
</Path> |
|
||||||
</AddIn> |
|
@ -1,67 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> |
|
||||||
<PropertyGroup> |
|
||||||
<OutputType>Library</OutputType> |
|
||||||
<RootNamespace>StringResourceToolAddIn</RootNamespace> |
|
||||||
<AssemblyName>StringResourceToolAddIn</AssemblyName> |
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
||||||
<ProjectGuid>{3648E209-B853-4168-BFB5-7A60EAF316F8}</ProjectGuid> |
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
|
||||||
<NoStdLib>False</NoStdLib> |
|
||||||
<RegisterForComInterop>False</RegisterForComInterop> |
|
||||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
|
||||||
<BaseAddress>4194304</BaseAddress> |
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget> |
|
||||||
<FileAlignment>4096</FileAlignment> |
|
||||||
<WarningLevel>4</WarningLevel> |
|
||||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
|
||||||
<TargetFrameworkProfile /> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
|
||||||
<Optimize>False</Optimize> |
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
||||||
<DebugSymbols>true</DebugSymbols> |
|
||||||
<DebugType>Full</DebugType> |
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
|
||||||
<OutputPath>bin\Debug</OutputPath> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
|
||||||
<Optimize>True</Optimize> |
|
||||||
<DefineConstants>TRACE</DefineConstants> |
|
||||||
<DebugSymbols>false</DebugSymbols> |
|
||||||
<DebugType>None</DebugType> |
|
||||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
|
||||||
<OutputPath>bin\Release</OutputPath> |
|
||||||
</PropertyGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Reference Include="ICSharpCode.NRefactory"> |
|
||||||
<HintPath>..\..\..\bin\ICSharpCode.NRefactory.dll</HintPath> |
|
||||||
<Private>False</Private> |
|
||||||
</Reference> |
|
||||||
<Reference Include="System" /> |
|
||||||
<Reference Include="System.Data" /> |
|
||||||
<Reference Include="System.Drawing" /> |
|
||||||
<Reference Include="System.Windows.Forms" /> |
|
||||||
<Reference Include="System.Xml" /> |
|
||||||
<Reference Include="ICSharpCode.SharpDevelop"> |
|
||||||
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath> |
|
||||||
<SpecificVersion>False</SpecificVersion> |
|
||||||
<Private>False</Private> |
|
||||||
</Reference> |
|
||||||
<Reference Include="ICSharpCode.Core"> |
|
||||||
<HintPath>..\..\..\bin\ICSharpCode.Core.dll</HintPath> |
|
||||||
<SpecificVersion>False</SpecificVersion> |
|
||||||
<Private>False</Private> |
|
||||||
</Reference> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<None Include="StringResourceToolAddIn.addin"> |
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
||||||
</None> |
|
||||||
<Compile Include="Src\Command.cs" /> |
|
||||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
|
||||||
</ItemGroup> |
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
|
||||||
</Project> |
|
@ -1,18 +0,0 @@ |
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 11.00 |
|
||||||
# Visual Studio 2010 |
|
||||||
# SharpDevelop 4.0.0.5303 |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringResourceToolAddIn", "StringResourceToolAddIn.csproj", "{3648E209-B853-4168-BFB5-7A60EAF316F8}" |
|
||||||
EndProject |
|
||||||
Global |
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|
||||||
Debug|Any CPU = Debug|Any CPU |
|
||||||
Release|Any CPU = Release|Any CPU |
|
||||||
EndGlobalSection |
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|
||||||
{3648E209-B853-4168-BFB5-7A60EAF316F8}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{3648E209-B853-4168-BFB5-7A60EAF316F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{3648E209-B853-4168-BFB5-7A60EAF316F8}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{3648E209-B853-4168-BFB5-7A60EAF316F8}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
EndGlobalSection |
|
||||||
EndGlobal |
|
Loading…
Reference in new issue