ResxTranslatorConsoleApp is a C# Console Application that automatically translates missing .resx
entries in your localization files using Microsoft Azure Cognitive Translator API. The app scans a directory for .resx
files, compares the default file with language-specific files, and fills in the missing translations.
This tool is ideal for automating translations in applications with multi-language support.
- 📂 Directory scanning for
.resx
files. - 🔍 Detects missing translations in language-specific
.resx
files. - 🤖 Uses Microsoft Azure Translator API for high-quality translations.
- 🔄 Overwrites existing language files with newly translated entries.
- 📝 Supports command-line arguments to customize behavior.
- 🛠️ Dry-run mode for testing without making changes.
- 📊 Logging of translated entries.
- The app scans the specified directory for
.resx
files. - It identifies the default
.resx
file (e.g.,AppResource.resx
). - It detects language-specific files (e.g.,
AppResource.fr.resx
,AppResource.es.resx
). - The app compares the default file with each language file to find missing translations.
- It uses Microsoft Azure Translator API to fill in the missing translations.
- The app saves the updated language files in the same directory.
-
Clone the repository:
git clone https://github.com/your-username/ResxTranslator.Console.git cd ResxTranslator.Console
-
Add your Microsoft Azure API key:
- Go to Azure Portal.
- Navigate to your Cognitive Services resource.
- Copy your API key and region.
Run the following command to build the project:
dotnet build
Run the app with the following command:
dotnet run --dir "/path/to/resx/files" --default AppResource --languages "languages.txt" --log
Argument | Description |
---|---|
--dir |
Required. Directory containing the .resx files. |
--default |
Required. The default .resx file name (without .resx ). |
--languages |
Optional. Path to a text file listing languages to translate. If not provided, the app will translate using the existing .resx files in the directory specified. |
--dry-run |
Optional. Show what would be translated without making changes. |
--log |
Optional. Enable logging of translated entries. |
/resx
┣ AppResource.resx
┣ AppResource.fr.resx
┣ AppResource.es.resx
┣ ProductNames.resx
┣ ProductNames.fr.resx
┣ ProductNames.es.resx
┗ languages.txt
fr
es
de
it
dotnet run --dir "/path/to/resx/files" --default AppResource --log
dotnet run --dir "/path/to/resx/files" --default ProductNames --languages "languages.txt" --dry-run
- .NET 7.0
- Microsoft Azure Cognitive Translator API
- Newtonsoft.Json
This project is licensed under the MIT License. See the LICENSE file for more details.
If you find this project helpful, consider buying me a coffee! It helps keep me motivated to create more awesome tools. 😊