Locale is a powerful multi-format localization library that supports JSON, YAML, RESX, PO/Gettext, XLIFF, SRT, VTT, CSV, i18next JSON, Fluent FTL, and VB resources. It provides services for scanning translation gaps, comparing files, validating against rules, converting between formats, and generating skeleton files for new languages.
$ dotnet add package LocaleMulti-format localization library for .NET
Locale is a powerful .NET library for working with localization files. It supports 11 formats and provides services for scanning, diffing, validating, converting, generating, and auto-translating translation files.
dotnet add package Locale
using Locale.Services;
using Locale.Models;
// Scan for translation gaps
var scanService = new ScanService();
var report = scanService.Scan("./locales", new ScanOptions
{
BaseCulture = "en",
TargetCultures = ["tr", "de", "fr"]
});
Console.WriteLine($"Missing: {report.MissingKeys.Count}, Orphan: {report.OrphanKeys.Count}");
// Compare two files
var diffService = new DiffService();
var diff = diffService.Diff("en.json", "tr.json");
// Validate files
var checkService = new CheckService();
var check = checkService.Check("./locales", new CheckOptions
{
Rules = ["no-empty-values", "consistent-placeholders"]
});
// Convert formats
var convertService = new ConvertService();
convertService.Convert("en.json", "en.yaml", new ConvertOptions { ToFormat = "yaml" });
// Generate skeleton files
var generateService = new GenerateService();
generateService.Generate("./locales", "./locales", new GenerateOptions
{
BaseCulture = "en",
TargetCulture = "tr"
});
| Format | Extensions | Description |
|---|---|---|
| JSON | .json | Flat and nested JSON |
| YAML | .yaml, .yml | Flat and nested YAML |
| RESX | .resx | .NET XML resources |
| PO | .po | GNU Gettext |
| XLIFF | .xlf, .xliff | XLIFF 1.2 & 2.0 |
| SRT | .srt | SubRip subtitles |
| VTT | .vtt | WebVTT subtitles |
| CSV | .csv | Comma-separated values |
| i18next | .i18n.json | i18next nested JSON |
| Fluent | .ftl | Mozilla Fluent FTL |
| VB | .vb | VB resources (read-only) |
| Provider | API Key | Default Model |
|---|---|---|
| ❌ | - | |
| DeepL | ✅ | - |
| Bing | ✅ | - |
| Yandex | ✅ | - |
| LibreTranslate | ⚪ | - |
| OpenAI | ✅ | gpt-4o-mini |
| Claude | ✅ | claude-3-5-sonnet-latest |
| Gemini | ✅ | gemini-2.0-flash |
| Azure OpenAI | ✅ | - |
| Ollama | ❌ | llama3.2 |
For full documentation, visit the GitHub repository.
MIT License - see LICENSE for details.