diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/.DS_Store differ diff --git a/.idea/.idea.TP Blazor/.idea/.gitignore b/.idea/.idea.TP Blazor/.idea/.gitignore new file mode 100644 index 0000000..bc77b30 --- /dev/null +++ b/.idea/.idea.TP Blazor/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/projectSettingsUpdater.xml +/contentModel.xml +/.idea.TP Blazor.iml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.TP Blazor/.idea/.name b/.idea/.idea.TP Blazor/.idea/.name new file mode 100644 index 0000000..39eee29 --- /dev/null +++ b/.idea/.idea.TP Blazor/.idea/.name @@ -0,0 +1 @@ +TP Blazor \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..54a144d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/TP Blazor/bin/Debug/net7.0/TP Blazor.dll", + "args": [], + "cwd": "${workspaceFolder}/TP Blazor", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/TP Blazor/Pages/Index.razor b/TP Blazor/Pages/Index.razor index 6085c4a..7ea6cb1 100644 --- a/TP Blazor/Pages/Index.razor +++ b/TP Blazor/Pages/Index.razor @@ -1,9 +1,32 @@ @page "/" +@using System.Globalization +@using TP_Blazor.Components Index

Hello, world!

+

+ CurrentCulture: @CultureInfo.CurrentCulture +

+ + + +
+ Cake Token number - @context.Id +
+
+ +
+
@context.Name
+
$@context.Cost
+
+
+ + + +
-Welcome to your new app. diff --git a/TP Blazor/Program.cs b/TP Blazor/Program.cs index 371def7..41c3fd8 100644 --- a/TP Blazor/Program.cs +++ b/TP Blazor/Program.cs @@ -1,3 +1,4 @@ +using System.Globalization; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using TP_Blazor.Data; @@ -6,6 +7,10 @@ using Blazorise.Icons.FontAwesome; using Microsoft.Extensions.DependencyInjection; using Blazorise.Bootstrap; using Blazored.LocalStorage; +using TP_Blazor.Services; +using Blazored.Modal; +using Microsoft.AspNetCore.Localization; +using Microsoft.Extensions.Options; var builder = WebApplication.CreateBuilder(args); @@ -18,6 +23,17 @@ builder.Services.AddBlazorise() .AddBootstrapProviders() .AddBlazoredLocalStorage() .AddFontAwesomeIcons(); +builder.Services.AddBlazoredLocalStorage(); +builder.Services.AddBlazoredModal(); +builder.Services.AddControllers(); +builder.Services.AddLocalization(opt=>{opt.ResourcesPath="Ressources";}); +builder.Services.Configure(option => +{ + option.DefaultRequestCulture = new RequestCulture(new CultureInfo("en-US")); + option.SupportedCultures = new List { new CultureInfo("en-US"), new CultureInfo("fr-FR") }; + option.SupportedUICultures = new List { new CultureInfo("en-US"), new CultureInfo("fr-FR") }; +}); +builder.Services.AddScoped(); var app = builder.Build(); @@ -32,6 +48,18 @@ app.UseStaticFiles(); app.UseRouting(); +var options =((IApplicationBuilder)app).ApplicationServices.GetService>(); + +if (options?.Value != null) +{ + app.UseRequestLocalization(options.Value); +} + +app.UseEndpoints(endpoints => +{ + endpoints.MapControllers(); +}); + app.MapBlazorHub(); app.MapFallbackToPage("/_Host"); diff --git a/TP Blazor/wwwroot/images/.DS_Store b/TP Blazor/wwwroot/images/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/TP Blazor/wwwroot/images/.DS_Store differ