Skip to content

Commit

Permalink
Merge pull request #180 from emoacht/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
emoacht authored May 23, 2021
2 parents 207b2ce + 835c2ca commit 841575c
Show file tree
Hide file tree
Showing 12 changed files with 444 additions and 75 deletions.
19 changes: 13 additions & 6 deletions Source/Installer/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Monitorian" Manufacturer="emoacht" Version="2.17.0"
<Product Id="*" Name="Monitorian" Manufacturer="emoacht" Version="2.18.0"
Language="1033" Codepage="1252" UpgradeCode="{81A4D148-75D3-462E-938D-8C208FB48E3C}">
<Package Id="*" InstallerVersion="500" Compressed="yes"
InstallScope="perMachine" InstallPrivileges="elevated"
Expand Down Expand Up @@ -82,10 +82,16 @@
</Component>

<!-- Language resources -->
<Directory Id="ResourcesFolder_frFR" Name="fr-FR"
FileSource="$(var.Monitorian.TargetDir)fr-FR">
<Component Id="CoreResourcesLibrary_frFR" Guid="{B7502D66-6FE8-4E0F-A8D0-42AFFBE82895}">
<File Id="CoreResourcesLibrary_frFR" Name="$(var.Monitorian.TargetName).Core.resources.dll" KeyPath="yes"/>
<Directory Id="ResourcesFolder_de" Name="de"
FileSource="$(var.Monitorian.TargetDir)de">
<Component Id="CoreResourcesLibrary_de" Guid="{4BE0F7FF-08C3-461E-9FED-4037D40BEB45}">
<File Id="CoreResourcesLibrary_de" Name="$(var.Monitorian.TargetName).Core.resources.dll" KeyPath="yes"/>
</Component>
</Directory>
<Directory Id="ResourcesFolder_fr" Name="fr"
FileSource="$(var.Monitorian.TargetDir)fr">
<Component Id="CoreResourcesLibrary_fr" Guid="{B7502D66-6FE8-4E0F-A8D0-42AFFBE82895}">
<File Id="CoreResourcesLibrary_fr" Name="$(var.Monitorian.TargetName).Core.resources.dll" KeyPath="yes"/>
</Component>
</Directory>
<Directory Id="ResourcesFolder_jaJP" Name="ja-JP"
Expand Down Expand Up @@ -156,7 +162,8 @@
<ComponentRef Id="AgencyLibrary"/>
<ComponentRef Id="BridgeLibrary"/>
<ComponentRef Id="VisualManifest"/>
<ComponentRef Id="CoreResourcesLibrary_frFR"/>
<ComponentRef Id="CoreResourcesLibrary_de"/>
<ComponentRef Id="CoreResourcesLibrary_fr"/>
<ComponentRef Id="CoreResourcesLibrary_jaJP"/>
<ComponentRef Id="CoreResourcesLibrary_koKR"/>
<ComponentRef Id="CoreResourcesLibrary_plPL"/>
Expand Down
38 changes: 18 additions & 20 deletions Source/Monitorian.Core/Models/LanguageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,28 @@ namespace Monitorian.Core.Models
{
public class LanguageService
{
private static IReadOnlyDictionary<string, string> PreparedCulturePairs => new Dictionary<string, string>
{
{ "/en", "en-US" },
{ "/fr" ,"fr-FR" },
{ "/ja", "ja-JP" },
{ "/ko", "ko-KR" },
{ "/pl", "pl-PL" },
{ "/ru", "ru-RU" },
{ "/zh", "zh-Hans" },
};

public static IReadOnlyCollection<string> Options => PreparedCulturePairs.Keys.ToArray();
public static IReadOnlyCollection<string> Options => new[] { Option };
private const string Option = "/lang";

private static readonly Lazy<CultureInfo> _culture = new Lazy<CultureInfo>(() =>
private static readonly Lazy<CultureInfo> _culture = new(() =>
{
var preparedCulturePairs = PreparedCulturePairs;
var supportedCultureNames = new HashSet<string>(CultureInfo.GetCultures(CultureTypes.AllCultures).Select(x => x.Name));
var arguments = AppKeeper.DefinedArguments;
int i = 0;
while (i < arguments.Count - 1)
{
if (string.Equals(arguments[i], Option, StringComparison.OrdinalIgnoreCase))
{
var cultureName = supportedCultureNames.FirstOrDefault(x => string.Equals(x, arguments[i + 1], StringComparison.OrdinalIgnoreCase));
if (cultureName is not null)
return new CultureInfo(cultureName);
return AppKeeper.DefinedArguments
.Where(x => !string.IsNullOrWhiteSpace(x))
.Select(x => (Success: preparedCulturePairs.TryGetValue(x.ToLower(), out string value) && supportedCultureNames.Contains(value), CultureName: value))
.Where(x => x.Success)
.Select(x => new CultureInfo(x.CultureName))
.FirstOrDefault();
break;
}
i++;
}
return null;
});

/// <summary>
Expand Down
25 changes: 19 additions & 6 deletions Source/Monitorian.Core/Monitorian.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
<Compile Include="Models\ProductInfo.cs" />
<Compile Include="Models\SettingsCore.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Invariant.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Invariant.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand Down Expand Up @@ -150,7 +155,20 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.fr-FR.resx">
<EmbeddedResource Include="Properties\Invariant.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Invariant.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.de.resx">
<DependentUpon>Resources.resx</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.fr.resx">
<DependentUpon>Resources.resx</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
Expand All @@ -166,11 +184,6 @@
<DependentUpon>Resources.resx</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.ru-RU.resx">
<DependentUpon>Resources.resx</DependentUpon>
<SubType>Designer</SubType>
Expand Down
4 changes: 2 additions & 2 deletions Source/Monitorian.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.17.0.0")]
[assembly: AssemblyFileVersion("2.17.0.0")]
[assembly: AssemblyVersion("2.18.0.0")]
[assembly: AssemblyFileVersion("2.18.0.0")]
[assembly: NeutralResourcesLanguage("en-US")]

// For unit test
Expand Down
90 changes: 90 additions & 0 deletions Source/Monitorian.Core/Properties/Invariant.Designer.cs

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

129 changes: 129 additions & 0 deletions Source/Monitorian.Core/Properties/Invariant.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?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="License" xml:space="preserve">
<value>License</value>
</data>
<data name="Site" xml:space="preserve">
<value>Site</value>
</data>
<data name="SiteUrl" xml:space="preserve">
<value>https://github.com/emoacht/Monitorian</value>
</data>
</root>
Loading

0 comments on commit 841575c

Please sign in to comment.