Skip to content

Commit

Permalink
247 new feature we will need a way to provide information about cultu…
Browse files Browse the repository at this point in the history
…re 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 <PTKu@users.noreply.github.com>
  • Loading branch information
PTKu and PTKu authored Oct 16, 2023
1 parent 4225ad2 commit c3d596b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 71 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Translator

private ResourceManager _resourceManager;

private CultureInfo Culture = new CultureInfo("sk-SK");
private CultureInfo Culture = CultureInfo.InvariantCulture;

/// <summary>
/// Translates localized string.
Expand All @@ -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);
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c3d596b

Please sign in to comment.