Skip to content

Commit

Permalink
Guide Localization Source
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Jan 10, 2025
1 parent ab0814a commit 46d51f3
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 46 deletions.
13 changes: 13 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Model/LocalizationSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

namespace Snap.Hutao.Model;

[Flags]
internal enum LocalizationSource
{
None = 0b0000,
Hutao = 0b0001,
Crowdin = 0b0010,
Gemini = 0b0100,
}
13 changes: 11 additions & 2 deletions src/Snap.Hutao/Snap.Hutao/Model/NameCultureInfoValue.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) DGP Studio. All rights reserved.
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using System.Globalization;
Expand All @@ -7,8 +7,17 @@ namespace Snap.Hutao.Model;

internal sealed class NameCultureInfoValue : NameValue<CultureInfo>
{
public NameCultureInfoValue(string name, CultureInfo value)
public NameCultureInfoValue(string name, CultureInfo value, LocalizationSource localizationSource)
: base(name, value)
{
IsMaintainedByHutao = localizationSource.HasFlag(LocalizationSource.Hutao);
IsMaintainedByCrowdin = localizationSource.HasFlag(LocalizationSource.Crowdin);
IsMaintainedByGemini = localizationSource.HasFlag(LocalizationSource.Gemini);
}

public bool IsMaintainedByHutao { get; }

public bool IsMaintainedByCrowdin { get; }

public bool IsMaintainedByGemini { get; }
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,15 @@
<data name="ViewGuideStepLanguage" xml:space="preserve">
<value>语言</value>
</data>
<data name="ViewGuideStepLanguageMaintainedByCrowdin" xml:space="preserve">
<value>由 Crowdin 社区成员维护</value>
</data>
<data name="ViewGuideStepLanguageMaintainedByGemini" xml:space="preserve">
<value>由 Google Gemini 翻译</value>
</data>
<data name="ViewGuideStepLanguageMaintainedByHutao" xml:space="preserve">
<value>由 DGP Studio 维护</value>
</data>
<data name="ViewGuideStepStaticResource" xml:space="preserve">
<value>资源</value>
</data>
Expand Down
24 changes: 12 additions & 12 deletions src/Snap.Hutao/Snap.Hutao/Service/SupportedCultures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ public static ImmutableArray<NameCultureInfoValue> Values
get;
} =
[
ToNameValue(CultureInfo.GetCultureInfo("zh-Hans")),
ToNameValue(CultureInfo.GetCultureInfo("zh-Hant")),
ToNameValue(CultureInfo.GetCultureInfo("zh-Hans"), LocalizationSource.Hutao),
ToNameValue(CultureInfo.GetCultureInfo("zh-Hant"), LocalizationSource.Crowdin),
/*ToNameValue(CultureInfo.GetCultureInfo("de")),*/
ToNameValue(CultureInfo.GetCultureInfo("en")),
ToNameValue(CultureInfo.GetCultureInfo("en"), LocalizationSource.Hutao),
/*ToNameValue(CultureInfo.GetCultureInfo("es")),*/
ToNameValue(CultureInfo.GetCultureInfo("fr")),
ToNameValue(CultureInfo.GetCultureInfo("id")),
ToNameValue(CultureInfo.GetCultureInfo("fr"), LocalizationSource.Gemini),
ToNameValue(CultureInfo.GetCultureInfo("id"), LocalizationSource.Gemini),
/*ToNameValue(CultureInfo.GetCultureInfo("it")),*/
ToNameValue(CultureInfo.GetCultureInfo("ja")),
ToNameValue(CultureInfo.GetCultureInfo("ko")),
ToNameValue(CultureInfo.GetCultureInfo("pt")),
ToNameValue(CultureInfo.GetCultureInfo("ru")),
ToNameValue(CultureInfo.GetCultureInfo("ja"), LocalizationSource.Crowdin),
ToNameValue(CultureInfo.GetCultureInfo("ko"), LocalizationSource.Crowdin | LocalizationSource.Gemini),
ToNameValue(CultureInfo.GetCultureInfo("pt"), LocalizationSource.Gemini),
ToNameValue(CultureInfo.GetCultureInfo("ru"), LocalizationSource.Gemini),
/*ToNameValue(CultureInfo.GetCultureInfo("th")),*/
/*ToNameValue(CultureInfo.GetCultureInfo("tr")),*/
ToNameValue(CultureInfo.GetCultureInfo("vi")),
ToNameValue(CultureInfo.GetCultureInfo("vi"), LocalizationSource.Gemini),
];

private static NameCultureInfoValue ToNameValue(CultureInfo info)
private static NameCultureInfoValue ToNameValue(CultureInfo info, LocalizationSource source)
{
return new(info.NativeName, info);
return new(info.NativeName, info, source);
}
}
18 changes: 12 additions & 6 deletions src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@
<None Remove="Assets\Wide310x150Logo.scale-400.png" />
<None Remove="BannedSymbols.txt" />
<None Remove="CodeMetricsConfig.txt" />
<None Remove="Resource\GuideLocalization\crowdin-symbol-cDark-64.png" />
<None Remove="Resource\GuideLocalization\crowdin-symbol-cWhite-64.png" />
<None Remove="Resource\GuideLocalization\DGP-v3-white-64.png" />
<None Remove="Resource\GuideLocalization\Gemini-64.png" />
<None Remove="Resource\Icon\UI_IconSmall_EP.png" />
<None Remove="Resource\Icon\UI_Icon_RelicType3.png" />
<None Remove="Resource\Icon\UI_Icon_RelicType4.png" />
Expand All @@ -115,8 +119,8 @@
<None Remove="Resource\ThirdParty\Apple.png" />
<None Remove="Resource\ThirdParty\Facebook.png" />
<None Remove="Resource\ThirdParty\Google.png" />
<None Remove="Resource\ThirdParty\hoyolab_ic_launcher_foreground.webp" />
<None Remove="Resource\ThirdParty\miyoushe_ic_launcher.png" />
<None Remove="Resource\ThirdParty\hoyolab128.png" />
<None Remove="Resource\ThirdParty\miyoushe128.png" />
<None Remove="Resource\ThirdParty\Twitter.png" />
<None Remove="IdentityStructs.json" />
<None Remove="Resource\BlurBackground.png" />
Expand Down Expand Up @@ -213,17 +217,17 @@
<Content Update="Assets\Wide310x150Logo.scale-100.png" />
<Content Update="Assets\Wide310x150Logo.scale-200.png" />
<Content Update="Assets\Wide310x150Logo.scale-400.png" />
<None Remove="Resource\ThirdParty\miyoushe128.png" />
<Content Include="Resource\ThirdParty\miyoushe128.png" />
<None Remove="Resource\ThirdParty\hoyolab128.png" />
<Content Include="Resource\ThirdParty\hoyolab128.png" />
</ItemGroup>

<!-- Resources Files -->
<ItemGroup>
<Content Include="Resource\BlurBackground.png" />
<Content Include="Resource\Font\CascadiaMono.ttf" />
<Content Include="Resource\Font\MiSans-Regular.ttf" />
<Content Include="Resource\GuideLocalization\crowdin-symbol-cDark-64.png" />
<Content Include="Resource\GuideLocalization\crowdin-symbol-cWhite-64.png" />
<Content Include="Resource\GuideLocalization\DGP-v3-white-64.png" />
<Content Include="Resource\GuideLocalization\Gemini-64.png" />
<Content Include="Resource\GuideStaticResourceQualityComparison.png" />
<Content Include="Resource\HutaoIconSourceTransparentBackgroundGradient1.png" />
<Content Include="Resource\Icon\UI_GachaShowPanel_Bg_Weapon.png" />
Expand Down Expand Up @@ -264,6 +268,8 @@
<Content Include="Resource\ThirdParty\Apple.png" />
<Content Include="Resource\ThirdParty\Facebook.png" />
<Content Include="Resource\ThirdParty\Google.png" />
<Content Include="Resource\ThirdParty\hoyolab128.png" />
<Content Include="Resource\ThirdParty\miyoushe128.png" />
<Content Include="Resource\ThirdParty\Twitter.png" />
<Content Include="Resource\WelcomeView_Background.png" />
<Content Include="Resource\Icon\UI_Icon_Tower_Star1.png" />
Expand Down
182 changes: 156 additions & 26 deletions src/Snap.Hutao/Snap.Hutao/UI/Xaml/View/GuideView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
xmlns:shm="using:Snap.Hutao.Model"
xmlns:shuxb="using:Snap.Hutao.UI.Xaml.Behavior"
xmlns:shuxcc="using:Snap.Hutao.UI.Xaml.Control.Card"
xmlns:shuxm="using:Snap.Hutao.UI.Xaml.Markup"
xmlns:shvg="using:Snap.Hutao.ViewModel.Guide"
d:DataContext="{d:DesignInstance shvg:GuideViewModel}"
Expand All @@ -19,31 +20,88 @@
</mxi:Interaction.Behaviors>

<UserControl.Resources>
<DataTemplate x:Key="LanguageTemplate" x:DataType="shm:NameCultureInfoValue">
<StackPanel MinWidth="240" Margin="16">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding Name}"/>
<TextBlock Opacity="0.8" Text="{Binding Value}"/>
</StackPanel>
</DataTemplate>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<x:String x:Key="LogoCrowdin">ms-appx:///Resource/GuideLocalization/crowdin-symbol-cDark-64.png</x:String>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<x:String x:Key="LogoCrowdin">ms-appx:///Resource/GuideLocalization/crowdin-symbol-cWhite-64.png</x:String>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<x:String x:Key="LogoDGPStudio">ms-appx:///Resource/GuideLocalization/DGP-v3-white-64.png</x:String>
<x:String x:Key="LogoGemini">ms-appx:///Resource/GuideLocalization/Gemini-64.png</x:String>

<DataTemplate x:Key="DownloadSummaryTemplate" x:DataType="shvg:DownloadSummary">
<Border
Width="180"
Margin="0,0,4,4"
Style="{StaticResource BorderCardStyle}">
<StackPanel Margin="8">
<TextBlock Text="{Binding Filename}"/>
<ProgressBar
Margin="0,4,0,0"
Maximum="1"
Value="{Binding ProgressValue}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding Description}"/>
</StackPanel>
</Border>
</DataTemplate>
<DataTemplate x:Key="LanguageTemplate" x:DataType="shm:NameCultureInfoValue">
<Grid MinWidth="280" Margin="16">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding Name}"/>
<TextBlock Opacity="0.8" Text="{Binding Value}"/>
</StackPanel>
<StackPanel
Grid.Column="1"
Orientation="Horizontal"
Spacing="8">
<Border
VerticalAlignment="Center"
CornerRadius="8"
Visibility="{Binding IsMaintainedByHutao, Converter={StaticResource BoolToVisibilityConverter}}">
<Image
Width="32"
Height="32"
VerticalAlignment="Center"
Source="{ThemeResource LogoDGPStudio}"
Stretch="Uniform"/>
</Border>
<Border
VerticalAlignment="Center"
CornerRadius="8"
Visibility="{Binding IsMaintainedByCrowdin, Converter={StaticResource BoolToVisibilityConverter}}">
<Image
Width="32"
Height="32"
VerticalAlignment="Center"
Source="{ThemeResource LogoCrowdin}"
Stretch="Uniform"/>
</Border>
<Border
VerticalAlignment="Center"
CornerRadius="8"
Visibility="{Binding IsMaintainedByGemini, Converter={StaticResource BoolToVisibilityConverter}}">
<Image
Width="32"
Height="32"
VerticalAlignment="Center"
Source="{ThemeResource LogoGemini}"
Stretch="Uniform"/>
</Border>
</StackPanel>
</Grid>
</DataTemplate>

<DataTemplate x:Key="DownloadSummaryTemplate" x:DataType="shvg:DownloadSummary">
<Border
Width="180"
Margin="0,0,4,4"
Style="{StaticResource BorderCardStyle}">
<StackPanel Margin="8">
<TextBlock Text="{Binding Filename}"/>
<ProgressBar
Margin="0,4,0,0"
Maximum="1"
Value="{Binding ProgressValue}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding Description}"/>
</StackPanel>
</Border>
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>

<Grid Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}">
Expand All @@ -63,13 +121,85 @@
ContentTransitions="{ThemeResource EntranceThemeTransitions}"
Value="{Binding State, Mode=OneWay}">
<cwc:Case Value="{shuxm:UInt32 Value=0}">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<GridView
Grid.Row="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ItemTemplate="{StaticResource LanguageTemplate}"
ItemsSource="{Binding CultureOptions.Cultures}"
SelectedItem="{Binding SelectedCulture, Mode=TwoWay}"
SelectionMode="Single"/>
<StackPanel
Grid.Row="1"
Orientation="Horizontal"
Spacing="16"/>
<StackPanel
Grid.Row="2"
Grid.Column="1"
HorizontalAlignment="Center"
Orientation="Horizontal"
Spacing="8">
<shuxcc:HorizontalCard>
<shuxcc:HorizontalCard.Left>
<Border VerticalAlignment="Center" CornerRadius="8">
<Image
Width="32"
Height="32"
VerticalAlignment="Center"
Source="{ThemeResource LogoDGPStudio}"
Stretch="Uniform"/>
</Border>
</shuxcc:HorizontalCard.Left>
<shuxcc:HorizontalCard.Right>
<TextBlock
Margin="6,0"
VerticalAlignment="Center"
Text="{shuxm:ResourceString Name=ViewGuideStepLanguageMaintainedByHutao}"/>
</shuxcc:HorizontalCard.Right>
</shuxcc:HorizontalCard>
<shuxcc:HorizontalCard>
<shuxcc:HorizontalCard.Left>
<Border VerticalAlignment="Center" CornerRadius="8">
<Image
Width="32"
Height="32"
VerticalAlignment="Center"
Source="{ThemeResource LogoCrowdin}"
Stretch="Uniform"/>
</Border>
</shuxcc:HorizontalCard.Left>
<shuxcc:HorizontalCard.Right>
<TextBlock
Margin="6,0"
VerticalAlignment="Center"
Text="{shuxm:ResourceString Name=ViewGuideStepLanguageMaintainedByCrowdin}"/>
</shuxcc:HorizontalCard.Right>
</shuxcc:HorizontalCard>
<shuxcc:HorizontalCard>
<shuxcc:HorizontalCard.Left>
<Border VerticalAlignment="Center" CornerRadius="8">
<Image
Width="32"
Height="32"
VerticalAlignment="Center"
Source="{ThemeResource LogoGemini}"
Stretch="Uniform"/>
</Border>
</shuxcc:HorizontalCard.Left>
<shuxcc:HorizontalCard.Right>
<TextBlock
Margin="6,0"
VerticalAlignment="Center"
Text="{shuxm:ResourceString Name=ViewGuideStepLanguageMaintainedByGemini}"/>
</shuxcc:HorizontalCard.Right>
</shuxcc:HorizontalCard>
</StackPanel>
</Grid>
</cwc:Case>
<cwc:Case Value="{shuxm:UInt32 Value=1}">
Expand Down Expand Up @@ -370,4 +500,4 @@
</StackPanel>
</Grid>
</Grid>
</UserControl>
</UserControl>

0 comments on commit 46d51f3

Please sign in to comment.