mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-23 01:44:26 +08:00
0.7.5.2
日韩支持
This commit is contained in:
48
LanMountainDesktop/Services/FontFamilyService.cs
Normal file
48
LanMountainDesktop/Services/FontFamilyService.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace LanMountainDesktop.Services;
|
||||
|
||||
public sealed class FontFamilyService
|
||||
{
|
||||
private const string FontsBasePath = "avares://LanMountainDesktop/Assets/Fonts";
|
||||
|
||||
public static readonly FontFamily DefaultFontFamily =
|
||||
new($"{FontsBasePath}#MiSans");
|
||||
|
||||
public static readonly FontFamily JapaneseFontFamily =
|
||||
new($"{FontsBasePath}#MiSans");
|
||||
|
||||
public static readonly FontFamily KoreanFontFamily =
|
||||
new($"Malgun Gothic, {FontsBasePath}#MiSans");
|
||||
|
||||
public FontFamily GetFontFamilyForLanguage(string? languageCode)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(languageCode))
|
||||
{
|
||||
return DefaultFontFamily;
|
||||
}
|
||||
|
||||
return languageCode.ToLowerInvariant() switch
|
||||
{
|
||||
"ja-jp" or "ja" => JapaneseFontFamily,
|
||||
"ko-kr" or "ko" => KoreanFontFamily,
|
||||
_ => DefaultFontFamily
|
||||
};
|
||||
}
|
||||
|
||||
public string GetFontFamilyResourceKey(string? languageCode)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(languageCode))
|
||||
{
|
||||
return "AppFontFamily";
|
||||
}
|
||||
|
||||
return languageCode.ToLowerInvariant() switch
|
||||
{
|
||||
"ja-jp" or "ja" => "AppFontFamilyJP",
|
||||
"ko-kr" or "ko" => "AppFontFamilyKR",
|
||||
_ => "AppFontFamily"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ public sealed class LocalizationService
|
||||
{
|
||||
"en-us" or "en" => "en-US",
|
||||
"ja-jp" or "ja" => "ja-JP",
|
||||
"ko-kr" or "ko" => "ko-KR",
|
||||
_ => "zh-CN"
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user