Skip to content

Commit

Permalink
PinIn
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Dec 7, 2021
1 parent 075bdf9 commit 42aa6fc
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 1 deletion.
2 changes: 1 addition & 1 deletion SteamToolsV2+.sln
Original file line number Diff line number Diff line change
Expand Up @@ -1828,7 +1828,7 @@ Global
{FB2CA9B4-71F1-48E8-B9AE-FF4375F4FE43} = {CC46B486-00D7-49E6-ABA3-FDF8F4868D2B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9313F2B4-10DA-43AA-A481-CAA7571C740C}
RESX_NeutralResourcesLanguage = zh-Hans
SolutionGuid = {9313F2B4-10DA-43AA-A481-CAA7571C740C}
EndGlobalSection
EndGlobal
41 changes: 41 additions & 0 deletions src/Common.PinyinLib.PinIn/Common.PinyinLib.PinIn.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFrameworks>MonoAndroid11.0;netstandard2.1</TargetFrameworks>
<RootNamespace>System</RootNamespace>
<AssemblyName>System.Common.PinyinLib.PinIn</AssemblyName>
</PropertyGroup>

<PropertyGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
<AndroidUseIntermediateDesignerFile>false</AndroidUseIntermediateDesignerFile>
<IsBindingProject>true</IsBindingProject>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.Version.cs">
<Link>Properties\AssemblyInfo.Version.cs</Link>
</Compile>
<Compile Include="..\Common.CoreLib\Properties\InternalsVisibleTo.cs">
<Link>Properties\InternalsVisibleTo.cs</Link>
</Compile>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Common.PinyinLib\Common.PinyinLib.csproj" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
<EmbeddedJar Include="Jars\PinIn-1.5.0-all.jar" />
<TransformFile Include="Transforms\Metadata.xml" />
</ItemGroup>

<ItemGroup Condition=" !$(TargetFramework.StartsWith('MonoAndroid')) ">
<Compile Remove="Transforms\**" />
<EmbeddedResource Remove="Transforms\**" />
<None Remove="Transforms\**" />
</ItemGroup>

</Project>
Binary file not shown.
35 changes: 35 additions & 0 deletions src/Common.PinyinLib.PinIn/PinyinImpl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Text;
#if MONOANDROID
using ME.Towdium.Pinin;
using PininFormat = ME.Towdium.Pinin.Utils.PinyinFormat;
#endif

// ReSharper disable once CheckNamespace
namespace System.Application.Services.Implementation
{
/// <summary>
/// 使用 <see cref="PinIn"/>(https://github.com/Towdium/PinIn) or (https://github.com/LasmGratel/PininSharp) 实现的拼音功能
/// </summary>
internal sealed class PinyinImpl : IPinyin
{
readonly PinIn p;

public PinyinImpl()
{
p = new();
}

public string GetPinyin(string s, PinyinFormat format)
{
var pinyin = p.GetPinyin(s);
return PininFormat.Raw.Format(pinyin);
return String.Empty;
}

public bool IsChinese(char c)
{
throw new NotImplementedException();
}
}
}
17 changes: 17 additions & 0 deletions src/Common.PinyinLib.PinIn/Transforms/Metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<metadata>
<!--
This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
-->

<!-- 文档参考 https://docs.microsoft.com/zh-cn/xamarin/android/platform/binding-java-library -->

<remove-node path="/api/package[@name='me.towdium.pinin.fastutil']" />
<remove-node path="/api/package[@name='me.towdium.pinin.fastutil.objects']" />
<remove-node path="/api/package[@name='me.towdium.pinin.fastutil.ints']" />
<remove-node path="/api/package[@name='me.towdium.pinin.fastutil.chars']" />
<remove-node path="/api/package[@name='me.towdium.pinin.fastutil.io']" />
</metadata>

0 comments on commit 42aa6fc

Please sign in to comment.