Automated .resx file generator for .NET applications with translation capabilities
- π― MVC-Optimized
Built for ASP.NET MVC projects with:Controllers/ Views/ Models/ ββ *.cs ββ *.cshtml ββ DataAnnotations - π Automatic Detection
Scans controllers, views and model validations Scans.csand.cshtmlfiles for localization patterns - π Multi-language Support
Generates resource files for en, tr, and custom languages - π Structured Output and Preservation
Mirrors your MVC folder hierarchy in Resources/
Creates
Resourcesfolders mirroring project structure - π Translation API Integration
Uses MyMemory Translation service for automatic translations β οΈ Duplicate Prevention
Ensures unique keys in resource files
- .NET 6.0 SDK or later
- Internet connection (for translation API)
- Valid project directory structure
-
Clone the repository:
git clone https://github.com/yourusername/localization-generator.git
-
Navigate to project directory:
cd localization-generator -
Build the solution:
dotnet build
Original:
/Controllers/HomeController.cs
/Views/Home/Index.cshtml
Generated:
/Resources/Controllers/HomeController.en.resx
/Resources/Views/Home/Index.tr.resx
-
Run the generator:
dotnet run --project LocalizationFileGenerator.csproj
-
Provide paths when prompted:
Enter the project path: D:\Projects\YourSolution Enter the output path for .resx files: D:\Projects\YourSolution -
Generated files will appear in:
YourSolution/ βββ Resources/ βββ [Mirrored project structure]/ βββ FileName.en.resx βββ FileName.tr.resx βββ FileName.resx
Modify the languages array in code:
string[] languages = {
"", // Neutral culture
"en", // English
"tr", // Turkish
"de" // Add new languages
};Format validation attributes:
[Required(ErrorMessageResourceType = typeof(Resources.User),
ErrorMessageResourceName = "NameRequired")]
public string Name { get; set; }Translation requests use:
string url = $"{baseUrl}get?q={text}&langpair=en|{targetLang}";if (translationResult?.responseStatus == 200)
{
return translationResult.TranslatedText;
}
else
{
return text; // Fallback to original
}- β³ Translation API rate limits (1000/day free tier)
- π Requires consistent project structure
- π First-letter capitalization not preserved
- Fork the repository
- Create a feature branch
- Submit a PR with:
- Description of changes
- Related issue reference
- Test results
MIT License - See LICENSE for full text
Note: Always test with a sample project before running on production code!