Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4813 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
43 changed files with 118821 additions and 17 deletions
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -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")); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
Loading…
Reference in new issue