Browse Source

Store string resources as .resx instead of .resources in the repository.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4813 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
b9e1ce7c02
  1. BIN
      data/resources/StringResources.cn-gb.resources
  2. 4716
      data/resources/StringResources.cn-gb.resx
  3. BIN
      data/resources/StringResources.cz.resources
  4. 6903
      data/resources/StringResources.cz.resx
  5. BIN
      data/resources/StringResources.de.resources
  6. 7429
      data/resources/StringResources.de.resx
  7. BIN
      data/resources/StringResources.es-mx.resources
  8. 7441
      data/resources/StringResources.es-mx.resx
  9. BIN
      data/resources/StringResources.es.resources
  10. 7447
      data/resources/StringResources.es.resx
  11. BIN
      data/resources/StringResources.fr.resources
  12. 7439
      data/resources/StringResources.fr.resx
  13. BIN
      data/resources/StringResources.hu.resources
  14. 6005
      data/resources/StringResources.hu.resx
  15. BIN
      data/resources/StringResources.it.resources
  16. 5624
      data/resources/StringResources.it.resx
  17. BIN
      data/resources/StringResources.kr.resources
  18. 7243
      data/resources/StringResources.kr.resx
  19. BIN
      data/resources/StringResources.nl.resources
  20. 7450
      data/resources/StringResources.nl.resx
  21. BIN
      data/resources/StringResources.no.resources
  22. 7334
      data/resources/StringResources.no.resx
  23. BIN
      data/resources/StringResources.pl.resources
  24. 6373
      data/resources/StringResources.pl.resx
  25. BIN
      data/resources/StringResources.pt-br.resources
  26. 6365
      data/resources/StringResources.pt-br.resx
  27. BIN
      data/resources/StringResources.pt.resources
  28. 6696
      data/resources/StringResources.pt.resx
  29. 7464
      data/resources/StringResources.resx
  30. BIN
      data/resources/StringResources.ro.resources
  31. 4607
      data/resources/StringResources.ro.resx
  32. BIN
      data/resources/StringResources.se.resources
  33. 5475
      data/resources/StringResources.se.resx
  34. BIN
      data/resources/StringResources.tr.resources
  35. 6632
      data/resources/StringResources.tr.resx
  36. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources
  37. 6
      src/Main/StartUp/Project/StartUp.csproj
  38. 45
      src/Tools/StringResourceTool/BuildResourceFiles.cs
  39. 22
      src/Tools/StringResourceTool/MainForm.cs
  40. 86
      src/Tools/StringResourceTool/ResourceDatabase.cs
  41. 11
      src/Tools/StringResourceTool/StringResourceTool.csproj
  42. 2
      src/Tools/StringResourceToolAddIn/Src/Command.cs
  43. 19
      src/Tools/Tools.build

BIN
data/resources/StringResources.cn-gb.resources

Binary file not shown.

4716
data/resources/StringResources.cn-gb.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.cz.resources

Binary file not shown.

6903
data/resources/StringResources.cz.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.de.resources

Binary file not shown.

7429
data/resources/StringResources.de.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.es-mx.resources

Binary file not shown.

7441
data/resources/StringResources.es-mx.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.es.resources

Binary file not shown.

7447
data/resources/StringResources.es.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.fr.resources

Binary file not shown.

7439
data/resources/StringResources.fr.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.hu.resources

Binary file not shown.

6005
data/resources/StringResources.hu.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.it.resources

Binary file not shown.

5624
data/resources/StringResources.it.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.kr.resources

Binary file not shown.

7243
data/resources/StringResources.kr.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.nl.resources

Binary file not shown.

7450
data/resources/StringResources.nl.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.no.resources

Binary file not shown.

7334
data/resources/StringResources.no.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.pl.resources

Binary file not shown.

6373
data/resources/StringResources.pl.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.pt-br.resources

Binary file not shown.

6365
data/resources/StringResources.pt-br.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.pt.resources

Binary file not shown.

6696
data/resources/StringResources.pt.resx

File diff suppressed because it is too large Load Diff

7464
data/resources/StringResources.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.ro.resources

Binary file not shown.

4607
data/resources/StringResources.ro.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.se.resources

Binary file not shown.

5475
data/resources/StringResources.se.resx

File diff suppressed because it is too large Load Diff

BIN
data/resources/StringResources.tr.resources

Binary file not shown.

6632
data/resources/StringResources.tr.resx

File diff suppressed because it is too large Load Diff

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.

6
src/Main/StartUp/Project/StartUp.csproj

@ -53,6 +53,9 @@ @@ -53,6 +53,9 @@
<SubType>Form</SubType>
</Compile>
<Compile Include="SharpDevelopMain.cs" />
<EmbeddedResource Include="..\..\..\..\data\resources\StringResources.resx">
<Link>Resources\StringResources.resx</Link>
</EmbeddedResource>
<EmbeddedResource Include="Resources\BitmapResources.resources">
<LogicalName>Resources.BitmapResources.resources</LogicalName>
</EmbeddedResource>
@ -62,9 +65,6 @@ @@ -62,9 +65,6 @@
<EmbeddedResource Include="Resources\SplashScreen.jpg">
<LogicalName>Resources.SplashScreen.jpg</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="Resources\StringResources.resources">
<LogicalName>Resources.StringResources.resources</LogicalName>
</EmbeddedResource>
<Compile Include="Configuration\AssemblyInfo.cs" />
<None Include="SharpDevelop.exe.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

45
src/Tools/StringResourceTool/BuildResourceFiles.cs

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
/*
* Created by SharpDevelop.
* User: daniel
* Date: 29.08.2009
* Time: 09:46
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
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> {
{ "pt-br", "br" }
};
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 (string code in languageCodes) {
string databaseCode = codeMap.ContainsKey(code) ? codeMap[code] : code;
LanguageTable language = db.Languages.Find(t => t.LanguageName == databaseCode);
if (language == null) {
debugOutput("Could not find language " + code);
} else {
if (code == "en")
language.SaveAsResx(Path.Combine(resourceDir, "StringResources.resx"));
else
language.SaveAsResx(Path.Combine(resourceDir, "StringResources." + code + ".resx"));
}
}
}
}
}

22
src/Tools/StringResourceTool/MainForm.cs

@ -99,7 +99,7 @@ namespace StringResourceTool @@ -99,7 +99,7 @@ namespace StringResourceTool
button4.Size = new System.Drawing.Size(113, 23);
button4.TabIndex = 6;
button4.Text = "Download database";
button4.Click += new System.EventHandler(this.Button4Click);
button4.Click += new System.EventHandler(this.DownloadButtonClick);
savePasswordCheckBox = new System.Windows.Forms.CheckBox();
//
// savePasswordCheckBox
@ -328,7 +328,6 @@ namespace StringResourceTool @@ -328,7 +328,6 @@ namespace StringResourceTool
}
}
const string srcDir = @"..\..\..\..\";
const string dataBaseDir = srcDir + @"..\..\SharpDevelopResources\LanguageResources\";
Hashtable FindResourceStrings()
{
ResourceSet rs = new ResourceSet(srcDir + @"Main\StartUp\Project\Resources\StringResources.resources");
@ -358,18 +357,23 @@ namespace StringResourceTool @@ -358,18 +357,23 @@ namespace StringResourceTool
}
}
void Button4Click(object sender, EventArgs e)
void DownloadButtonClick(object sender, EventArgs e)
{
EventHandler onDownloadFinished = delegate {
outputTextBox.Text += "\nBuilding resource files...";
RunBatch(dataBaseDir, "build.bat", delegate {
BeginInvoke(new MethodInvoker(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(srcDir, "debugbuild.bat", null);
});
};
server.DownloadDatabase(dataBaseDir + "LocalizeDb.mdb", onDownloadFinished);
server.DownloadDatabase("LocalizeDb_DL_Corsavy.mdb", onDownloadFinished);
//onDownloadFinished(null, null);
}
void RunBatch(string dir, string batchFile, MethodInvoker exitCallback)

86
src/Tools/StringResourceTool/ResourceDatabase.cs

@ -0,0 +1,86 @@ @@ -0,0 +1,86 @@
/*
* Created by SharpDevelop.
* User: daniel
* Date: 28.08.2009
* Time: 23:40
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Linq;
using System.Resources;
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)
{
using (ResXResourceWriter writer = new ResXResourceWriter(filename)) {
foreach (ResourceEntry entry in Entries.Values.OrderBy(e => e.Key, StringComparer.OrdinalIgnoreCase)) {
writer.AddResource(entry.Key, entry.Value);
}
}
}
}
public class ResourceEntry
{
public string Key, Description, Value;
}
}

11
src/Tools/StringResourceTool/StringResourceTool.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<RootNamespace>StringResourceTool</RootNamespace>
@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{197537EA-78F4-4434-904C-C81B19459FE7}</ProjectGuid>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
@ -25,13 +26,21 @@ @@ -25,13 +26,21 @@
</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.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BuildResourceFiles.cs" />
<Compile Include="MainForm.cs" />
<Compile Include="ResourceDatabase.cs" />
<Compile Include="TranslationServer.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />

2
src/Tools/StringResourceToolAddIn/Src/Command.cs

@ -71,7 +71,7 @@ namespace StringResourceToolAddIn @@ -71,7 +71,7 @@ namespace StringResourceToolAddIn
try {
Process.Start(info);
} catch (Exception ex) {
MessageService.ShowError(ex, "Error starting " + info.FileName);
MessageService.ShowException(ex, "Error starting " + info.FileName);
}
}

19
src/Tools/Tools.build

@ -1,4 +1,8 @@ @@ -1,4 +1,8 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTarget="Build">
<PropertyGroup>
<LanguageResourcePath>..\..\data\resources\</LanguageResourcePath>
</PropertyGroup>
<ItemGroup>
<SHFBFiles Include="SHFB\*"/>
<SHFBBuildComponents Include="SHFB\BuildComponents\*"/>
@ -18,9 +22,21 @@ @@ -18,9 +22,21 @@
<HelpToolFiles Include="Help\*"/>
<PartCoverFiles Include="PartCover\*"/>
<PartCoverXsltFiles Include="PartCover\xslt\*"/>
<LanguageResource Include="$(LanguageResourcePath)StringResources.*.resx"/>
</ItemGroup>
<Target Name="Build">
<Target Name="CompileResources" Inputs="@(LanguageResource)" Outputs="@(LanguageResource->'$(LanguageResourcePath)%(Filename).resources')">
<GenerateResource
Sources="@(LanguageResource)"
OutputResources="@(LanguageResource->'$(LanguageResourcePath)%(Filename).resources')">
<Output
TaskParameter="OutputResources"
ItemName="Resources"/>
</GenerateResource>
</Target>
<Target Name="Build" DependsOnTargets="CompileResources">
<Copy SourceFiles="@(SHFBFiles)" DestinationFolder="..\..\bin\Tools\SHFB" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(SHFBBuildComponents)" DestinationFolder="..\..\bin\Tools\SHFB\BuildComponents" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(SHFBColorizerFiles)" DestinationFolder="..\..\bin\Tools\SHFB\Colorizer" SkipUnchangedFiles="true"/>
@ -66,6 +82,7 @@ @@ -66,6 +82,7 @@
<ItemGroup>
<CleanupFiles Include="..\..\bin\*"/>
<CleanupFiles Include="..\Main\GlobalAssemblyInfo.cs"/>
<CleanupFiles Include="$(LanguageResourcePath)StringResources.*.resources"/>
<CleanupDirectories Include="..\..\bin\UnitTests"/>
<CleanupDirectories Include="..\..\bin\Tools"/>
<CleanupDirectories Include="..\..\bin\setup\help"/>

Loading…
Cancel
Save