Switching language, cultureSelector is working
continuous-integration/drone/push Build is passing Details

Projet
Dorian HODIN 2 years ago
parent 3e1a00572c
commit b21312d459

Binary file not shown.

@ -1,8 +1,8 @@
@using Models
@using ProjetBlazor.Models
<CascadingValue Value="@this">
<div class="css-grid">
<div><h1>List of items :</h1></div>
<div><h1>@Localizer["List"]</h1></div>
<DataGrid TItem="Item"
Data="@items"
ReadData="@OnReadData"
@ -10,7 +10,7 @@
PageSize="8"
ShowPager
Responsive>
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)" Caption="Image">
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)" Caption="@Localizer["Image"]">
<DisplayTemplate>
@if (!string.IsNullOrWhiteSpace(context.ImageBase64))
{
@ -22,12 +22,12 @@
}
</DisplayTemplate>
</DataGridColumn>
<DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" Caption="Nom" />
<DataGridColumn TItem="Item" Field="@nameof(Item.StackSize)" Caption="Taille Stack" />
<DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" Caption="@Localizer["Nom"]" />
<DataGridColumn TItem="Item" Field="@nameof(Item.StackSize)" Caption="@Localizer["Stack"]" />
</DataGrid>
</div>
<div><h1>My Inventory :</h1></div>
<div><h1>@Localizer["Inventory"]</h1></div>
<div class="css-recipe">
@for (int i = 0; i < 27; i++)
{
@ -36,4 +36,9 @@
}
</div>
<div class="actions" id="actions">
<div>@Localizer["Actions"]</div>
</div>
</CascadingValue>

@ -37,6 +37,9 @@ namespace ProjetBlazor.Components
[Inject]
internal IJSRuntime JavaScriptRuntime { get; set; }
[Inject]
public IStringLocalizer<ItemsList> Localizer { get; set; }
private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)

@ -11,6 +11,8 @@
}
.actions {
padding-top: 1px;
padding-left: 5px;
border: 1px solid black;
height: 250px;
clear: both;

@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;
namespace ProjetBlazor.Controllers
{
[Route("[controller]/[action]")]
public class CultureController : Controller
{
/// <summary>
/// Sets the culture.
/// </summary>
/// <param name="culture">The culture.</param>
/// <param name="redirectUri">The redirect URI.</param>
/// <returns>
/// The action result.
/// </returns>
public IActionResult SetCulture(string culture, string redirectUri)
{
if (culture != null)
{
// Define a cookie with the selected culture
this.HttpContext.Response.Cookies.Append(
CookieRequestCultureProvider.DefaultCookieName,
CookieRequestCultureProvider.MakeCookieValue(
new RequestCulture(culture)));
}
return this.LocalRedirect(redirectUri);
}
}
}

@ -1,7 +1,9 @@
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using ProjetBlazor.Components;
using ProjetBlazor.Models;
using ProjetBlazor.Services;
using System.Collections.Generic;
namespace ProjetBlazor.Pages
{

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Actions" xml:space="preserve">
<value>Actions</value>
</data>
<data name="Image" xml:space="preserve">
<value>Item Picture</value>
</data>
<data name="Inventory" xml:space="preserve">
<value>My Inventory :</value>
</data>
<data name="List" xml:space="preserve">
<value>List of Items :</value>
</data>
<data name="Nom" xml:space="preserve">
<value>Name</value>
</data>
<data name="Stack" xml:space="preserve">
<value>Stack Size</value>
</data>
</root>

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Actions" xml:space="preserve">
<value>Actions</value>
</data>
<data name="Image" xml:space="preserve">
<value>Image de l'item</value>
</data>
<data name="Inventory" xml:space="preserve">
<value>Mon Inventaire :</value>
</data>
<data name="List" xml:space="preserve">
<value>Liste des Items :</value>
</data>
<data name="Nom" xml:space="preserve">
<value>Nom</value>
</data>
<data name="Stack" xml:space="preserve">
<value>Taille du Stack</value>
</data>
</root>

@ -0,0 +1,45 @@
@using System.Globalization
@inject NavigationManager NavigationManager
<p>
<label>
<t>Select your language:</t>
<select @bind="Culture">
@foreach (var culture in supportedCultures)
{
<option value="@culture">@culture.DisplayName</option>
}
</select>
</label>
</p>
@code
{
private CultureInfo[] supportedCultures = new[]
{
new CultureInfo("en-US"),
new CultureInfo("fr-FR")
};
private CultureInfo Culture
{
get => CultureInfo.CurrentCulture;
set
{
if (CultureInfo.CurrentUICulture == value)
{
return;
}
var culture = value.Name.ToLower(CultureInfo.InvariantCulture);
var uri = new Uri(this.NavigationManager.Uri).GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped);
var query = $"?culture={Uri.EscapeDataString(culture)}&" + $"redirectUri={Uri.EscapeDataString(uri)}";
// Redirect the user to the culture controller to set the cookie
this.NavigationManager.NavigateTo("/Culture/SetCulture" + query, forceLoad: true);
}
}
}

@ -0,0 +1,3 @@
t {
color : whitesmoke;
}

@ -7,9 +7,9 @@
<main>
<div class="top-row px-4">
<img src="/images/minecraft.png" height="31px"/>
<CultureSelector />
</div>
<article class="content px-4">
@Body
</article>

@ -20,3 +20,4 @@ main {
article{
background-image: url("../wwwroot/images/background.png");
}

@ -40,6 +40,10 @@ build_metadata.AdditionalFiles.CssScope = b-qx2dj81qjg
build_metadata.AdditionalFiles.TargetPath = Q29tcG9uZW50c1xJdGVtc0xpc3QucmF6b3I=
build_metadata.AdditionalFiles.CssScope = b-7ik5rr5b8g
[C:/Users/Dorian/Documents/Blazor/Code/ProjetBlazor/Shared/CultureSelector.razor]
build_metadata.AdditionalFiles.TargetPath = U2hhcmVkXEN1bHR1cmVTZWxlY3Rvci5yYXpvcg==
build_metadata.AdditionalFiles.CssScope = b-c86f565ybb
[C:/Users/Dorian/Documents/Blazor/Code/ProjetBlazor/Shared/MainLayout.razor]
build_metadata.AdditionalFiles.TargetPath = U2hhcmVkXE1haW5MYXlvdXQucmF6b3I=
build_metadata.AdditionalFiles.CssScope = b-6fq4tjte4h

@ -1 +1 @@
229bd16bb9b4923f80464bcfeab9862ed937a469
47b84b5f92ec96be88b4551f09de2a86289c4cba

@ -91,3 +91,11 @@ C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\bin\Debug\net6.0\Microsoft.Ex
C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\bin\Debug\net6.0\Microsoft.Extensions.Options.ConfigurationExtensions.dll
C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\obj\Debug\net6.0\scopedcss\Components\ItemsList.razor.rz.scp.css
C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\obj\Debug\net6.0\scopedcss\Components\GetItemInInventory.razor.rz.scp.css
C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\obj\Debug\net6.0\ProjetBlazor.csproj.GenerateResource.cache
C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\bin\Debug\net6.0\fr-FR\ProjetBlazor.resources.dll
C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\obj\Debug\net6.0\fr-FR\ProjetBlazor.resources.dll
C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\obj\Debug\net6.0\scopedcss\Shared\CultureSelector.razor.rz.scp.css
C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\obj\Debug\net6.0\ProjetBlazor.Resources.Components.ItemsList.fr-FR.resources
C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\bin\Debug\net6.0\en-US\ProjetBlazor.resources.dll
C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\obj\Debug\net6.0\ProjetBlazor.Resources.Components.ItemsList.en-US.resources
C:\Users\Dorian\Documents\Blazor\Code\ProjetBlazor\obj\Debug\net6.0\en-US\ProjetBlazor.resources.dll

File diff suppressed because one or more lines are too long

@ -11,6 +11,8 @@
}
.actions[b-7ik5rr5b8g] {
padding-top: 1px;
padding-left: 5px;
border: 1px solid black;
height: 250px;
clear: both;

@ -20,3 +20,4 @@ main[b-6fq4tjte4h] {
article[b-6fq4tjte4h]{
background-image: url("../wwwroot/images/background.png");
}

@ -22,10 +22,16 @@
}
.actions[b-7ik5rr5b8g] {
padding-top: 1px;
padding-left: 5px;
border: 1px solid black;
height: 250px;
clear: both;
}
/* _content/ProjetBlazor/Shared/CultureSelector.razor.rz.scp.css */
t[b-c86f565ybb] {
color : whitesmoke;
}
/* _content/ProjetBlazor/Shared/MainLayout.razor.rz.scp.css */
.page[b-6fq4tjte4h] {
position: relative;
@ -49,3 +55,4 @@ main[b-6fq4tjte4h] {
article[b-6fq4tjte4h]{
background-image: url("../wwwroot/images/background.png");
}

@ -20,10 +20,16 @@
}
.actions[b-7ik5rr5b8g] {
padding-top: 1px;
padding-left: 5px;
border: 1px solid black;
height: 250px;
clear: both;
}
/* _content/ProjetBlazor/Shared/CultureSelector.razor.rz.scp.css */
t[b-c86f565ybb] {
color : whitesmoke;
}
/* _content/ProjetBlazor/Shared/MainLayout.razor.rz.scp.css */
.page[b-6fq4tjte4h] {
position: relative;
@ -47,3 +53,4 @@ main[b-6fq4tjte4h] {
article[b-6fq4tjte4h]{
background-image: url("../wwwroot/images/background.png");
}

Loading…
Cancel
Save