Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Update document
Browse files Browse the repository at this point in the history
  • Loading branch information
feast107 committed Nov 4, 2023
1 parent 18d3ad1 commit d33ad6f
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 27 deletions.
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# Antelcat.Avalonia.I18N
Reactive language support for Avalonia applications when using .resx file.
<div align="center">

<h1>

Antelcat.Avalonia.`{I18N}`

</h1>

给Avalonia应用程序提供响应式的多语言支持。

</div>

<p align="center">
<img alt="dotnet-version" src="https://img.shields.io/badge/Avalonia-%3E%3D11.0.0-AE42F8.svg"/>
<img alt="csharp-version" src="https://img.shields.io/badge/C%23-preview-3BA93F.svg"/>
<img alt="nuget" src="https://img.shields.io/badge/Nuget-v1.0.0-blue.svg"/>
</p>

---

## 📖 About

本项目构建自 [Antelcat.Wpf.I18N](https://github.com/Antelcat/Antelcat.Avalonia.I18N) ,并且有着完全一致的API。
2 changes: 1 addition & 1 deletion extern/Antelcat.Wpf.I18N
14 changes: 12 additions & 2 deletions src/Antelcat.Avalonia.I18N.Demo/Antelcat.Avalonia.I18N.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<Nullable>enable</Nullable>
<TrimMode>copyused</TrimMode>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<Company>Antelcat</Company>
<Product>Antelcat.Avalonia.I18N.Demo-1.0.0</Product>
<ApplicationIcon>..\..\extern\Antelcat.Wpf.I18N\src\Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<!--This helps with theme dll-s trimming.
Expand All @@ -21,11 +26,11 @@
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.5" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference OutputItemType="Analyzer" ReferenceOutputAssembly="false" Include="..\Antelcat.Avalonia.I18N.SourceGenerators\Antelcat.Avalonia.I18N.SourceGenerators\Antelcat.Avalonia.I18N.SourceGenerators.csproj" />
<ProjectReference OutputItemType="Analyzer" ReferenceOutputAssembly="false" Include="..\Antelcat.Avalonia.I18N.SourceGenerators\Antelcat.Avalonia.I18N.SourceGenerators.csproj" />
<ProjectReference Include="..\Antelcat.Avalonia.I18N\Antelcat.Avalonia.I18N.csproj" />
</ItemGroup>
<ItemGroup>
Expand All @@ -44,4 +49,9 @@
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\extern\Antelcat.Wpf.I18N\src\Icon.ico">
<Link>Icon.ico</Link>
</None>
</ItemGroup>
</Project>
4 changes: 3 additions & 1 deletion src/Antelcat.Avalonia.I18N.Demo/App.axaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:styling="clr-namespace:FluentAvalonia.Styling;assembly=FluentAvalonia"
RequestedThemeVariant="Light"
x:Class="Antelcat.Avalonia.I18N.Demo.App">
<Application.Styles>
<FluentTheme />
<!-- As of preview5, these properties now default to false -->
<styling:FluentAvaloniaTheme PreferSystemTheme="True" PreferUserAccentColor="True" />
</Application.Styles>
</Application>
6 changes: 6 additions & 0 deletions src/Antelcat.Avalonia.I18N.Demo/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Antelcat.Avalonia.I18N.Demo.ViewModels;
using Antelcat.Avalonia.I18N.Demo.Views;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Avalonia.Styling;

namespace Antelcat.Avalonia.I18N.Demo
{
Expand All @@ -11,6 +13,10 @@ public partial class App : Application
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
if (Design.IsDesignMode)
{
RequestedThemeVariant = ThemeVariant.Dark;
}
}

public override void OnFrameworkInitializationCompleted()
Expand Down
24 changes: 11 additions & 13 deletions src/Antelcat.Avalonia.I18N.Demo/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
xmlns:viewModels="clr-namespace:Antelcat.Avalonia.I18N.Demo.ViewModels"
xmlns:ms="clr-namespace:Antelcat.Avalonia.I18N.Demo.Models"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"

Height="400" Width="800"
x:DataType="viewModels:ViewModel"
WindowStartupLocation="CenterScreen"
x:Class="Antelcat.Avalonia.I18N.Demo.Views.MainWindow"
Title="Antelcat.Avalonia.I18N.Demo">

Expand All @@ -23,7 +24,7 @@
<ScrollViewer
Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Grid,AncestorLevel=1},Path=Height}">
<StackPanel>
<Menu Margin="0" Padding="0" Background="Transparent">
<Menu Margin="12" Padding="0" Background="Transparent">
<MenuItem Margin="0" Padding="0">
<MenuItem.Header>
<TextBlock FontSize="24">
Expand All @@ -43,7 +44,7 @@
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<StackPanel>
<Grid Margin="0,0,10,0">
<Grid>
<StackPanel>
<Menu Background="Transparent">
<MenuItem>
Expand All @@ -55,6 +56,7 @@
</Menu>
<ComboBox
Margin="12,0"
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Grid,AncestorLevel=1},Path=Width}"
SelectedItem="{Binding SelectedKey}"
ItemsSource="{Binding AvailableKeys}" />
<Menu Background="Transparent">
Expand All @@ -65,26 +67,23 @@
</MenuItem>
</Menu>

<TextBox Text="{I18N {Binding SelectedKey}}" Margin="12,0" />
<TextBox Margin="12,0" Text="{I18N {Binding SelectedKey}}" />

</StackPanel>
</Grid>
<Grid Grid.Row="1" Margin="10,12,10,0">
<Grid Grid.Row="1" Margin="12,10">
<StackPanel>
<TextBlock Text="{I18N {x:Static ms:LangKeys.Input_your_text_to_translate}}"></TextBlock>
<TextBox Margin="0,10"
Text="{Binding InputText}">
</TextBox>
<TextBox Margin="0,10" Text="{Binding InputText}"/>
<TextBlock Text="{I18N {x:Static ms:LangKeys.Translated_text}}" />
<TextBlock Text="{I18N {Binding InputText}}" Margin="0,10" />
<TextBlock Text="{I18N {Binding InputText}}" />
</StackPanel>
</Grid>
</StackPanel>
<Grid Grid.Column="1">
<StackPanel>
<TextBlock Text="{I18N {x:Static ms:LangKeys.Available_languages}}"></TextBlock>
<ListBox Margin="0,10"
ItemsSource="{Binding AvailableCultures}"
<TextBlock Margin="0,10" Text="{I18N {x:Static ms:LangKeys.Available_languages}}"></TextBlock>
<ListBox ItemsSource="{Binding AvailableCultures}"
SelectedItem="{Binding Culture}">
<ListBox.ItemTemplate>
<DataTemplate>
Expand All @@ -96,7 +95,6 @@
</Grid>
</Grid>
</StackPanel>

</ScrollViewer>
</Grid>
</Border>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
<ProjectReference
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
Include="..\..\..\extern\Antelcat.Wpf.I18N\extern\CodeAnalysis.Extensions\src\Feast.CodeAnalysis.Extensions.SourceGenerators\Feast.CodeAnalysis.Extensions.SourceGenerators.csproj"/>
Include="..\..\extern\Antelcat.Wpf.I18N\extern\CodeAnalysis.Extensions\src\Feast.CodeAnalysis.Extensions.SourceGenerators\Feast.CodeAnalysis.Extensions.SourceGenerators.csproj"/>
</ItemGroup>

<Import Project="..\..\..\extern\Antelcat.Wpf.I18N\src\Antelcat.Shared.I18N.SourceGenerators\Antelcat.Shared.I18N.SourceGenerators.projitems" Label="Shared"/>
<Import Project="..\..\extern\Antelcat.Wpf.I18N\src\Antelcat.Shared.I18N.SourceGenerators\Antelcat.Shared.I18N.SourceGenerators.projitems" Label="Shared"/>


</Project>
7 changes: 6 additions & 1 deletion src/Antelcat.Avalonia.I18N.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extern", "Extern", "{9EB247CE-2BC3-4FAF-A6BD-82CBFF42DC5B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "__", "__", "{399E7DF0-E0B2-4181-A31F-EFCEC63E73CB}"
ProjectSection(SolutionItems) = preProject
..\extern\Antelcat.Wpf.I18N\Icon.png = ..\extern\Antelcat.Wpf.I18N\Icon.png
..\LICENSE = ..\LICENSE
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Antelcat.Shared.I18N.SourceGenerators", "..\extern\Antelcat.Wpf.I18N\src\Antelcat.Shared.I18N.SourceGenerators\Antelcat.Shared.I18N.SourceGenerators.shproj", "{15D71DC2-F53D-42EC-85E4-4982F6E351A5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antelcat.Avalonia.I18N.SourceGenerators", "Antelcat.Avalonia.I18N.SourceGenerators\Antelcat.Avalonia.I18N.SourceGenerators\Antelcat.Avalonia.I18N.SourceGenerators.csproj", "{AECE67EE-A77B-4D76-81AF-B3681CBDB061}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antelcat.Avalonia.I18N.SourceGenerators", "Antelcat.Avalonia.I18N.SourceGenerators\Antelcat.Avalonia.I18N.SourceGenerators.csproj", "{AECE67EE-A77B-4D76-81AF-B3681CBDB061}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Feast.CodeAnalysis.Extensions.SourceGenerators", "..\extern\Antelcat.Wpf.I18N\extern\CodeAnalysis.Extensions\src\Feast.CodeAnalysis.Extensions.SourceGenerators\Feast.CodeAnalysis.Extensions.SourceGenerators.csproj", "{94E2F592-7943-435A-9BFA-DE667874BF5C}"
EndProject
Expand Down
32 changes: 27 additions & 5 deletions src/Antelcat.Avalonia.I18N/Antelcat.Avalonia.I18N.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,44 @@
<Copyright>Copyright Antelcat. All rights reserved</Copyright>
<PackageProjectUrl>https://github.com/Antelcat/Antelcat.Avalonia.I18N</PackageProjectUrl>
<RepositoryUrl>https://github.com/Antelcat/Antelcat.Avalonia.I18N.git</RepositoryUrl>
<AssemblyVersion>1.1.0</AssemblyVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>Antelcat</Authors>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>Reduce xaml declaration length; Support cs code translate.</PackageReleaseNotes>
<PackageReleaseNotes>Initial release</PackageReleaseNotes>
<PackageTags>dotnet;Avalonia;markup;extension;MVVM;i18n;language;binding;.NET;</PackageTags>
<Version>1.0.0</Version>

<DefineConstants>AVALONIA</DefineConstants>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>Icon.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0" />
<PackageReference Include="Avalonia" Version="11.0.0"/>
</ItemGroup>

<ItemGroup>
<Content Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</Content>
<None Include="..\..\extern\Antelcat.Wpf.I18N\Icon.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
<Link>Icon.png</Link>
</None>
</ItemGroup>

<ItemGroup Label="Package">
<None Include="..\Antelcat.Avalonia.I18N.SourceGenerators\bin\$(Configuration)\netstandard2.0\Antelcat.Avalonia.I18N.SourceGenerators.dll" PackagePath="analyzers\dotnet\cs" Pack="true" Visible="false" />
</ItemGroup>

<ItemGroup>
<ProjectReference ReferenceOutputAssembly="false" Include="..\Antelcat.Avalonia.I18N.SourceGenerators\Antelcat.Avalonia.I18N.SourceGenerators.csproj" />
</ItemGroup>

<Import Project="..\..\extern\Antelcat.Wpf.I18N\src\Antelcat.Shared.I18N\Antelcat.Shared.I18N.projitems" Label="Shared" />
<Import Project="..\..\extern\Antelcat.Wpf.I18N\src\Antelcat.Shared.I18N\Antelcat.Shared.I18N.projitems" Label="Shared"/>

</Project>

0 comments on commit d33ad6f

Please sign in to comment.