Error on empty translations and simplify command line

This commit is contained in:
Duncan Ogilvie 2024-05-17 09:59:49 +02:00
parent 7ebd882673
commit dc7a76d888
4 changed files with 23 additions and 10 deletions

Binary file not shown.

View File

@ -186,7 +186,15 @@ namespace TranslationChecker
void ReportError(Message message, string translation) void ReportError(Message message, string translation)
{ {
var location = message.Locations.First(); var location = message.Locations.First();
if (string.IsNullOrEmpty(translation))
{
Console.WriteLine($" Empty translation ({location.Filename}:{location.Line})\n Source:\n '{message.Source}'");
}
else
{
Console.WriteLine($" Format string error ({location.Filename}:{location.Line})\n Source:\n '{message.Source}'\n Translation:\n '{translation}'"); Console.WriteLine($" Format string error ({location.Filename}:{location.Line})\n Source:\n '{message.Source}'\n Translation:\n '{translation}'");
}
success = false; success = false;
ErrorCount++; ErrorCount++;
} }
@ -224,7 +232,13 @@ namespace TranslationChecker
else else
{ {
var translation = message.Translation.Text; var translation = message.Translation.Text;
if (!CheckTranslation(original, translation)) if (string.IsNullOrEmpty(translation))
{
ReportError(message, translation);
if (fix)
message.Translation.Text = original;
}
else if (!CheckTranslation(original, translation))
{ {
ReportError(message, translation); ReportError(message, translation);
if (fix) if (fix)
@ -266,19 +280,17 @@ namespace TranslationChecker
} }
var fix = false; var fix = false;
var folder = false;
for (var i = 1; i < args.Length; i++) for (var i = 1; i < args.Length; i++)
{ {
if (args[i] == "--fix") if (args[i] == "--fix")
fix = true; fix = true;
else if (args[i] == "--folder")
folder = true;
} }
var success = true; var success = true;
if (folder) var path = args[0];
if (File.GetAttributes(path).HasFlag(FileAttributes.Directory))
{ {
foreach (var tsFile in Directory.EnumerateFiles(args[0], "*.ts", SearchOption.AllDirectories)) foreach (var tsFile in Directory.EnumerateFiles(path, "*.ts", SearchOption.AllDirectories))
{ {
if (!CheckFile(tsFile, fix)) if (!CheckFile(tsFile, fix))
success = false; success = false;
@ -286,7 +298,7 @@ namespace TranslationChecker
} }
else else
{ {
success = CheckFile(args[0], fix); success = CheckFile(path, fix);
} }
Console.WriteLine($"\nTotal errors: {ErrorCount}"); Console.WriteLine($"\nTotal errors: {ErrorCount}");

View File

@ -25,12 +25,13 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>full</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />

View File

@ -10,7 +10,7 @@ java -jar crowdin-cli.jar download
if not %ERRORLEVEL%==0 exit /b if not %ERRORLEVEL%==0 exit /b
echo Checking translations... echo Checking translations...
TranslationChecker.exe translations --folder --fix TranslationChecker.exe translations --fix
set CHECKER_ERRORLEVEL=%ERRORLEVEL% set CHECKER_ERRORLEVEL=%ERRORLEVEL%
echo Generating Qt translations... echo Generating Qt translations...