From c3d596b81c0f32ea55bd936e645be1e0d727e91d Mon Sep 17 00:00:00 2001 From: Peter Kurhajec <61538034+PTKu@users.noreply.github.com> Date: Mon, 16 Oct 2023 10:27:09 +0200 Subject: [PATCH] 247 new feature we will need a way to provide information about culture for localized plc strings (#249) * Create draft PR for #247 * add methods and modifies to provide localized tranlsation usingmethods * mend * fix parent object resource search --------- Co-authored-by: PTKu --- .../AXSharp - Backup.Abstractions.csproj | 60 ------------------- .../AXSharp.Connector/Connector/Connector.cs | 5 +- .../Localizations/Translator.cs | 12 ++-- 3 files changed, 6 insertions(+), 71 deletions(-) delete mode 100644 src/AXSharp.abstractions/src/AXSharp.Abstractions/AXSharp - Backup.Abstractions.csproj diff --git a/src/AXSharp.abstractions/src/AXSharp.Abstractions/AXSharp - Backup.Abstractions.csproj b/src/AXSharp.abstractions/src/AXSharp.Abstractions/AXSharp - Backup.Abstractions.csproj deleted file mode 100644 index 1a7e5cc4..00000000 --- a/src/AXSharp.abstractions/src/AXSharp.Abstractions/AXSharp - Backup.Abstractions.csproj +++ /dev/null @@ -1,60 +0,0 @@ - - - net6.0;net7.0 - - true - - true - false - - - Contains abstractions for AX# - - - https://github.com/ix-ax/ - https://github.com/ix-ax/axsharp - true - ix-ax - (c) Peter Kurhajec and Contributors - simatix-ax, PLC, industrial automation, SCADA, HMI - true - AXSharp abstractions - icon_128_128.png - git - True - snupkg - MIT - - Release notes are published here: - https://github.com/ix-ax/axsharp/releases - - NUGET-README.md - - - - - True - \ - - - True - \ - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - Full - - - diff --git a/src/AXSharp.connectors/src/AXSharp.Connector/Connector/Connector.cs b/src/AXSharp.connectors/src/AXSharp.Connector/Connector/Connector.cs index bd8f55f6..defe3b94 100644 --- a/src/AXSharp.connectors/src/AXSharp.Connector/Connector/Connector.cs +++ b/src/AXSharp.connectors/src/AXSharp.Connector/Connector/Connector.cs @@ -386,13 +386,12 @@ protected async void StartReadWriteOps() var sw = new Stopwatch(); long cycleCount = 0; var startTimeStamp = DateTime.Now; - + await Task.Run(async () => - { + { while (true) if (!IsRwLoopSuspended) { - //Thread.Sleep(ReadWriteCycleDelay); await Task.Delay(ReadWriteCycleDelay); sw.Restart(); try diff --git a/src/AXSharp.connectors/src/AXSharp.Connector/Localizations/Translator.cs b/src/AXSharp.connectors/src/AXSharp.Connector/Localizations/Translator.cs index b313353a..40100fb3 100644 --- a/src/AXSharp.connectors/src/AXSharp.Connector/Localizations/Translator.cs +++ b/src/AXSharp.connectors/src/AXSharp.Connector/Localizations/Translator.cs @@ -21,7 +21,7 @@ public class Translator private ResourceManager _resourceManager; - private CultureInfo Culture = new CultureInfo("sk-SK"); + private CultureInfo Culture = CultureInfo.InvariantCulture; /// /// Translates localized string. @@ -33,11 +33,7 @@ public string Translate(string originalString, ITwinElement twin, CultureInfo cu { if(culture == null) culture = Culture; - if (_resourceManager == null) - { - return originalString.CleanUpLocalizationTokens(); - } - + return Localize(originalString, twin, culture); } @@ -119,13 +115,13 @@ private string LocalizeInParents(string token, ITwinElement rootObj, CultureInfo public string Localize(string str, ITwinElement twinElement, CultureInfo culture) { - Console.WriteLine($"{str}"); + foreach (var localizable in GetTranslatable(str)) { var validIdentifier = LocalizationHelper.CreateId(localizable.CleanUpLocalizationTokens()); // Search in first level resource - var translation = _resourceManager.GetString(validIdentifier, culture); + var translation = _resourceManager?.GetString(validIdentifier, culture); // Search in parent resources if (translation == null)