refactor: remove i18n
This can be a problem for Future Me™️
This commit is contained in:
parent
e93db2c7a0
commit
75eed18bc8
@ -1,17 +0,0 @@
|
|||||||
namespace OliverBooth.Middleware;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Extension methods for <see cref="CultureRedirectMiddleware" />.
|
|
||||||
/// </summary>
|
|
||||||
internal static class CultureRedirectExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Adds the <see cref="CultureRedirectMiddleware" /> to the application's request pipeline.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="builder">The application builder.</param>
|
|
||||||
/// <returns>The application builder.</returns>
|
|
||||||
public static IApplicationBuilder UseCultureRedirect(this IApplicationBuilder builder)
|
|
||||||
{
|
|
||||||
return builder.UseMiddleware<CultureRedirectMiddleware>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
using System.Globalization;
|
|
||||||
|
|
||||||
namespace OliverBooth.Middleware;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Redirects requests to the default culture if the culture is not specified in the URL.
|
|
||||||
/// </summary>
|
|
||||||
internal sealed class CultureRedirectMiddleware
|
|
||||||
{
|
|
||||||
private readonly RequestDelegate _next;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="CultureRedirectMiddleware" /> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="next">The next request delegate.</param>
|
|
||||||
public CultureRedirectMiddleware(RequestDelegate next)
|
|
||||||
{
|
|
||||||
_next = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invokes the middleware.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="context">The HTTP context.</param>
|
|
||||||
public async Task Invoke(HttpContext context)
|
|
||||||
{
|
|
||||||
const StringComparison comparison = StringComparison.OrdinalIgnoreCase;
|
|
||||||
|
|
||||||
HttpRequest request = context.Request;
|
|
||||||
PathString requestPath = request.Path;
|
|
||||||
|
|
||||||
if (requestPath.HasValue)
|
|
||||||
{
|
|
||||||
string[] pathSegments = requestPath.Value.Split('/');
|
|
||||||
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
|
|
||||||
|
|
||||||
if (pathSegments.Length >= 2 && cultures.Any(CultureMatch))
|
|
||||||
{
|
|
||||||
await _next(context);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CultureMatch(CultureInfo culture)
|
|
||||||
{
|
|
||||||
string segment = pathSegments[1].Split('-')[0];
|
|
||||||
return string.Equals(culture.TwoLetterISOLanguageName, segment, comparison);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const string defaultCulture = "en";
|
|
||||||
var redirectUrl = $"/{defaultCulture}{requestPath}{request.QueryString}";
|
|
||||||
context.Response.Redirect(redirectUrl);
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,8 +5,6 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<TargetCulture>en</TargetCulture>
|
|
||||||
<UICulture>en</UICulture>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -16,7 +14,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="7.0.9"/>
|
|
||||||
<PackageReference Include="X10D" Version="3.2.2"/>
|
<PackageReference Include="X10D" Version="3.2.2"/>
|
||||||
<PackageReference Include="X10D.Hosting" Version="3.2.2"/>
|
<PackageReference Include="X10D.Hosting" Version="3.2.2"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@page "/{culture=en}/contact"
|
@page
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Contact";
|
ViewData["Title"] = "Contact";
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@page "/{culture=en}/contact/job-opportunity"
|
@page "/contact/job-opportunity"
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Contact";
|
ViewData["Title"] = "Contact";
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@page "/{culture=en}/contact/open-source"
|
@page "/contact/open-source"
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Contact";
|
ViewData["Title"] = "Contact";
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
@page "/{culture=en}/contact/other"
|
@page
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Contact";
|
ViewData["Title"] = "Contact";
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@page "/{culture=en}/contact/privacy/{which?}"
|
@page "/contact/privacy/{which?}"
|
||||||
@model OliverBooth.Pages.Contact.Privacy
|
@model OliverBooth.Pages.Contact.Privacy
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Contact";
|
ViewData["Title"] = "Contact";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@page "/{culture=en}/contact/project-idea"
|
@page "/contact/project-idea"
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Contact";
|
ViewData["Title"] = "Contact";
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@page "/{culture=en}/contact/technical-help"
|
@page "/contact/technical-help"
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Contact";
|
ViewData["Title"] = "Contact";
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
@page "/{culture=en}/donate"
|
@page
|
||||||
@using Microsoft.AspNetCore.Mvc.Localization
|
|
||||||
@inject IViewLocalizer Localizer
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Donate";
|
ViewData["Title"] = "Donate";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h1 class="display-4">@Localizer["Donate"]</h1>
|
<h1 class="display-4">Donate</h1>
|
||||||
<p>@Localizer["DonatePart1"]</p>
|
<p>
|
||||||
|
If you like what I do and would like to donate money to me and fund my coffee addiction, there are a few options for
|
||||||
|
you!
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<script type="text/javascript" src="https://storage.ko-fi.com/cdn/widget/Widget_2.js"></script>
|
<script type="text/javascript" src="https://storage.ko-fi.com/cdn/widget/Widget_2.js"></script>
|
||||||
@ -19,7 +20,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>@Localizer["DonatePart2"]</p>
|
<p>I also accept cryptocurrency donations.</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>BTC: 1LmXvavJr1omscfkXjp7A4VyNf3XhKP9JK</li>
|
<li>BTC: 1LmXvavJr1omscfkXjp7A4VyNf3XhKP9JK</li>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@page "/{culture=en}/error/{code:int?}"
|
@page "/error/{code:int?}"
|
||||||
@model OliverBooth.Pages.ErrorModel
|
@model OliverBooth.Pages.ErrorModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Error";
|
ViewData["Title"] = "Error";
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
@page "/{culture=en}"
|
@page
|
||||||
@using Microsoft.AspNetCore.Mvc.Localization
|
|
||||||
@inject IViewLocalizer Localizer
|
|
||||||
|
|
||||||
<h1 class="display-4">@Localizer["HomeTitle"]</h1>
|
<h1 class="display-4">Hi, I'm Oliver.</h1>
|
||||||
<p class="lead">@Localizer["HomeSubtitle"]</p>
|
<p class="lead">I'm a tech enthusiast, coffee drinker, and software developer.</p>
|
||||||
|
|
||||||
<p>@Localizer.GetHtml("Intro1")</p>
|
<p>
|
||||||
|
My primary focus is C#, though I have dabbled in several other languages such as Java, Kotlin, VB, C/C++, Python,
|
||||||
|
and others. Over the years I've built up a collection of projects. Some of which I'm extremely proud of, and others
|
||||||
|
I've quietly abandoned and buried. I'm currently working on a few projects that I hope to release in the near
|
||||||
|
future, but in the meantime, feel free to check out some of my <a asp-page="/Projects/Index">previous work.</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
I've also written a few <a asp-page="/tutorials/index">tutorials</a> on various topics, usually involving
|
I've also written a few <a asp-page="/tutorials/index">tutorials</a> on various topics, usually involving
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
@page "/{culture=en}/privacy/google-play"
|
@page "/privacy/google-play"
|
||||||
@model OliverBooth.Pages.Privacy.GooglePlay
|
@model OliverBooth.Pages.Privacy.GooglePlay
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Google Play Privacy Policy";
|
ViewData["Title"] = "Google Play Privacy Policy";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h1 class="display-4">@ViewData["Title"]</h1>
|
<h1 class="display-4">@ViewData["Title"]</h1>
|
||||||
<p class="lead">Last Updated: 26 May 2023</p>
|
<p class="lead">Last Updated: 26 May 2023</p>
|
||||||
<p>This Privacy Policy describes how your personal information is collected, used, and shared when you use or interact with applications that I publish on the <a href="https://play.google.com/store/">Google Play Store</a>.</p>
|
<p>This Privacy Policy describes how your personal information is collected, used, and shared when you use or interact with applications that I publish on the <a href="https://play.google.com/store/">Google Play Store</a>.</p>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
@page "/{culture=en}/privacy"
|
@page
|
||||||
@model OliverBooth.Pages.Privacy.Index
|
@model OliverBooth.Pages.Privacy.Index
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Privacy Policy";
|
ViewData["Title"] = "Privacy Policy";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h1 class="display-4">@ViewData["Title"]</h1>
|
<h1 class="display-4">@ViewData["Title"]</h1>
|
||||||
<p class="lead">Last Updated: 26 May 2023</p>
|
<p class="lead">Last Updated: 26 May 2023</p>
|
||||||
<p>This Privacy Policy describes how your personal information is collected, used, and shared when you visit or interact with my website <a href="https://oliverbooth.dev/">oliverbooth.dev</a>.</p>
|
<p>This Privacy Policy describes how your personal information is collected, used, and shared when you visit or interact with my website <a href="https://oliverbooth.dev/">oliverbooth.dev</a>.</p>
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
@using System.Globalization
|
|
||||||
@using Microsoft.AspNetCore.Localization
|
|
||||||
@using Microsoft.AspNetCore.Mvc.Localization
|
|
||||||
@inject IViewLocalizer Localizer
|
|
||||||
@{
|
|
||||||
CultureInfo? requestCulture = Context.Features.Get<IRequestCultureFeature>()?.RequestCulture.Culture;
|
|
||||||
string culture = (requestCulture ?? CultureInfo.CurrentCulture).TwoLetterISOLanguageName;
|
|
||||||
}
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
@ -33,26 +25,28 @@
|
|||||||
<nav>
|
<nav>
|
||||||
<ul class="site-nav">
|
<ul class="site-nav">
|
||||||
<li>
|
<li>
|
||||||
<a asp-page="/index" asp-route-culture="@culture">@Localizer["Home"]</a>
|
<a asp-page="/index">Home</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://blog.oliverbooth.dev">Blog</a>
|
<a href="https://blog.oliverbooth.dev">Blog</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a asp-page="/tutorials/index" asp-route-culture="@culture">@Localizer["Tutorials"]</a>
|
<a asp-page="/tutorials/index">Tutorials</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a asp-page="/projects/index" asp-route-culture="@culture">@Localizer["Projects"]</a>
|
<a asp-page="/projects/index">Projects</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a asp-page="/contact/index" asp-route-culture="@culture">@Localizer["Contact"]</a>
|
<a asp-page="/contact/index">Contact</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a asp-page="/donate" asp-route-culture="@culture">@Localizer["Donate"]</a>
|
<a asp-page="/donate">Donate</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<hr class="page-separator"/>
|
|
||||||
|
<div style="margin:50px 0;"></div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<main role="main" class="pb-3">
|
<main role="main" class="pb-3">
|
||||||
@RenderBody()
|
@RenderBody()
|
||||||
@ -61,7 +55,7 @@
|
|||||||
|
|
||||||
<footer class="footer text-muted">
|
<footer class="footer text-muted">
|
||||||
<div class="container text-center">
|
<div class="container text-center">
|
||||||
© @DateTime.UtcNow.Year • <a asp-area="" asp-page="/privacy/index" asp-route-culture="@culture">@Localizer["Privacy"]</a>
|
© @DateTime.UtcNow.Year • <a asp-area="" asp-page="/privacy/index">Privacy</a>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<data name="HomeTitle" xml:space="preserve">
|
|
||||||
<value>Hi, I'm Oliver.</value>
|
|
||||||
</data>
|
|
||||||
<data name="HomeSubtitle" xml:space="preserve">
|
|
||||||
<value>I'm a tech enthusiast, coffee drinker, and software developer.</value>
|
|
||||||
</data>
|
|
||||||
<data name="Intro1" xml:space="preserve">
|
|
||||||
<value>My primary focus is C#, though I have dabbled in several other languages such as Java, Kotlin, VB, C/C++, Python, and others. Over the years I've built up a collection of projects. Some of which I'm extremely proud of, and others I've quietly abandoned and buried. I'm currently working on a few projects that I hope to release in the near future, but in the meantime, feel free to check out some of my <a asp-page="/Projects/Index">previous work.</a></value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<data name="HomeTitle" xml:space="preserve">
|
|
||||||
<value>Salut, je suis Oliver.</value>
|
|
||||||
</data>
|
|
||||||
<data name="HomeSubtitle" xml:space="preserve">
|
|
||||||
<value>Je suis un passionné de technologie, un buveur de café, et un developpeur de logiciels.</value>
|
|
||||||
</data>
|
|
||||||
<data name="Intro1" xml:space="preserve">
|
|
||||||
<value>Je me concentre principalement sur C#, bien que j'ai également expérimenté plusieurs autres langues telles que Java, Kotlin, VB, C / C++, Python et d'autres. Au fil des ans, j'ai constitué une collection de projets. Certains dont je suis extrêmement fier, et d'autres que j'ai tranquillement abandonnés et enterrés. Je travaille actuellement sur quelques projets que j'espère publier dans un proche avenir, mais en attendant, n'hésitez pas à consulter certains de mes <a asp-page="/Projects/Index">travaux précédents.</a></value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
Loading…
Reference in New Issue
Block a user