-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
3,438 additions
and
2,131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = crlf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
10 changes: 6 additions & 4 deletions
10
tabler/Classes/LanguageStatistics.cs → tabler.Logic/Classes/LanguageStatistics.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Generic; | ||
|
||
namespace tabler { | ||
public class LanguageStatistics { | ||
namespace tabler.Logic.Classes | ||
{ | ||
public class LanguageStatistics | ||
{ | ||
public string LanguageName { get; set; } | ||
public Dictionary<string, int> MissingModStrings { get; set; } | ||
} | ||
} | ||
} |
10 changes: 6 additions & 4 deletions
10
tabler/Classes/ModInfoContainer.cs → tabler.Logic/Classes/ModInfoContainer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace tabler { | ||
public class ModInfoContainer { | ||
namespace tabler.Logic.Classes | ||
{ | ||
public class ModInfoContainer | ||
{ | ||
//Values(ID)(LANGUAGE) | ||
public Dictionary<string, Dictionary<string, string>> Values = new Dictionary<string, Dictionary<string, string>>(); | ||
|
||
public string Name { get; set; } | ||
public FileInfo FileInfoStringTable { get; set; } | ||
public bool FileHasBom { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace tabler.Logic.Classes | ||
{ | ||
public class ReleaseVersion | ||
{ | ||
public string Version { get; set; } | ||
public string HtmlUrl { get; set; } | ||
} | ||
} |
24 changes: 13 additions & 11 deletions
24
tabler/Classes/Settings.cs → tabler.Logic/Classes/Settings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 22 additions & 16 deletions
38
tabler/Classes/TranslationComponents.cs → ...er.Logic/Classes/TranslationComponents.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,42 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
|
||
namespace tabler { | ||
|
||
public class TranslationComponents { | ||
|
||
namespace tabler.Logic.Classes | ||
{ | ||
public class TranslationComponents | ||
{ | ||
private List<LanguageStatistics> _statistics; | ||
|
||
public List<ModInfoContainer> AllModInfo { get; set; } | ||
|
||
public List<string> Headers { get; set; } | ||
|
||
public List<LanguageStatistics> Statistics { | ||
get { | ||
if (_statistics == null) { | ||
public List<LanguageStatistics> Statistics | ||
{ | ||
get | ||
{ | ||
if (_statistics == null) | ||
{ | ||
_statistics = new List<LanguageStatistics>(); | ||
} | ||
|
||
return _statistics; | ||
} | ||
set { _statistics = value; } | ||
set => _statistics = value; | ||
} | ||
|
||
public int KeyCount { | ||
get { | ||
int count = 0; | ||
if (AllModInfo != null) { | ||
public int KeyCount | ||
{ | ||
get | ||
{ | ||
var count = 0; | ||
if (AllModInfo != null) | ||
{ | ||
count = AllModInfo.Sum(mi => mi.Values.Count); | ||
} | ||
|
||
return count; | ||
} | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using tabler.Logic.Helper; | ||
|
||
namespace tabler.Logic.Classes | ||
{ | ||
public class TranslationManager | ||
{ | ||
public const string COLUMN_MODNAME = "Mod"; | ||
public const string COLUMN_IDNAME = "ID"; | ||
public const string STRINGTABLE_NAME = "stringtable.xml"; | ||
|
||
private readonly FileInfo _fiExcelFile; | ||
public TranslationComponents TranslationComponents; | ||
|
||
public TranslationManager() | ||
{ | ||
} | ||
|
||
public TranslationManager(FileInfo fiExcelFile) | ||
{ | ||
_fiExcelFile = fiExcelFile; | ||
} | ||
|
||
|
||
private List<string> PrepareHeaders(List<string> headers, bool insertMod) | ||
{ | ||
headers = headers.OrderBy(l => l).ToList(); | ||
|
||
if (headers.Any(x => x.ToLowerInvariant() == "english")) | ||
{ | ||
headers.Remove("English"); | ||
headers.Insert(0, "English"); | ||
} | ||
|
||
headers.Insert(0, COLUMN_IDNAME); | ||
if (insertMod) | ||
{ | ||
headers.Insert(0, COLUMN_MODNAME); | ||
} | ||
|
||
|
||
//remove duplicates | ||
headers = headers.Distinct().ToList(); | ||
|
||
return headers; | ||
} | ||
|
||
|
||
private TranslationComponents GetTranslationComponents(DirectoryInfo lastPathToDataFiles, bool insertMod) | ||
{ | ||
var allStringtableFiles = FileSystemHelper.GetFilesByNameInDirectory(lastPathToDataFiles, STRINGTABLE_NAME, SearchOption.AllDirectories).ToList(); | ||
|
||
if (allStringtableFiles.Any() == false) | ||
{ | ||
return null; | ||
} | ||
|
||
var xh = new XmlHelper(); | ||
var transComp = xh.ParseXmlFiles(allStringtableFiles); | ||
|
||
transComp.Headers = PrepareHeaders(transComp.Headers, insertMod); | ||
|
||
TranslationComponents = transComp; | ||
return TranslationComponents; | ||
} | ||
|
||
|
||
private static bool SaveModInfosToXml(DirectoryInfo lastPathToDataFiles, List<ModInfoContainer> lstModInfos) | ||
{ | ||
//if going through mods instead of files, | ||
// we could create files | ||
// too tired :D -> TODO | ||
var filesByNameInDirectory = FileSystemHelper.GetFilesByNameInDirectory(lastPathToDataFiles, STRINGTABLE_NAME, SearchOption.AllDirectories); | ||
|
||
var xh = new XmlHelper(); | ||
xh.UpdateXmlFiles(filesByNameInDirectory, lstModInfos); | ||
|
||
return true; | ||
} | ||
|
||
|
||
public TranslationComponents GetGridData(DirectoryInfo lastPathToDataFiles) | ||
{ | ||
return GetTranslationComponents(lastPathToDataFiles, false); | ||
} | ||
|
||
public bool SaveGridData(DirectoryInfo lastPathToDataFiles, List<ModInfoContainer> lstModInfos) | ||
{ | ||
return SaveModInfosToXml(lastPathToDataFiles, lstModInfos); | ||
} | ||
} | ||
} |
28 changes: 17 additions & 11 deletions
28
tabler/Classes/DuplicateKeyException.cs → ...Logic/Exceptions/DuplicateKeyException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
using System; | ||
using System; | ||
|
||
namespace tabler { | ||
public class DuplicateKeyException : Exception { | ||
public string KeyName { get; set; } | ||
public string FileName { get; set; } | ||
public string EntryName { get; set; } | ||
|
||
public DuplicateKeyException(string keyName) { | ||
namespace tabler.Logic.Exceptions | ||
{ | ||
public class DuplicateKeyException : Exception | ||
{ | ||
public DuplicateKeyException(string keyName) | ||
{ | ||
KeyName = keyName; | ||
} | ||
public DuplicateKeyException(string keyName, string fileName) { | ||
|
||
public DuplicateKeyException(string keyName, string fileName) | ||
{ | ||
KeyName = keyName; | ||
FileName = fileName; | ||
} | ||
|
||
public DuplicateKeyException(string keyName, string fileName, string entryName) { | ||
public DuplicateKeyException(string keyName, string fileName, string entryName) | ||
{ | ||
KeyName = keyName; | ||
FileName = fileName; | ||
EntryName = entryName; | ||
} | ||
|
||
public string KeyName { get; set; } | ||
public string FileName { get; set; } | ||
public string EntryName { get; set; } | ||
} | ||
} | ||
} |
28 changes: 17 additions & 11 deletions
28
tabler/Classes/GenericXmlException.cs → ...r.Logic/Exceptions/GenericXmlException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
using System; | ||
using System; | ||
|
||
namespace tabler { | ||
public class GenericXmlException : Exception { | ||
public string KeyName { get; set; } | ||
public string FileName { get; set; } | ||
public string EntryName { get; set; } | ||
|
||
public GenericXmlException(string keyName) { | ||
namespace tabler.Logic.Exceptions | ||
{ | ||
public class GenericXmlException : Exception | ||
{ | ||
public GenericXmlException(string keyName) | ||
{ | ||
KeyName = keyName; | ||
} | ||
public GenericXmlException(string keyName, string fileName) { | ||
|
||
public GenericXmlException(string keyName, string fileName) | ||
{ | ||
KeyName = keyName; | ||
FileName = fileName; | ||
} | ||
|
||
public GenericXmlException(string keyName, string fileName, string entryName) { | ||
public GenericXmlException(string keyName, string fileName, string entryName) | ||
{ | ||
KeyName = keyName; | ||
FileName = fileName; | ||
EntryName = entryName; | ||
} | ||
|
||
public string KeyName { get; set; } | ||
public string FileName { get; set; } | ||
public string EntryName { get; set; } | ||
} | ||
} | ||
} |
Oops, something went wrong.