Skip to content

Commit

Permalink
Merge branch 'release/v0.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bux committed Jan 4, 2019
2 parents 8041dad + a77a5bf commit 2fb8764
Show file tree
Hide file tree
Showing 64 changed files with 3,438 additions and 2,131 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
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
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; }
}
}
}
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; }
}
}
}
10 changes: 10 additions & 0 deletions tabler.Logic/Classes/ReleaseVersion.cs
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 tabler/Classes/Settings.cs → tabler.Logic/Classes/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
namespace tabler {
public class Settings {

public IndentationSettings IndentationSettings { get; set; }

public int TabSize { get; set; }

public bool RemoveEmptyNodes { get; set; }

public Settings() {
namespace tabler.Logic.Classes
{
public class Settings
{
public Settings()
{
// defaults
IndentationSettings = IndentationSettings.Spaces;
TabSize = 4;
RemoveEmptyNodes = true;
}

public IndentationSettings IndentationSettings { get; set; }

public int TabSize { get; set; }

public bool RemoveEmptyNodes { get; set; }
}

public enum IndentationSettings {
public enum IndentationSettings
{
Spaces = 0,
Tabs = 1
}
Expand Down
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;
}
}
}

}
}
95 changes: 95 additions & 0 deletions tabler.Logic/Classes/TranslationManager.cs
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);
}
}
}
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; }
}
}
}
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; }
}
}
}
Loading

0 comments on commit 2fb8764

Please sign in to comment.