Skip to content

Instantly share code, notes, and snippets.

View nadjibus's full-sized avatar

Nadjib Bait nadjibus

  • Independent .NET/Azure/Unity3D Developer
  • UAE
View GitHub Profile
@nadjibus
nadjibus / LocalizeTagHelper.cs
Created November 2, 2022 21:07
An ASP.NET Core Tag Helper that makes localization pretty straightforward
using Microsoft.AspNetCore.Razor.TagHelpers;
[HtmlTargetElement(LocalizeTagName)] // This is for <localize>Content here</localize> syntax
[HtmlTargetElement(Attributes = LocalizeTagName)] // This is for <p localize>Content here</p> syntax, which I personally prefer
public class LocalizeTagHelper : TagHelper
{
private const string LocalizeTagName = "localize";
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Reflection;
public class Program
{
public static void Main(string[] args)
{
BenchmarkRunner.Run(typeof(Program).Assembly);
}