Skip to content

Commit

Permalink
feat: Added Italian language support for the LessMSI GUI app (#205)
Browse files Browse the repository at this point in the history
closes #203

* added English strings for the main form

* added Italian texts to the main page

* added Italian texts to the tabs section in main page

* Added Italian text for error messages

* Added Italian text for preferences form

* Added Italian texts for the about window

* Added final Italian texts for preferences form

* Added final Italian texts for about form

* Stopped tracking aboutbox.rtf file

* added final Italian texts to GUI app

* Deleted aboutbox.rtf file

* Changed AboutBoxFilePath member to be a local variable

* Amended locale strings values according to Scott’s comments

* Deleted the Strings.it.Designer.cs file

* Added GUI tests that check GUI strings in different locale settings

* Unified locale tests into one to avoid issues while changing locale settings

* Changing CurrentCulture variable as part of the locale change

* Deleted unnecessary using statement

* Reverted AboutBox logic to original implementation

* added Copyright text

* fix: build culture resources in gui project in msbuild

* fix: build the gui resources for it lang in msbuild

* fix: adds resources to the zip file in the culture-specific subdir in msbuild

---------

Co-authored-by: Scott Willeke <[email protected]>
  • Loading branch information
mega5800 and activescott authored Oct 5, 2024
1 parent 82d6669 commit 18356d0
Show file tree
Hide file tree
Showing 15 changed files with 1,443 additions and 191 deletions.
36 changes: 35 additions & 1 deletion src/.build/lessmsi.msbuild
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,24 @@
<TheProjects Include="$(RootDir)\LessMsi.Tests\LessMsi.Tests.csproj"></TheProjects>
</ItemGroup>

<ItemDefinitionGroup>
<DeployFiles>
<!-- This adds a deafult empty TheCulture item metadata to the DeployFiles itemgroup -->
<TheCulture></TheCulture>
</DeployFiles>
</ItemDefinitionGroup>

<ItemGroup>
<DeployFiles Include="$(RootDir)\ExplorerShortcutHelper\bin\Release\AddWindowsExplorerShortcut.exe"></DeployFiles>
<DeployFiles Include="$(RootDir)\LessMsi.Core\bin\Release\lessmsi.core.dll"></DeployFiles>
<DeployFiles Include="$(RootDir)\LessMsi.Cli\bin\Release\lessmsi.exe"></DeployFiles>
<DeployFiles Include="$(RootDir)\LessMsi.Cli\bin\Release\lessmsi.exe.config"></DeployFiles>
<DeployFiles Include="$(RootDir)\LessMsi.Gui\bin\Release\lessmsi-gui.exe"></DeployFiles>
<DeployFiles Include="$(RootDir)\LessMsi.Gui\bin\Release\lessmsi-gui.exe.config"></DeployFiles>
<DeployFiles Include="$(RootDir)\LessMsi.Gui\bin\Release\it\lessmsi-gui.resources.dll">
<!-- TheCulture is MSBuild's so-called "Item Metadata". See https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-items?view=vs-2022&source=recommendations#item-metadata -->
<TheCulture>it</TheCulture>
</DeployFiles>
<DeployFiles Include="$(RootDir)\packages\libmspack4n.0.9.10\lib\net40\libmspackn.dll"></DeployFiles>
<DeployFiles Include="$(RootDir)\packages\libmspack4n.0.9.10\build\x86\mspack.dll"></DeployFiles>
<DeployFiles Include="$(RootDir)\packages\LessIO.1.0.34\lib\net40\LessIO.dll"></DeployFiles>
Expand Down Expand Up @@ -124,10 +135,23 @@
<Target Name="Deploy" DependsOnTargets="Build;Clean">
<MakeDir Directories="$(TheDeployDir)" />

<!-- The condition of empty TheCulture means it is not a culture-specific resource and does not need put in a subdirectory-->
<Copy
Condition=" '%(TheCulture)' == '' "
SourceFiles="%(DeployFiles.FullPath)"
DestinationFolder="$(TheDeployDir)\%(RecursiveDir)"
/>

<!--
GUI Resources
Here we add TheCulture item metadata to the deployfiles that require it so we can put them in the correct location in deploy zip.
-->
<Copy
Condition=" '%(TheCulture)' != '' "
SourceFiles="%(DeployFiles.FullPath)"
DestinationFolder="$(TheDeployDir)"
DestinationFolder="$(TheDeployDir)\%(TheCulture)"
/>

</Target>

<Target Name="BeforeTest" DependsOnTargets="Init;Clean">
Expand Down Expand Up @@ -157,10 +181,20 @@

<!-- the deploy dir has test files in it too, so we move deploy files to a staging directory -->
<MakeDir Directories="$(TheTempDir)\zipstaging" />
<!-- The condition of empty TheCulture means it is not a culture-specific resource and does not need put in a subdirectory-->
<Copy
Condition=" '%(TheCulture)' == '' "
SourceFiles="%(DeployFiles.FullPath)"
DestinationFolder="$(TheTempDir)\zipstaging"
/>
<!-- Copy GUI resources into zip staging
Here we add TheCulture item metadata to the deployfiles that require it so we can put them in the correct location in deploy zip.
-->
<Copy
Condition=" '%(TheCulture)' != '' "
SourceFiles="%(DeployFiles.FullPath)"
DestinationFolder="$(TheTempDir)\zipstaging\%(TheCulture)"
/>
<ZipDirectory
SourceDirectory="$(TheTempDir)\zipstaging"
DestinationFile="$(TheTempDir)\$(TheZipFileName)"
Expand Down
229 changes: 114 additions & 115 deletions src/LessMsi.Gui/AboutBox.cs
Original file line number Diff line number Diff line change
@@ -1,121 +1,120 @@
using LessMsi.Gui.Properties;
using System;
using System;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;

namespace LessMsi.Gui
{
partial class AboutBox : Form
{
public AboutBox()
{
InitializeComponent();
this.Text = String.Format("About {0}", AssemblyTitle);
this.labelProductName.Text = AssemblyProduct;
this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
this.labelCopyright.Text = AssemblyCopyright;

Icon = Resources.LessmsiIcon;
}

#region Assembly Attribute Accessors

public string AssemblyTitle
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
if (attributes.Length > 0)
{
AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
if (titleAttribute.Title != "")
{
return titleAttribute.Title;
}
}
return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
}
}

public string AssemblyVersion
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}

public string AssemblyDescription
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyDescriptionAttribute)attributes[0]).Description;
}
}

public string AssemblyProduct
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyProductAttribute)attributes[0]).Product;
}
}

public string AssemblyCopyright
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}

public string AssemblyCompany
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyCompanyAttribute)attributes[0]).Company;
}
}
#endregion

private void AboutBox_Load(object sender, EventArgs e)
{
var aboutRtf = GetType().Assembly.GetManifestResourceStream(GetType(), "aboutbox.rtf");
Debug.Assert(aboutRtf != null, "Failed to load aboutbox.rtf");
this.richTextBox.LoadFile(aboutRtf, RichTextBoxStreamType.RichText);
}

private void richTextBox_LinkClicked(object sender, LinkClickedEventArgs e)
{
Process.Start(e.LinkText);
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
namespace LessMsi.Gui
{
partial class AboutBox : Form
{
public AboutBox()
{
InitializeComponent();
this.Text = String.Format("About {0}", AssemblyTitle);
this.labelProductName.Text = AssemblyProduct;
this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
this.labelCopyright.Text = $"Copyright Scott Willeke © 2004-{DateTime.Now.Year}";

Icon = Properties.Resources.LessmsiIcon;
}

#region Assembly Attribute Accessors

public string AssemblyTitle
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
if (attributes.Length > 0)
{
AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
if (titleAttribute.Title != "")
{
return titleAttribute.Title;
}
}
return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
}
}

public string AssemblyVersion
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}

public string AssemblyDescription
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyDescriptionAttribute)attributes[0]).Description;
}
}

public string AssemblyProduct
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyProductAttribute)attributes[0]).Product;
}
}

public string AssemblyCopyright
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}

public string AssemblyCompany
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyCompanyAttribute)attributes[0]).Company;
}
}
#endregion

private void AboutBox_Load(object sender, EventArgs e)
{
var aboutRtf = GetType().Assembly.GetManifestResourceStream(GetType(), "aboutbox.rtf");
Debug.Assert(aboutRtf != null, "Failed to load aboutbox.rtf");
this.richTextBox.LoadFile(aboutRtf, RichTextBoxStreamType.RichText);
}

private void richTextBox_LinkClicked(object sender, LinkClickedEventArgs e)
{
Process.Start(e.LinkText);
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
var text = ((LinkLabel) sender).Text;
var link = text.Substring(e.Link.Start, e.Link.Length);
Process.Start(link);
}
}
var link = text.Substring(e.Link.Start, e.Link.Length);
Process.Start(link);
}
}
}
6 changes: 3 additions & 3 deletions src/LessMsi.Gui/AboutBox.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="logoPictureBox.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAHgAAAEGCAIAAAAhWcaAAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
Expand Down
18 changes: 17 additions & 1 deletion src/LessMsi.Gui/LessMsi.Gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Extensions\DataGridViewExtensions.cs" />
<Compile Include="Resources\Languages\Strings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
<Compile Include="Windows.Forms\DisposableCursor.cs" />
<Compile Include="Windows.Forms\ElevationButton.cs">
<SubType>Component</SubType>
Expand All @@ -127,7 +132,6 @@
</Compile>
<Compile Include="Windows.Forms\SortableBindingList.cs" />
<Compile Include="Windows.Forms\WinFormsHelper.cs" />
<EmbeddedResource Include="aboutbox.rtf" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
<SubType>Designer</SubType>
Expand All @@ -139,12 +143,23 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Languages\Strings.it.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.it.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Languages\Strings.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Windows.Forms\ErrorDialog.resx">
<DependentUpon>ErrorDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Windows.Forms\SearchPanel.resx">
<DependentUpon>SearchPanel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="aboutbox.rtf" />
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
Expand All @@ -155,6 +170,7 @@
<ItemGroup>
<EmbeddedResource Include="AboutBox.resx">
<DependentUpon>AboutBox.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
Expand Down
Loading

0 comments on commit 18356d0

Please sign in to comment.