Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
WaterfallPage多语言改造
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiichiamane committed May 28, 2019
1 parent 6e066f3 commit f04c775
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 11 deletions.
6 changes: 6 additions & 0 deletions PixivFSUWP/Data/OverAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,11 @@ public static string TryGetString(this IJsonValue source)
return "";
return source.GetString();
}

public static string GetResourceString(string ID)
{
var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
return resourceLoader.GetString(ID);
}
}
}
44 changes: 44 additions & 0 deletions PixivFSUWP/Strings/zh/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
<value>生日</value>
<comment>TextBlock</comment>
</data>
<data name="BookmarkDeleteFailedPlain" xml:space="preserve">
<value>作品「{0}」删除收藏失败</value>
<comment>PlainText</comment>
</data>
<data name="Bookmarked.Content" xml:space="preserve">
<value>收藏</value>
<comment>NavigationViewItem</comment>
Expand Down Expand Up @@ -173,6 +177,14 @@
<value>按日期降序</value>
<comment>ComboBoxItem</comment>
</data>
<data name="DeleteBookmarkPlain" xml:space="preserve">
<value>删除收藏</value>
<comment>PlainText</comment>
</data>
<data name="DeletedBookmarkPlain" xml:space="preserve">
<value>作品「{0}」已删除收藏</value>
<comment>PlainText</comment>
</data>
<data name="Desk.Text" xml:space="preserve">
<value>桌子</value>
<comment>TextBlock</comment>
Expand Down Expand Up @@ -313,10 +325,18 @@
<value>未收藏</value>
<comment>TextBlock</comment>
</data>
<data name="NotBookmarkedPlain" xml:space="preserve">
<value>未收藏</value>
<comment>PlainText</comment>
</data>
<data name="NotFollowing.Text" xml:space="preserve">
<value>未关注</value>
<comment>TextBlock</comment>
</data>
<data name="NotFollowingPlain" xml:space="preserve">
<value>未关注</value>
<comment>PlainText</comment>
</data>
<data name="OKPlain" xml:space="preserve">
<value>好的</value>
<comment>PlainText</comment>
Expand Down Expand Up @@ -365,6 +385,10 @@
<value>快速收藏</value>
<comment>MenuFlyoutItem</comment>
</data>
<data name="QuickBookmarkPlain" xml:space="preserve">
<value>快速收藏</value>
<comment>PlainText</comment>
</data>
<data name="QuickDownload.Text" xml:space="preserve">
<value>快速保存</value>
<comment>MenuFlyoutItem</comment>
Expand Down Expand Up @@ -461,6 +485,10 @@
<value>停止</value>
<comment>TextBlock</comment>
</data>
<data name="StopPlain" xml:space="preserve">
<value>停止</value>
<comment>PlainText</comment>
</data>
<data name="Tablet.Text" xml:space="preserve">
<value>数位板</value>
<comment>TextBlock</comment>
Expand Down Expand Up @@ -497,8 +525,24 @@
<value>作品</value>
<comment>TextBlock</comment>
</data>
<data name="WorkBookmarkedPlain" xml:space="preserve">
<value>作品「{0}」已收藏</value>
<comment>PlainText</comment>
</data>
<data name="WorkBookmarkFailedPlain" xml:space="preserve">
<value>作品「{0}」收藏失败</value>
<comment>PlainText</comment>
</data>
<data name="WorkPlain" xml:space="preserve">
<value>Pixiv作品</value>
<comment>PlainText</comment>
</data>
<data name="WorkSavedPlain" xml:space="preserve">
<value>作品「{0}」已保存</value>
<comment>PlainText</comment>
</data>
<data name="WorkSaveFailedPlain" xml:space="preserve">
<value>作品「{0}」保存失败</value>
<comment>PlainText</comment>
</data>
</root>
4 changes: 2 additions & 2 deletions PixivFSUWP/WaterfallPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
<ListView.Resources>
<MenuFlyout x:Name="quickActions">
<MenuFlyout.Items>
<MenuFlyoutItem x:Name="quickStar" Text="快速收藏" Click="QuickStar_Click">
<MenuFlyoutItem x:Name="quickStar" x:Uid="QuickBookmark" Click="QuickStar_Click">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE734;"/>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem x:Name="quickSave" Text="快速保存" Click="QuickSave_Click">
<MenuFlyoutItem x:Name="quickSave" x:Uid="QuickDownload" Click="QuickSave_Click">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE74E;"/>
</MenuFlyoutItem.Icon>
Expand Down
23 changes: 14 additions & 9 deletions PixivFSUWP/WaterfallPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using PixivFSUWP.Interfaces;
using static PixivFSUWP.Data.OverAll;

// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板

Expand Down Expand Up @@ -122,7 +123,9 @@ private void WaterfallListView_RightTapped(object sender, RightTappedRoutedEvent
{
ListView listView = (ListView)sender;
tapped = ((FrameworkElement)e.OriginalSource).DataContext as ViewModels.WaterfallItemViewModel;
quickStar.Text = (tapped.IsBookmarked) ? "删除收藏" : "快速收藏";
quickStar.Text = (tapped.IsBookmarked) ?
GetResourceString("DeleteBookmarkPlain") :
GetResourceString("QuickBookmarkPlain");
quickStar.IsEnabled = tapped.Title != null;
quickActions.ShowAt(listView, e.GetPosition(listView));
}
Expand All @@ -131,7 +134,9 @@ private void WaterfallListView_Holding(object sender, HoldingRoutedEventArgs e)
{
ListView listView = (ListView)sender;
tapped = ((FrameworkElement)e.OriginalSource).DataContext as ViewModels.WaterfallItemViewModel;
quickStar.Text = (tapped.IsBookmarked) ? "删除收藏" : "快速收藏";
quickStar.Text = (tapped.IsBookmarked) ?
GetResourceString("DeleteBookmarkPlain") :
GetResourceString("QuickBookmarkPlain");
quickStar.IsEnabled = tapped.Title != null;
quickActions.ShowAt(listView, e.GetPosition(listView));
}
Expand Down Expand Up @@ -166,12 +171,12 @@ private async void QuickStar_Click(object sender, RoutedEventArgs e)
i.NotifyChange("StarsString");
i.NotifyChange("IsBookmarked");
await ((Frame.Parent as Grid)?.Parent as MainPage)?.
ShowTip(string.Format("作品「{0}」已删除收藏", title));
ShowTip(string.Format(GetResourceString("DeletedBookmarkPlain"), title));
}
else
{
await ((Frame.Parent as Grid)?.Parent as MainPage)?.
ShowTip(string.Format("作品「{0}」删除收藏失败", title));
ShowTip(string.Format(GetResourceString("BookmarkDeleteFailedPlain"), title));
}
}
else
Expand All @@ -195,12 +200,12 @@ private async void QuickStar_Click(object sender, RoutedEventArgs e)
i.NotifyChange("StarsString");
i.NotifyChange("IsBookmarked");
await ((Frame.Parent as Grid)?.Parent as MainPage)?.
ShowTip(string.Format("作品「{0}」已收藏", title));
ShowTip(string.Format(GetResourceString("WorkBookmarkedPlain"), title));
}
else
{
await ((Frame.Parent as Grid)?.Parent as MainPage)?.
ShowTip(string.Format("作品「{0}」收藏失败", title));
ShowTip(string.Format(GetResourceString("WorkBookmarkFailedPlain"), title));
}
}
}
Expand All @@ -217,7 +222,7 @@ private async void QuickSave_Click(object sender, RoutedEventArgs e)
var i = tapped;
FileSavePicker picker = new FileSavePicker();
picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
picker.FileTypeChoices.Add("图片文件", new List<string>() { ".png" });
picker.FileTypeChoices.Add(GetResourceString("ImageFilePlain"), new List<string>() { ".png" });
picker.SuggestedFileName = i.Title;
var file = await picker.PickSaveFileAsync();
if (file != null)
Expand All @@ -236,10 +241,10 @@ private async void QuickSave_Click(object sender, RoutedEventArgs e)
var updateStatus = await CachedFileManager.CompleteUpdatesAsync(file);
if (updateStatus == FileUpdateStatus.Complete)
await ((Frame.Parent as Grid)?.Parent as MainPage)?.
ShowTip(string.Format("作品「{0}」已保存", i.Title));
ShowTip(string.Format(GetResourceString("WorkSavedPlain"), i.Title));
else
await ((Frame.Parent as Grid)?.Parent as MainPage)?.
ShowTip(string.Format("作品「{0}」保存失败", i.Title));
ShowTip(string.Format(GetResourceString("WorkSaveFailedPlain"), i.Title));
}
}
}
Expand Down

0 comments on commit f04c775

Please sign in to comment.