From 2d43905cb3ab6f5841709abf4d86d1f58674a63e Mon Sep 17 00:00:00 2001 From: Lucie Bedouret Date: Sun, 18 Dec 2022 15:01:14 +0100 Subject: [PATCH] Add: language chagement for the inventory grid part --- .../Components/InventoryItem.razor | 2 +- .../Components/InventoryItem.razor.cs | 4 + .../myBlazorApp/Components/MyInventory.razor | 2 +- .../Components/MyInventory.razor.cs | 5 + myBlazorApp/myBlazorApp/Pages/List.razor.cs | 4 +- .../Components.InventoryItem.Designer.cs | 69 ++++++++++ ...Components.InventoryItem.fr-FR.Designer.cs | 69 ++++++++++ .../Components.InventoryItem.fr-FR.resx | 124 ++++++++++++++++++ .../Resources/Components.InventoryItem.resx | 124 ++++++++++++++++++ .../Components.MyInventory.Designer.cs | 69 ++++++++++ .../Components.MyInventory.fr-FR.resx | 124 ++++++++++++++++++ .../Resources/Components.MyInventory.resx | 124 ++++++++++++++++++ myBlazorApp/myBlazorApp/myBlazorApp.csproj | 21 +++ 13 files changed, 737 insertions(+), 4 deletions(-) create mode 100644 myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.Designer.cs create mode 100644 myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.fr-FR.Designer.cs create mode 100644 myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.fr-FR.resx create mode 100644 myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.resx create mode 100644 myBlazorApp/myBlazorApp/Resources/Components.MyInventory.Designer.cs create mode 100644 myBlazorApp/myBlazorApp/Resources/Components.MyInventory.fr-FR.resx create mode 100644 myBlazorApp/myBlazorApp/Resources/Components.MyInventory.resx diff --git a/myBlazorApp/myBlazorApp/Components/InventoryItem.razor b/myBlazorApp/myBlazorApp/Components/InventoryItem.razor index 97abaf3..b1abcfe 100644 --- a/myBlazorApp/myBlazorApp/Components/InventoryItem.razor +++ b/myBlazorApp/myBlazorApp/Components/InventoryItem.razor @@ -15,7 +15,7 @@ } else { -

Empty

+

@Localizer["emptyElement"]

} diff --git a/myBlazorApp/myBlazorApp/Components/InventoryItem.razor.cs b/myBlazorApp/myBlazorApp/Components/InventoryItem.razor.cs index 0e50916..b03b669 100644 --- a/myBlazorApp/myBlazorApp/Components/InventoryItem.razor.cs +++ b/myBlazorApp/myBlazorApp/Components/InventoryItem.razor.cs @@ -4,6 +4,7 @@ namespace myBlazorApp.Components; using System.Reflection.Metadata; using Blazorise; using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; using myBlazorApp.Models; public partial class InventoryItem @@ -23,6 +24,9 @@ public partial class InventoryItem [Parameter] public bool NoDrop { get; set; } + [Inject] + public IStringLocalizer Localizer { get; set; } + [CascadingParameter] public MyInventory Parent { get; set; } diff --git a/myBlazorApp/myBlazorApp/Components/MyInventory.razor b/myBlazorApp/myBlazorApp/Components/MyInventory.razor index db46643..f5934a4 100644 --- a/myBlazorApp/myBlazorApp/Components/MyInventory.razor +++ b/myBlazorApp/myBlazorApp/Components/MyInventory.razor @@ -1,6 +1,6 @@ @using myBlazorApp.Models -

My Inventory

+

@Localizer["Title"]

@foreach(InventoryListItem i in ItemsInventory) diff --git a/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs b/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs index 627dd62..12d0f5c 100644 --- a/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs +++ b/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs @@ -1,7 +1,9 @@ using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; using Microsoft.JSInterop; using myBlazorApp.Models; using myBlazorApp.Services; @@ -32,6 +34,9 @@ namespace myBlazorApp.Components [Inject] public IDataService DataService { get; set; } + [Inject] + public IStringLocalizer Localizer { get; set; } + [Inject] public IWebHostEnvironment WebHostEnvironment { get; set; } diff --git a/myBlazorApp/myBlazorApp/Pages/List.razor.cs b/myBlazorApp/myBlazorApp/Pages/List.razor.cs index a917aa8..cafbca1 100644 --- a/myBlazorApp/myBlazorApp/Pages/List.razor.cs +++ b/myBlazorApp/myBlazorApp/Pages/List.razor.cs @@ -20,8 +20,8 @@ namespace myBlazorApp.Pages private int totalItem; - [Inject] - public IDataService DataService { get; set; } + [Inject] + public IDataService DataService { get; set; } [Inject] public IWebHostEnvironment WebHostEnvironment { get; set; } diff --git a/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.Designer.cs b/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.Designer.cs new file mode 100644 index 0000000..494ecb6 --- /dev/null +++ b/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.Designer.cs @@ -0,0 +1,69 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace myBlazorApp.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// This class was generated by MSBuild using the GenerateResource task. + /// To add or remove a member, edit your .resx file then rerun MSBuild. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Build.Tasks.StronglyTypedResourceBuilder", "15.1.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Components_InventoryItem { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Components_InventoryItem() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("myBlazorApp.Resources.Components.InventoryItem", typeof(Components_InventoryItem).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Empty. + /// + internal static string emptyElement { + get { + return ResourceManager.GetString("emptyElement", resourceCulture); + } + } + } +} diff --git a/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.fr-FR.Designer.cs b/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.fr-FR.Designer.cs new file mode 100644 index 0000000..5b87e5a --- /dev/null +++ b/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.fr-FR.Designer.cs @@ -0,0 +1,69 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace myBlazorApp.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// This class was generated by MSBuild using the GenerateResource task. + /// To add or remove a member, edit your .resx file then rerun MSBuild. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Build.Tasks.StronglyTypedResourceBuilder", "15.1.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Components_InventoryItem_fr_FR { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Components_InventoryItem_fr_FR() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("myBlazorApp.Resources.Components.InventoryItem.fr-FR", typeof(Components_InventoryItem_fr_FR).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Vide. + /// + internal static string emptyElement { + get { + return ResourceManager.GetString("emptyElement", resourceCulture); + } + } + } +} diff --git a/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.fr-FR.resx b/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.fr-FR.resx new file mode 100644 index 0000000..3487613 --- /dev/null +++ b/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.fr-FR.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Vide + + + \ No newline at end of file diff --git a/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.resx b/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.resx new file mode 100644 index 0000000..9897740 --- /dev/null +++ b/myBlazorApp/myBlazorApp/Resources/Components.InventoryItem.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Empty + + + \ No newline at end of file diff --git a/myBlazorApp/myBlazorApp/Resources/Components.MyInventory.Designer.cs b/myBlazorApp/myBlazorApp/Resources/Components.MyInventory.Designer.cs new file mode 100644 index 0000000..8ecbbf5 --- /dev/null +++ b/myBlazorApp/myBlazorApp/Resources/Components.MyInventory.Designer.cs @@ -0,0 +1,69 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace myBlazorApp.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// This class was generated by MSBuild using the GenerateResource task. + /// To add or remove a member, edit your .resx file then rerun MSBuild. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Build.Tasks.StronglyTypedResourceBuilder", "15.1.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Components_MyInventory { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Components_MyInventory() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("myBlazorApp.Resources.Components.MyInventory", typeof(Components_MyInventory).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to My inventory. + /// + internal static string Title { + get { + return ResourceManager.GetString("Title", resourceCulture); + } + } + } +} diff --git a/myBlazorApp/myBlazorApp/Resources/Components.MyInventory.fr-FR.resx b/myBlazorApp/myBlazorApp/Resources/Components.MyInventory.fr-FR.resx new file mode 100644 index 0000000..a7d77e7 --- /dev/null +++ b/myBlazorApp/myBlazorApp/Resources/Components.MyInventory.fr-FR.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Mon inventaire + + + \ No newline at end of file diff --git a/myBlazorApp/myBlazorApp/Resources/Components.MyInventory.resx b/myBlazorApp/myBlazorApp/Resources/Components.MyInventory.resx new file mode 100644 index 0000000..471398d --- /dev/null +++ b/myBlazorApp/myBlazorApp/Resources/Components.MyInventory.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + My inventory + + + \ No newline at end of file diff --git a/myBlazorApp/myBlazorApp/myBlazorApp.csproj b/myBlazorApp/myBlazorApp/myBlazorApp.csproj index 234a850..a37021c 100644 --- a/myBlazorApp/myBlazorApp/myBlazorApp.csproj +++ b/myBlazorApp/myBlazorApp/myBlazorApp.csproj @@ -53,6 +53,18 @@ ResXFileCodeGenerator Pages.List.fr-FR.Designer.cs + + ResXFileCodeGenerator + Components.MyInventory.Designer.cs + + + ResXFileCodeGenerator + Components.InventoryItem.Designer.cs + + + ResXFileCodeGenerator + Components.InventoryItem.fr-FR.Designer.cs + @@ -61,5 +73,14 @@ Pages.List.fr-FR.resx + + Components.MyInventory.resx + + + Components.InventoryItem.resx + + + Components.InventoryItem.fr-FR.resx +