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

[release/8.0] Add missing translations #4004

Merged
merged 6 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
12 changes: 12 additions & 0 deletions src/Aspire.Dashboard/Aspire.Dashboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>Routes.resx</DependentUpon>
</Compile>
<Compile Update="Resources\Logs.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Logs.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -182,6 +187,13 @@
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Routes.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Resources\Logs.resx">
<XlfSourceFormat>Resx</XlfSourceFormat>
<XlfOutputItem>EmbeddedResource</XlfOutputItem>
<SubType>Designer</SubType>
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Logs.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/Aspire.Dashboard/Components/Dialogs/FilterDialog.razor
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
@using Aspire.Dashboard.Model
@using Aspire.Dashboard.Model.Otlp
@using Aspire.Dashboard.Otlp.Storage
@using Aspire.Dashboard.Resources
@using Microsoft.FluentUI.AspNetCore.Components;
@implements IDialogContentComponent<FilterDialogViewModel>

@inject IStringLocalizer<Dialogs> Loc
@inject IStringLocalizer<Logs> LogsLoc

<EditForm EditContext="@EditContext" OnValidSubmit="@Apply">
<DataAnnotationsValidator />

<FluentStack Orientation="Orientation.Vertical" VerticalGap="8">
<FluentCombobox Placeholder="@Loc[nameof(Dialogs.FilterDialogFieldPlaceholder)]" Items=@Parameters @bind-Value="@_formModel.Parameter" Width="100%" Height="500px" />

<FluentSelect TOption="SelectViewModel<FilterCondition>" Items="@s_filterConditions" @bind-SelectedOption="@_formModel.Condition" aria-label="@Loc[Dialogs.FilterDialogConditionSelectLabel]" OptionText="@(i => i.Name)" Width="100%" />
<FluentSelect TOption="SelectViewModel<FilterCondition>" Items="@_filterConditions" @bind-SelectedOption="@_formModel.Condition" aria-label="@Loc[Dialogs.FilterDialogConditionSelectLabel]" OptionText="@(i => i.Name)" Width="100%" />

<FluentTextField @bind-Value="_formModel.Value" Placeholder="@Loc[nameof(Dialogs.FilterDialogTextValuePlaceholder)]" />
<ValidationMessage For="() => _formModel.Value" />
Expand Down
24 changes: 13 additions & 11 deletions src/Aspire.Dashboard/Components/Dialogs/FilterDialog.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@ namespace Aspire.Dashboard.Components.Dialogs;

public partial class FilterDialog
{
private static readonly List<SelectViewModel<FilterCondition>> s_filterConditions = new()
{
CreateFilterSelectViewModel(FilterCondition.Equals),
CreateFilterSelectViewModel(FilterCondition.Contains),
CreateFilterSelectViewModel(FilterCondition.NotEqual),
CreateFilterSelectViewModel(FilterCondition.NotContains),
};
private List<SelectViewModel<FilterCondition>> _filterConditions = null!;

private static SelectViewModel<FilterCondition> CreateFilterSelectViewModel(FilterCondition condition) =>
new SelectViewModel<FilterCondition> { Id = condition, Name = LogFilter.ConditionToString(condition) };
private SelectViewModel<FilterCondition> CreateFilterSelectViewModel(FilterCondition condition) =>
new SelectViewModel<FilterCondition> { Id = condition, Name = LogFilter.ConditionToString(condition, LogsLoc) };

[CascadingParameter]
public FluentDialog? Dialog { get; set; }
Expand All @@ -37,19 +31,27 @@ private static SelectViewModel<FilterCondition> CreateFilterSelectViewModel(Filt

protected override void OnInitialized()
{
_filterConditions =
[
CreateFilterSelectViewModel(FilterCondition.Equals),
CreateFilterSelectViewModel(FilterCondition.Contains),
CreateFilterSelectViewModel(FilterCondition.NotEqual),
CreateFilterSelectViewModel(FilterCondition.NotContains)
];

_formModel = new LogDialogFormModel();
EditContext = new EditContext(_formModel);

if (Content.Filter is { } logFilter)
{
_formModel.Parameter = logFilter.Field;
_formModel.Condition = s_filterConditions.Single(c => c.Id == logFilter.Condition);
_formModel.Condition = _filterConditions.Single(c => c.Id == logFilter.Condition);
_formModel.Value = logFilter.Value;
}
else
{
_formModel.Parameter = "Message";
_formModel.Condition = s_filterConditions.Single(c => c.Id == FilterCondition.Contains);
_formModel.Condition = _filterConditions.Single(c => c.Id == FilterCondition.Contains);
_formModel.Value = "";
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/Aspire.Dashboard/Components/Pages/StructuredLogs.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
@using Aspire.Dashboard.Otlp.Model
@using Aspire.Dashboard.Utils
@using Microsoft.Extensions.Logging
@using System.Web
@using Aspire.Dashboard.Resources
@using System.Globalization
@inject IJSRuntime JS
@implements IDisposable

@inject IStringLocalizer<Dashboard.Resources.StructuredLogs> Loc
@inject IStringLocalizer<ControlsStrings> ControlsStringsLoc
@inject IStringLocalizer<Logs> LogsLoc

<PageTitle><ApplicationName ResourceName="@nameof(Dashboard.Resources.StructuredLogs.StructuredLogsPageTitle)" Loc="@Loc" /></PageTitle>

Expand All @@ -30,7 +31,7 @@
slot="end" />
<FluentDivider slot="end" Role="DividerRole.Presentation" Orientation="Orientation.Vertical" />
<div title="@Loc[nameof(Dashboard.Resources.StructuredLogs.StructuredLogsMinimumLogFilter)]" slot="end" style="display: flex;align-items: center;">
<span>Level:</span>
<span>@Loc[nameof(Dashboard.Resources.StructuredLogs.StructuredLogsLevels)]</span>
<FluentDivider Role="DividerRole.Presentation" Orientation="Orientation.Vertical" />
<FluentSelect TOption="SelectViewModel<LogLevel?>"
Items="@_logLevels"
Expand All @@ -52,7 +53,7 @@
{
foreach (var filter in ViewModel.Filters)
{
<FluentButton slot="end" Appearance="Appearance.Outline" OnClick="() => OpenFilterAsync(filter)">@filter.FilterText</FluentButton>
<FluentButton slot="end" Appearance="Appearance.Outline" OnClick="() => OpenFilterAsync(filter)">@filter.GetDisplayText(LogsLoc)</FluentButton>
<FluentDivider slot="end" Role="DividerRole.Presentation" Orientation="Orientation.Vertical" />
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/Aspire.Dashboard/Model/Otlp/LogFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Diagnostics;
using System.Globalization;
using Aspire.Dashboard.Otlp.Model;
using Aspire.Dashboard.Resources;
using Microsoft.Extensions.Localization;

namespace Aspire.Dashboard.Model.Otlp;

Expand All @@ -14,7 +16,9 @@ public class LogFilter
public FilterCondition Condition { get; set; }
public string Value { get; set; } = default!;

public string FilterText => $"{Field} {ConditionToString(Condition)} {Value}";
public string DebuggerDisplayText => $"{Field} {ConditionToString(Condition, null)} {Value}";

public string GetDisplayText(IStringLocalizer<Logs> loc) => $"{Field} {ConditionToString(Condition, loc)} {Value}";

public static List<string> GetAllPropertyNames(List<string> propertyKeys)
{
Expand All @@ -23,17 +27,17 @@ public static List<string> GetAllPropertyNames(List<string> propertyKeys)
return result;
}

public static string ConditionToString(FilterCondition c) =>
public static string ConditionToString(FilterCondition c, IStringLocalizer<Logs>? loc) =>
c switch
{
FilterCondition.Equals => "==",
FilterCondition.Contains => "contains",
FilterCondition.Contains => loc?[nameof(Logs.LogContains)] ?? "contains",
FilterCondition.GreaterThan => ">",
FilterCondition.LessThan => "<",
FilterCondition.GreaterThanOrEqual => ">=",
FilterCondition.LessThanOrEqual => "<=",
FilterCondition.NotEqual => "!=",
FilterCondition.NotContains => "not contains",
FilterCondition.NotContains => loc?[nameof(Logs.LogNotContains)] ?? "not contains",
_ => throw new ArgumentOutOfRangeException(nameof(c), c, null)
};

Expand Down
80 changes: 80 additions & 0 deletions src/Aspire.Dashboard/Resources/Logs.Designer.cs

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

108 changes: 108 additions & 0 deletions src/Aspire.Dashboard/Resources/Logs.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema

Version 1.3

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">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</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.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:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="LogContains" xml:space="preserve">
<value>contains</value>
</data>
<data name="LogNotContains" xml:space="preserve">
<value>not contains</value>
<comment>corresponds to A !contains B</comment>
</data>
</root>
9 changes: 9 additions & 0 deletions src/Aspire.Dashboard/Resources/StructuredLogs.Designer.cs

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

3 changes: 3 additions & 0 deletions src/Aspire.Dashboard/Resources/StructuredLogs.resx
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,7 @@
<data name="StructuredLogsAllApplications" xml:space="preserve">
<value>(All)</value>
</data>
<data name="StructuredLogsLevels" xml:space="preserve">
<value>Level:</value>
</data>
</root>
Loading
Loading