super janky localization implementation

This commit is contained in:
Royce551 2021-06-10 15:57:06 -05:00
parent 2e7d390681
commit 0a91adcdf7
6 changed files with 391 additions and 19 deletions

View file

@ -32,6 +32,19 @@
<PackageReference Include="Tmds.DBus" Version="0.9.1" />
<PackageReference Include="z440.atl.core" Version="3.19.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="Backends\bass.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

View file

@ -2,20 +2,27 @@ using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.ReactiveUI;
using FRESHMusicPlayer;
using FRESHMusicPlayer.Handlers.Configuration;
using FRESHMusicPlayer.Utilities;
using FRESHMusicPlayer.ViewModels;
using System;
using System.IO;
using System.Threading.Tasks;
namespace FRESHMusicPlayer_Avalonia
namespace FRESHMusicPlayer
{
class Program
public class Program
{
public static ConfigurationFile Config;
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
public static void Main(string[] args)
public static async Task Main(string[] args)
{
Config = await ConfigurationHandler.Read();
if (Config.Language != "automatic") System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Config.Language);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);

View file

@ -0,0 +1,189 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FRESHMusicPlayer.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FRESHMusicPlayer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Import Folders.
/// </summary>
public static string ImportFolders {
get {
return ResourceManager.GetString("ImportFolders", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Import Playlist Files.
/// </summary>
public static string ImportPlaylistFiles {
get {
return ResourceManager.GetString("ImportPlaylistFiles", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Import Tracks.
/// </summary>
public static string ImportTracks {
get {
return ResourceManager.GetString("ImportTracks", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About.
/// </summary>
public static string Menu_About {
get {
return ResourceManager.GetString("Menu_About", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About FRESHMusicPlayer.
/// </summary>
public static string Menu_About_AboutFMP {
get {
return ResourceManager.GetString("Menu_About_AboutFMP", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to File.
/// </summary>
public static string Menu_File {
get {
return ResourceManager.GetString("Menu_File", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Playback.
/// </summary>
public static string Menu_Playback {
get {
return ResourceManager.GetString("Menu_Playback", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Next.
/// </summary>
public static string Menu_Playback_Next {
get {
return ResourceManager.GetString("Menu_Playback_Next", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Pause after current track.
/// </summary>
public static string Menu_Playback_PauseAfterCurrentTrack {
get {
return ResourceManager.GetString("Menu_Playback_PauseAfterCurrentTrack", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Play/Pause.
/// </summary>
public static string Menu_Playback_PlayPause {
get {
return ResourceManager.GetString("Menu_Playback_PlayPause", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Previous.
/// </summary>
public static string Menu_Playback_Previous {
get {
return ResourceManager.GetString("Menu_Playback_Previous", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Repeat.
/// </summary>
public static string Menu_Playback_Repeat {
get {
return ResourceManager.GetString("Menu_Playback_Repeat", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Shuffle.
/// </summary>
public static string Menu_Playback_Shuffle {
get {
return ResourceManager.GetString("Menu_Playback_Shuffle", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Open....
/// </summary>
public static string OpenDialog {
get {
return ResourceManager.GetString("OpenDialog", resourceCulture);
}
}
}
}

View file

@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ImportFolders" xml:space="preserve">
<value>Import Folders</value>
</data>
<data name="ImportPlaylistFiles" xml:space="preserve">
<value>Import Playlist Files</value>
</data>
<data name="ImportTracks" xml:space="preserve">
<value>Import Tracks</value>
</data>
<data name="Menu_About" xml:space="preserve">
<value>About</value>
</data>
<data name="Menu_About_AboutFMP" xml:space="preserve">
<value>About FRESHMusicPlayer</value>
</data>
<data name="Menu_File" xml:space="preserve">
<value>File</value>
</data>
<data name="Menu_Playback" xml:space="preserve">
<value>Playback</value>
</data>
<data name="Menu_Playback_Next" xml:space="preserve">
<value>Next</value>
</data>
<data name="Menu_Playback_PauseAfterCurrentTrack" xml:space="preserve">
<value>Pause after current track</value>
</data>
<data name="Menu_Playback_PlayPause" xml:space="preserve">
<value>Play/Pause</value>
</data>
<data name="Menu_Playback_Previous" xml:space="preserve">
<value>Previous</value>
</data>
<data name="Menu_Playback_Repeat" xml:space="preserve">
<value>Repeat</value>
</data>
<data name="Menu_Playback_Shuffle" xml:space="preserve">
<value>Shuffle</value>
</data>
<data name="OpenDialog" xml:space="preserve">
<value>Open...</value>
</data>
</root>

View file

@ -337,7 +337,7 @@ namespace FRESHMusicPlayer.ViewModels
Player.SongException += Player_SongException;
ProgressTimer.Elapsed += ProgressTimer_Elapsed; // TODO: put this in a more logical place
LoggingHandler.Log("Handling config...");
Config = await ConfigurationHandler.Read();
Config = Program.Config; // HACK: this is a hack
Volume = Config?.Volume ?? 1f;
LoggingHandler.Log("Handling command line args...");

View file

@ -3,6 +3,7 @@
xmlns:vm="using:FRESHMusicPlayer.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:resx ="clr-namespace:FRESHMusicPlayer.Properties"
xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
Width="800" Height="540"
@ -53,29 +54,29 @@
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="File">
<NativeMenuItem Header="{x:Static resx:Resources.Menu_File}">
<NativeMenu>
<NativeMenuItem Header="Open..." Command="{Binding OpenTrackCommand}"/>
<NativeMenuItem Header="{x:Static resx:Resources.OpenDialog}" Command="{Binding OpenTrackCommand}"/>
<NativeMenuItemSeperator/>
<NativeMenuItem Header="Import Tracks" Command="{Binding BrowseTracksCommand}"/>
<NativeMenuItem Header="Import Folders" Command="{Binding BrowseFoldersCommand}"/>
<NativeMenuItem Header="Import Playlist Files" Command="{Binding BrowsePlaylistFilesCommand}"/>
<NativeMenuItem Header="{x:Static resx:Resources.ImportTracks}" Command="{Binding BrowseTracksCommand}"/>
<NativeMenuItem Header="{x:Static resx:Resources.ImportFolders}" Command="{Binding BrowseFoldersCommand}"/>
<NativeMenuItem Header="{x:Static resx:Resources.ImportPlaylistFiles}" Command="{Binding BrowsePlaylistFilesCommand}"/>
</NativeMenu>
</NativeMenuItem>
<NativeMenuItem Header="Playback">
<NativeMenuItem Header="{x:Static resx:Resources.Menu_Playback}">
<NativeMenu>
<NativeMenuItem Header="Play/Pause" Command="{Binding PlayPauseCommand}"/>
<NativeMenuItem Header="Previous" Command="{Binding SkipPreviousCommand}"/>
<NativeMenuItem Header="Next" Command="{Binding SkipNextCommand}"/>
<NativeMenuItem Header="{x:Static resx:Resources.Menu_Playback_PlayPause}" Command="{Binding PlayPauseCommand}"/>
<NativeMenuItem Header="{x:Static resx:Resources.Menu_Playback_Previous}" Command="{Binding SkipPreviousCommand}"/>
<NativeMenuItem Header="{x:Static resx:Resources.Menu_Playback_Next}" Command="{Binding SkipNextCommand}"/>
<NativeMenuItemSeperator/>
<NativeMenuItem Header="Toggle Repeat" Command="{Binding RepeatCommand}"/>
<NativeMenuItem Header="Shuffle" Command="{Binding ShuffleCommand}" IsChecked="{Binding Shuffle}"/>
<NativeMenuItem Header="Pause after current track" Command="{Binding PauseAfterCurrentTrackCommand}"/>
<NativeMenuItem Header="{x:Static resx:Resources.Menu_Playback_Shuffle}" Command="{Binding ShuffleCommand}" IsChecked="{Binding Shuffle}"/>
<NativeMenuItem Header="{x:Static resx:Resources.Menu_Playback_PauseAfterCurrentTrack}" Command="{Binding PauseAfterCurrentTrackCommand}"/>
</NativeMenu>
</NativeMenuItem>
<NativeMenuItem Header="About">
<NativeMenuItem Header="{x:Static resx:Resources.Menu_About}">
<NativeMenu>
<NativeMenuItem Header="About FRESHMusicPlayer" Command="{Binding AboutFMPCommand}"/>
<NativeMenuItem Header="{x:Static resx:Resources.Menu_About_AboutFMP}" Command="{Binding AboutFMPCommand}"/>
</NativeMenu>
</NativeMenuItem>
</NativeMenu>
@ -363,9 +364,9 @@
<TextBlock Text="You can also drag and drop to this page."/>
</StackPanel>
</TabItem>
<!--<TabItem Header="Native Menubar Debug">
<TabItem Header="Native Menubar Debug">
<NativeMenuBar/>
</TabItem>-->
</TabItem>
</TabControl>
</DockPanel>