Skip to content

Commit

Permalink
Simplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinHo64 committed Apr 26, 2024
1 parent fd4e8f6 commit ff62b5c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 31 deletions.
37 changes: 7 additions & 30 deletions Library/Pages/CreateStructuredLearningOutcome.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@using Microsoft.Extensions.Localization
@using System.Diagnostics.CodeAnalysis
@using System.Globalization
@using System.Resources
Expand Down Expand Up @@ -27,7 +26,6 @@
<div class="min-w-[15%] text-md break-keep text-adlergrey">Englisch/English</div>
</MudSelectItem>
</MudSelect>
<MudText>CurrentCulture: @CultureInfo.CurrentCulture.Name ; Culture: @Culture.Name ; </MudText>
</div>

<div class="bg-adlerbgbright">
Expand Down Expand Up @@ -199,7 +197,7 @@

<div class="flex items-end">
<button class="h-8 m-2 hover:bg-adlergrey-100 hover:rounded">
<a class="mx-2 text-xs text-adlergrey-300" target="_blank" href="@GetLearningOutcomeExampleImage()">@GetLocalizerString("CreateStructuredLearningOutcome.Example")</a>
<a class="mx-2 text-xs text-adlergrey-300" target="_blank" href="@GetLocalizerString("CreateStructuredLearningOutcome.ExampleImagePath")">@GetLocalizerString("CreateStructuredLearningOutcome.Example")</a>
</button>

</div>
Expand All @@ -212,18 +210,13 @@

private Dictionary<TaxonomyLevel, string> TaxonomyLevelNames { get; set; } = null!;

[Inject, AllowNull] //can never be null, DI will throw exception on unresolved types
internal IStringLocalizer<CreateStructuredLearningOutcome> Localizer { get; set; }
private string IntroText => GetLocalizerString("CreateStructuredLearningOutcome.Intro");

private string IntroText => Culture.Name == "de-DE" ? "Sie können..." : "You will be able to...";
private string WherebyText => GetLocalizerString("CreateStructuredLearningOutcome.Whereby.Text");

private string WherebyText => Culture.Name == "de-DE" ? "indem Sie..." : "by...";

private string WhatForText => Culture.Name == "de-DE" ? "um..." : "to...";
private string WhatForText => GetLocalizerString("CreateStructuredLearningOutcome.WhatFor.Text");

private static ResourceManager _resourceManager = new ResourceManager("Library.Resources.Pages.CreateStructuredLearningOutcome", typeof(CreateStructuredLearningOutcome).Assembly);

private string GetLocalizerString(string key) => _resourceManager.GetString(key, Culture) ?? "String not found";
private static readonly ResourceManager ResourceManager = new("Library.Resources.Pages.CreateStructuredLearningOutcome", typeof(CreateStructuredLearningOutcome).Assembly);

private CultureInfo _culture = null!;

Expand All @@ -235,27 +228,11 @@
{
if (Equals(_culture, value)) return;
_culture = value;
CultureInfo.CurrentCulture = value;
CultureInfo.CurrentUICulture = value;
CultureInfo.DefaultThreadCurrentCulture = value;
CultureInfo.DefaultThreadCurrentUICulture = value;
OnCultureChange();
}
}

private string GetLearningOutcomeExampleImage()
{
@switch (CultureInfo.CurrentCulture.Name)
{
case "de-DE":
return "/CustomIcons/Beispiel-Lernziel_AT-de_LO-de.png";

case "en-DE":
return "/CustomIcons/Beispiel-Lernziel_AT-en_LO-en.png";
}

return "";
}

private string GetLocalizerString(string key) => ResourceManager.GetString(key, Culture) ?? "String not found";

[CascadingParameter, AllowNull] //injected by MudDialog
public MudDialogInstance DialogInstance { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,7 @@
<data name="CreateStructuredLearningOutcome.CopyToClipboard.Failure" xml:space="preserve">
<value>Fehler beim Kopieren in die Zwischenablage. Markieren und kopieren Sie alternativ Ihr formuliertes Lernziel/Lernergebnis im Vorschaufenster.</value>
</data>
<data name="CreateStructuredLearningOutcome.ExampleImagePath" xml:space="preserve">
<value>/CustomIcons/Beispiel-Lernziel_AT-de_LO-de.png</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<value>The formulation of a learning outcome focuses on the description of corresponding abilities, skills or competencies of the intended learning process of the students. These can be assigned to a taxonomy level based on the complexity of the cognitive processes. The definition of a taxonomy level (according to Anderson &amp; Krathwohl) serves to find a suitable verb of visibility in the further processing steps of the learning outcome formulation.</value>
</data>
<data name="CreateStructuredLearningOutcome.Intro" xml:space="preserve">
<value>You are able to...</value>
<value>You will be able to...</value>
</data>
<data name="CreateStructuredLearningOutcome.VerbOfVisibility" xml:space="preserve">
<value>Verb of visibility*</value>
Expand Down Expand Up @@ -132,4 +132,7 @@
<data name="CreateStructuredLearningOutcome.CopyToClipboard.Failure" xml:space="preserve">
<value>Error when copying to the clipboard. Alternatively, select and copy your formulated learning objective/learning outcome in the preview window.</value>
</data>
<data name="CreateStructuredLearningOutcome.ExampleImagePath" xml:space="preserve">
<value>/CustomIcons/Beispiel-Lernziel_AT-en_LO-en.png</value>
</data>
</root>

0 comments on commit ff62b5c

Please sign in to comment.