Skip to content

Commit

Permalink
Merge pull request #139 from XanatosX/feature/change-json-translation
Browse files Browse the repository at this point in the history
Change json translation files
  • Loading branch information
XanatosX authored Apr 17, 2024
2 parents 9ab045f + 9bf420e commit b7b359a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 101 deletions.
64 changes: 14 additions & 50 deletions src/DefaultPlugins/Translations/de-DE.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,14 @@
[
{
"key": "script-displayname",
"value": "Skript ausführung"
},
{
"key": "script-description",
"value": "Diese Plugin erlaubt Ihnen Skript-Dateien mit dem Modular Tool Manager auszuführen"
},
{
"key": "binary-displayname",
"value": "Ausführbare Datei starten"
},
{
"key": "binary-description",
"value": "Diese Plugin erlaubt es Ihnen Binäre Dateien mit dem Modular Tool Manager auszuführen"
},
{
"key": "batch",
"value": "Batch-Skript"
},
{
"key": "cmd",
"value": "CMD-Skript"
},
{
"key": "powershell",
"value": "PowerShell-Skript"
},
{
"key": "executable",
"value": "Ausführbare-Datei"
},
{
"key": "error_cant_find_script_file",
"value": "Konnte das auszuführende Skript '{0}' nicht finden"
},
{
"key": "error_cant_find_binary_file",
"value": "Konnte ausführbare datei '{0}' nicht finden"
},
{
"key": "hide",
"value": "Terminal verstecken"
},
{
"key": "adminRequired",
"value": "Als Administrator ausführen"
}
]
{
"script-displayname": "Skript ausführung",
"script-description": "Diese Plugin erlaubt Ihnen Skript-Dateien mit dem Modular Tool Manager auszuführen",
"binary-displayname": "Ausführbare Datei starten",
"binary-description": "Diese Plugin erlaubt es Ihnen Binäre Dateien mit dem Modular Tool Manager auszuführen",
"batch": "Batch-Skript",
"cmd": "CMD-Skript",
"powershell": "PowerShell-Skript",
"executable": "Ausführbare-Datei",
"error_cant_find_script_file": "Konnte das auszuführende Skript '{0}' nicht finden",
"error_cant_find_binary_file": "Konnte ausführbare datei '{0}' nicht finden",
"hide": "Terminal verstecken",
"adminRequired": "Als Administrator ausführen"
}
64 changes: 14 additions & 50 deletions src/DefaultPlugins/Translations/en-EN.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,14 @@
[
{
"key": "script-displayname",
"value": "Script execution"
},
{
"key": "script-description",
"value": "This plugin will allow you to run scrip files with the modular tool manager"
},
{
"key": "binary-displayname",
"value": "Start executable binary file"
},
{
"key": "binary-description",
"value": "This plugin will allow you to run binary executable with the modular tool manager"
},
{
"key": "batch",
"value": "Batch-Script"
},
{
"key": "cmd",
"value": "CMD-Script"
},
{
"key": "powershell",
"value": "PowerShell-Script"
},
{
"key": "executable",
"value": "Executable-File"
},
{
"key": "error_cant_find_script_file",
"value": "Could not find script '{0}' to execute"
},
{
"key": "error_cant_find_binary_file",
"value": "Could not find binary file '{0}' to run"
},
{
"key": "hide",
"value": "Hide command line"
},
{
"key": "adminRequired",
"value": "Run as Administrator"
}
]
{
"script-displayname": "Script execution",
"script-description": "This plugin will allow you to run scrip files with the modular tool manager",
"binary-displayname": "Start executable binary file",
"binary-description": "This plugin will allow you to run binary executable with the modular tool manager",
"batch": "Batch-Script",
"cmd": "CMD-Script",
"powershell": "PowerShell-Script",
"executable": "Executable-File",
"error_cant_find_script_file": "Could not find script '{0}' to execute",
"error_cant_find_binary_file": "Could not find binary file '{0}' to run",
"hide": "Hide command line",
"adminRequired": "Run as Administrator"
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,20 @@ private string GetLanguageFromPath(string path)
/// <returns>A list with all possible translations</returns>
private List<TranslationModel> GetTranslationsFromFile(Assembly assembly, string cultureFile)
{
return JsonSerializer.Deserialize<List<TranslationModel>>(LoadResourceData(assembly, cultureFile)) ?? new();
List<TranslationModel> translations = new();
try
{
var data = JsonSerializer.Deserialize<Dictionary<string, string>>(LoadResourceData(assembly, cultureFile));
foreach (var item in data)
{
translations.Add(new TranslationModel { Key = item.Key, Value = item.Value });
}
}
catch (System.Exception e)
{
logger.LogError(e, "Error trying to parse translation file");
}
return translations;
}

/// <summary>
Expand Down

0 comments on commit b7b359a

Please sign in to comment.