Blazor.Untranslated
0.1.0
dotnet add package Blazor.Untranslated --version 0.1.0
NuGet\Install-Package Blazor.Untranslated -Version 0.1.0
<PackageReference Include="Blazor.Untranslated" Version="0.1.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Blazor.Untranslated" Version="0.1.0" />
<PackageReference Include="Blazor.Untranslated"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Blazor.Untranslated --version 0.1.0
#r "nuget: Blazor.Untranslated, 0.1.0"
#:package Blazor.Untranslated@0.1.0
#addin nuget:?package=Blazor.Untranslated&version=0.1.0
#tool nuget:?package=Blazor.Untranslated&version=0.1.0
Blazor.Untranslated
A Roslyn analyzer that fails the build when a Blazor component renders literal text instead of a localized
resource. Rule UNT001, for .razor components in Blazor Server, WebAssembly, static SSR and MAUI Hybrid. MIT.
Blazor.Untranslated grew out of Adjudeca, a Blazor site in three languages, where it keeps every page
translatable. It is 0.x, so any minor version may change what the rule reports.
No support. Built for my own projects and shared as is: issues and pull requests aren't monitored, and any release may change or break things.
What it catches
<h1>Coming soon</h1>
<img src="logo.svg" alt="Company logo" />
<Card Title="Latest news" />
Pages/Home.razor(1,5): error UNT001: Literal text "Coming soon" must come from a resource
Pages/Home.razor(2,26): error UNT001: Literal text "Company logo" must come from a resource
Pages/Home.razor(3,14): error UNT001: Literal text "Latest news" must come from a resource
The rule reports literal text with letters in:
- markup text and text content (
@("Hello"),@(ok ? "Yes" : "No"),@($"Hi {name}"),@("a" + b)); - the attributes people see or hear:
title,alt,placeholder,label,aria-label,aria-description,aria-roledescription,aria-valuetext,aria-placeholder,descriptionandtext; - the component parameters with those names, such as
Title,Description,Label,PlaceholderandText, generic components included.
It ignores text without letters (numbers, symbols, punctuation), <script> and <style> content, HTML and Razor
comments, and every other attribute (class, href, id…). Text from a resource, such as @L["Title"], passes.
The rule is an error, so it fails every build: locally, in the IDE and in CI, with no extra step.
Install
dotnet add package Blazor.Untranslated
The package is a development dependency: it adds nothing to your output and does not flow to projects that reference yours. It works with the .NET 8, 9 and 10 SDKs.
Configuration
Both settings are MSBuild properties in the project that renders the components, with items separated by commas:
<PropertyGroup>
<UntranslatedAllowedTerms>Contoso,Pro</UntranslatedAllowedTerms>
<UntranslatedTextAttributes>data-tooltip,Caption</UntranslatedTextAttributes>
</PropertyGroup>
An allowed term is removed from the text before the check, so Contoso passes and Welcome to Contoso does not.
Neither property can contain ; or #: the compiler receives them through an analyzer config file, where those
start a comment.
UNT001 is reported in .razor files, where #pragma warning disable cannot reach it. To turn it off for a
project, add <NoWarn>$(NoWarn);UNT001</NoWarn> or set dotnet_diagnostic.UNT001.severity = none in
.editorconfig.
Limits
- Text built in
@codeblocks or C# files and rendered through a variable is not detected. Keep such text in resources too, and check it in reviews. - Missing translations of existing keys are not checked: the rule only sees that a resource is used.
.cshtmlviews and Razor Pages are not checked: only.razorcomponents.
How it works
The Razor compiler has already separated markup from C# when the analyzer runs, so the rule sees exactly what
reaches the page instead of guessing through @if and @foreach blocks. For each .razor file it reads the
generated C# and inspects the RenderTreeBuilder calls: AddMarkupContent (static HTML, parsed for text nodes and
visible attributes), AddContent, AddAttribute and AddComponentParameter.
It relies on the shape of that generated code:
- the
#pragma checksumat the top of each generated file, which names the.razorsource; - literal values at the
RenderTreeBuildercall sites, wrapped at most in casts, conditionals, concatenation, interpolation andRuntimeHelpers.TypeCheck; - the
TypeInferencehelpers that render generic components, whose literals sit at the call site; - the
.razorfiles passed to the compiler as additional files, which the analyzer uses to point at the line.
A Razor compiler that changes these can silence the rule. The test suite builds fixture components on the .NET 8, 9 and 10 SDKs and compares every reported line with markers in the fixtures, so such a change fails CI here first.
Develop
dotnet build # the analyzer and the tests
dotnet test # packs the analyzer and builds the fixtures in tests/Fixtures with it
dotnet format --verify-no-changes
UNTRANSLATED_FIXTURE_SDK=8.0 dotnet test builds the fixtures with the newest installed 8.0 SDK instead of the
current one. Coding agents: read AGENTS.md.
Releases
git tag v0.1.0 && git push --tags (or Actions → Release → Run workflow with the version, which creates the tag on
main) runs release.yml: it tests, packs, pushes the package to NuGet.org through
Trusted Publishing (no stored key: a policy on
nuget.org for repository vmihalachi/blazor-untranslated and workflow release.yml, plus the NUGET_USER
repository variable holding the nuget.org username; without them it says so and attaches the package to the
release instead) and creates a GitHub release from CHANGELOG.md.
License
MIT. © 2026 Vlad Mihalachi.
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 147 | 10/9/2026 |