Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internationalize Core, CmdLine, ConsoleUI, and AutoUpdater #3482

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release_data.outputs.upload_url }}
asset_path: _build/out/AutoUpdater/Release/bin/AutoUpdater.exe
asset_path: _build/repack/Release/AutoUpdater.exe
asset_name: AutoUpdater.exe
asset_content_type: application/vnd.microsoft.portable-executable

Expand Down
63 changes: 35 additions & 28 deletions AutoUpdate/CKAN-autoupdate.csproj
Original file line number Diff line number Diff line change
@@ -1,61 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project>
<PropertyGroup>
<AssemblyName>AutoUpdater</AssemblyName>
<AssemblyName>CKAN-AutoUpdateHelper</AssemblyName>
<OutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<BaseIntermediateOutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E5B1C768-349E-4DAF-A134-56E4ECF1EEEF}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>AutoUpdater</RootNamespace>
<RootNamespace>CKAN.AutoUpdateHelper</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<Configurations>Debug;Release</Configurations>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>7</LangVersion>
<ApplicationIcon>..\assets\ckan.ico</ApplicationIcon>
<TargetFramework>net45</TargetFramework>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>7</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ILRepack" Version="2.0.18" />
<PackageReference Include="ILRepack.MSBuild.Task" Version="2.0.13" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\_build\meta\GlobalAssemblyVersionInfo.cs">
<Link>Properties\GlobalAssemblyVersionInfo.cs</Link>
</Compile>
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<Target Name="BeforeBuild">
<Exec Command="powershell ../build.ps1 Generate-GlobalAssemblyVersionInfo" Condition="!Exists('../_build/meta/GlobalAssemblyVersionInfo.cs') And '$(OS)' == 'Windows_NT'" />
<Exec Command="sh ../build Generate-GlobalAssemblyVersionInfo" Condition="!Exists('../_build/meta/GlobalAssemblyVersionInfo.cs') And '$(OS)' == 'Unix'" />
</Target>
</Project>
<Target Name="ILRepack" AfterTargets="Build">
<ItemGroup>
<InputAssemblies Include="fr-FR\$(AssemblyName).resources.dll" />
<InputAssemblies Include="ru-RU\$(AssemblyName).resources.dll" />
</ItemGroup>
<ILRepack OutputAssembly="AutoUpdater.exe"
MainAssembly="$(AssemblyName).exe"
InputAssemblies="@(InputAssemblies)"
OutputType="$(OutputType)"
WorkingDirectory="$(OutputPath)"
Internalize="true"
Parallel="true" />
<ItemGroup>
<Repacked Include="$(OutputPath)AutoUpdater.*" />
</ItemGroup>
<Copy SourceFiles="@(Repacked)"
DestinationFolder="..\_build\repack\$(Configuration)" />
</Target>
</Project>
17 changes: 9 additions & 8 deletions AutoUpdate/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* AutoUpdate.exe <running CKAN PID> <running CKAN path> <updated CKAN path> <launch>
*/

namespace AutoUpdater
namespace CKAN.AutoUpdateHelper
{
public class Program
{
Expand All @@ -26,7 +26,7 @@ public static int Main(string[] args)

if (args.Length != 4)
{
ReportError("Usage: AutoUpdater.exe pid oldPath newPath [no]launch");
ReportError("{0}: AutoUpdater.exe pid oldPath newPath [no]launch", Properties.Resources.Usage);
return ExitBADOPT;
}

Expand All @@ -39,7 +39,7 @@ public static int Main(string[] args)

if (!File.Exists(updated_path))
{
ReportError($"Downloaded ckan.exe not found at: {updated_path}");
ReportError(Properties.Resources.DownloadNotFound, updated_path);
return ExitBADOPT;
}

Expand Down Expand Up @@ -71,7 +71,7 @@ public static int Main(string[] args)
}
catch (Exception exc)
{
ReportError($"Failed to wait for CKAN to close: {exc.Message}");
ReportError(Properties.Resources.FailedToWait, exc.Message);
return ExitERROR;
}

Expand All @@ -86,7 +86,7 @@ public static int Main(string[] args)
{
if (retry == maxRetries - 1)
{
ReportError($"Failed to delete {local_path}: {exc.Message}");
ReportError(Properties.Resources.FailedToDelete, local_path, exc.Message);
if (fromGui)
{
// Launch the old EXE that we can't delete
Expand Down Expand Up @@ -172,20 +172,21 @@ private static bool IsOnWindows()
/// <param name="e">Info about the exception</param>
private static void UnhandledExceptionEventHandler(Object sender, UnhandledExceptionEventArgs e)
{
ReportError($"Unhandled exception:\r\n{e.ExceptionObject}");
ReportError(Properties.Resources.UnhandledException, e.ExceptionObject);
}

/// <summary>
/// It's nice to tell the user when something goes wrong!
/// </summary>
/// <param name="err">Description of the problem that happened</param>
private static void ReportError(string err)
private static void ReportError(string message, params object[] args)
{
string err = string.Format(message, args);
Console.Error.WriteLine(err);
if (fromGui)
{
// Show a popup in case the console isn't open
MessageBox.Show(err, "Fatal AutoUpdater Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(err, Properties.Resources.FatalErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

Expand Down
10 changes: 8 additions & 2 deletions AutoUpdate/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
using System.Reflection;
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: AssemblyTitle("AutoUpdater")]
[assembly: AssemblyTitle("CKAN-AutoUpdater")]
[assembly: AssemblyDescription("CKAN Auto-update Executable")]
[assembly: NeutralResourcesLanguage("en-GB")]

[assembly: InternalsVisibleTo("Tests")]
[assembly: InternalsVisibleTo("CKAN.Tests")]
82 changes: 82 additions & 0 deletions AutoUpdate/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading