
Product
Introducing Socket MCP for Claude Desktop
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
fstonge.AspNetCore.Routing.Translation
Advanced tools
Under ConfigureServices, you need to add the following:
public void ConfigureServices(IServiceCollection services)
{
var builder = services.AddControllersWithViews(options =>
{
// Add filter to set current filter in cookies
options.AddCultureCookieFilter();
});
services.AddLocalization(options => options.ResourcesPath = "Resources");
builder.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix);
builder.AddDataAnnotationsLocalization();
// Inject required services, add routing and replace current LinkGenerator
services.AddRoutingLocalization(_configuration);
}
Under Configure, you need to add the following:
public void Configure(IApplicationBuilder app)
{
// Setup Request localization, Rewriter and Routing
app.UseRoutingLocalization();
app.UseStaticFiles();
// Setup Endpoints with culture
app.UseEndpointsLocalization();
}
You need to add the following structure in your appsettings:
{
"RoutingTranslation":
{
"SupportedCultures": "fr, en",
"DefaultCulture": "fr"
}
}
[Translate("en", "orders")]
[Translate("fr", "commandes")]
public class OrdersController : Controller
{
[Translate("fr", "liste")]
public IActionResult List()
{
return View();
}
}
<form asp-controller="orders" asp-action="list"></form>
<a asp-controller="products" asp-action="detail" asp-route-id="12"></a>
<a asp-route-culture="fr">French</a>
You can inject an IOptions that contains your configured cultures. Use the following:
IOptions<RequestLocalizationOptions> options
You can create your own custom validation by deriving from ICustomTranslation:
public class ProductTranslation : ICustomTranslation
{
public string ControllerName => "products";
public string ActionName => "detail";
public RewriteRule[] RewriteRules => new[]
{
new RewriteRule(
@"^([-a-zA-Z]+)\/([^\/]+)\/[-\/a-zA-Z0-9]+\/p-([=._a-zA-Z0-9]+)-.*$",
"$1/$2/detail/$3")
};
public string GenerateUrlPath(RouteValueDictionary values, FragmentString fragment)
{
return "/" +
$"{values.GetParameterValue(RouteValue.Culture)}/" +
$"{values.GetParameterValue(RouteValue.Controller)}/" +
"10-control-and-testing/" +
"14-testing-string/" +
$"p-{values.GetParameterValue(RouteValue.Id)}-testing-product-string";
}
}
Then add it as a scoped in Startup.cs:
// Add custom translations as singleton
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<ICustomTranslation, ProductTranslation>();
}
FAQs
Translate routes easily on your mvc app
We found that fstonge.aspnetcore.routing.translation demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.