Skip to content

Commit

Permalink
Support localization
Browse files Browse the repository at this point in the history
  • Loading branch information
Kannagi authored and Kannagi committed Nov 14, 2022
1 parent 4b0136e commit 3735467
Show file tree
Hide file tree
Showing 12 changed files with 311 additions and 67 deletions.
67 changes: 67 additions & 0 deletions languages/en-US/yt-dlp-gui.lang
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
AppName: yt-dlp-gui
Main:
# Basic
Url: Url
Title: Title
Desc: Description
SaveAs: Save As...
Thumbnail: Thumbnail
About: About...
# Tab Formats
Formats: Formats
Video: Video
Audio: Audio
Subtitle: Subtitle
VideoRes: Resolution
VideoFPS: FPS
VideoExt: Ext.
VideoCodec: Codec
VideoSize: FileSize
AudioSampleRate: ASR
AudioExt: Ext.
AudioCodec: Codec
AudioSize: FileSize
# Tab Formats
Advance: Advance
EmbedSubs: Embed Subtitles
EmbedSubsEnabled: Enabled
TimeRange: Time Range
TimeRangeHits: --download-sections
TimeRangeHelper: "*10:15-15:00"
# Tab Options
Options: Options
Notifications: Notifications
NotificationsEnabled: Enabled
AlwaysOnTop: Always On Top
AlwaysOnTopEnabled: Enabled
RememberWindowState: Remember Window State
RememberWindowPosition: Position
RememberWindowSize: Size
Cookie: Cookie
CookieWhenNeeded: When Needed
CookieNever: Never
CookieAlways: Always
CookieAsk: Ask
CookieUse: Use
Configuration: Configuration
ConfigurationNone: "[None]"
Aria2: Aria2
Aria2Enabled: Enabled
# Label
Live: LIVE
DownloadThumb: Download Thumbnail
# button
Analyze: Analyze
Browse: Browse
Download: Download
Record: Record
Cancel: Cancel
Stop: Stop
About:
About: 關於
Website: 網站
Authors: 作者
Releases:
Releases: 發行版本
Loading: 讀取中...
NoUpdated: 目前沒有更新版本
67 changes: 67 additions & 0 deletions languages/zh-TW/yt-dlp-gui.lang
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
AppName: yt-dlp-gui (繁體中文)
Main:
# Basic
Url: 網址
Title: 標題
Desc: 註解
SaveAs: 另存為...
Thumbnail: 縮圖
About: 關於...
# Tab Formats
Formats: 格式
Video: 視頻
Audio: 音頻
Subtitle: 字幕
VideoRes: 解析度
VideoFPS: 幀率
VideoExt: 格式
VideoCodec: 編碼
VideoSize: 容量
AudioSampleRate: 採樣
AudioExt: 格式
AudioCodec: 編碼
AudioSize: 容量
# Tab Formats
Advance: 進階
EmbedSubs: 內嵌字幕
EmbedSubsEnabled: 啟用
TimeRange: 範圍
TimeRangeHits: --download-sections
TimeRangeHelper: "*10:15-15:00"
# Tab Options
Options: 選項
Notifications: 通知
NotificationsEnabled: 啟用
AlwaysOnTop: 保持在最上層
AlwaysOnTopEnabled: 啟用
RememberWindowState: 記憶視窗
RememberWindowPosition: 位置
RememberWindowSize: 尺寸
Cookie: Cookie
CookieWhenNeeded: 當需要時
CookieNever: 不使用
CookieAlways: 總是使用
CookieAsk: 詢問
CookieUse: 使用
Configuration: 設置檔
ConfigurationNone: "[不使用]"
Aria2: Aria2
Aria2Enabled: 啟用
# Label
Live: 直播
DownloadThumb: 下載縮圖
# button
Analyze: 分析
Browse: 瀏覽
Download: 下載
Record: 錄製
Cancel: 取消
Stop: 停止
About:
About: 關於
Website: 網站
Authors: 作者
Releases:
Releases: 發行版本
Loading: 讀取中...
NoUpdated: 目前沒有更新版本
9 changes: 7 additions & 2 deletions yt-dlp-gui/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
using System.Linq;
using Libs.Yaml;
using System.Linq;
using System.Windows;
using yt_dlp_gui.Models;

namespace yt_dlp_gui {
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application {
public static string CurrentVersion = "2022.11.04";
public static string CurrentVersion = "2022.11.14";
public static Lang Lang { get; set; } = new();
private void Application_Startup(object sender, StartupEventArgs e) {
var args = e.Args.ToList();
LoadPath();

var langPath = App.Path(App.Folders.root, App.AppName + ".lang");
Lang = Yaml.Open<Lang>(langPath);
new Views.Main().Show();
}
}
Expand Down
20 changes: 18 additions & 2 deletions yt-dlp-gui/Libs/Yaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System.Diagnostics;
using ICSharpCode.AvalonEdit.Highlighting.Xshd;
using ICSharpCode.AvalonEdit.Highlighting;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using YamlDotNet.Core;
using YamlDotNet.Serialization;

Expand All @@ -17,7 +21,19 @@ public static class Yaml {
return deserializer.Deserialize<T>(yaml);
}
} catch (YamlException e) {
//Debug.WriteLine(e.Message);
Debug.WriteLine(e.Message);
}
}
return new T();
}
public static T OpenFromResouce<T>(string path) where T : new() {
if (!Util.ResourceExists(path)) return new T();
using (Stream s = System.Windows.Application.GetResourceStream(new Uri(path, UriKind.Relative)).Stream) {
using (TextReader reader = new StreamReader(s)) {
var deserializer = new DeserializerBuilder()
.IgnoreUnmatchedProperties()
.Build();
return deserializer.Deserialize<T>(reader);
}
}
return new T();
Expand Down
86 changes: 86 additions & 0 deletions yt-dlp-gui/Models/Lang.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System.ComponentModel;

namespace yt_dlp_gui.Models {
public class Lang :INotifyPropertyChanged {
public event PropertyChangedEventHandler? PropertyChanged;
public string AppName { get; set; } = "yt-dlp-gui";
public LangMain Main { get; set; } = new();
public LangAbout About { get; set; } = new();
public LangReleases Releases { get; set; } = new();
}
public class LangMain :INotifyPropertyChanged {
public event PropertyChangedEventHandler? PropertyChanged;
//Basic
public string Url { get; set; } = "Url";
public string Title { get; set; } = "Title";
public string Desc { get; set; } = "Description";
public string SaveAs { get; set; } = "Save As...";
public string Thumbnail { get; set; } = "Thumbnail";
//Menu
public string About { get; set; } = "About...";
//Tab Format
public string Formats { get; set; } = "Formats";
public string Video { get; set; } = "Video";
public string Audio { get; set; } = "Audio";
public string Subtitle { get; set; } = "Subtitle";
public string VideoRes { get; set; } = "Resolution";
public string VideoFPS { get; set; } = "FPS";
public string VideoExt { get; set; } = "Ext.";
public string VideoCodec { get; set; } = "Codec";
public string VideoSize { get; set; } = "FileSize";
public string AudioSampleRate { get; set; } = "ASR";
public string AudioExt { get; set; } = "Ext.";
public string AudioCodec { get; set; } = "Codec";
public string AudioSize { get; set; } = "FileSize";
//Tab Advance
public string Advance { get; set; } = "Advance";
public string EmbedSubs { get; set; } = "Embed Subtitles";
public string EmbedSubsEnabled { get; set; } = "Enabled";
public string TimeRange { get; set; } = "Time Range";
public string TimeRangeHits { get; set; } = "--download-sections";
public string TimeRangeHelper { get; set; } = "*10:15-15:00";
//Tab Options
public string Options { get; set; } = "Options";
public string Notifications { get; set; } = "Notifications";
public string NotificationsEnabled { get; set; } = "Enabled";
public string AlwaysOnTop { get; set; } = "Always On Top";
public string AlwaysOnTopEnabled { get; set; } = "Enabled";
public string RememberWindowState { get; set; } = "Remember Window State";
public string RememberWindowPosition { get; set; } = "Position";
public string RememberWindowSize { get; set; } = "Size";
public string Cookie { get; set; } = "Cookie";
public string CookieWhenNeeded { get; set; } = "When Needed";
public string CookieNever { get; set; } = "Never";
public string CookieAlways { get; set; } = "Always";
public string CookieAsk { get; set; } = "Ask";
public string CookieUse { get; set; } = "Use";
public string Configuration { get; set; } = "Configuration";
public string ConfigurationNone { get; set; } = "[None]";
public string Aria2 { get; set; } = "Aria2";
public string Aria2Enabled { get; set; } = "Enabled";
//Label
public string Live { get; set; } = "LIVE";
//checkbox
public string DownloadThumb { get; set; } = "Download Thumbnail";
//button
public string Analyze { get; set; } = "Analyze";
public string Browse { get; set; } = "Browse";
public string Download { get; set; } = "Download";
public string Record { get; set; } = "Record";
public string Cancel { get; set; } = "Cancel";
public string Stop { get; set; } = "Stop";

}
public class LangAbout :INotifyPropertyChanged {
public event PropertyChangedEventHandler? PropertyChanged;
public string About { get; set; } = "About";
public string Website { get; set; } = "Website";
public string Authors { get; set; } = "Authors";
}
public class LangReleases :INotifyPropertyChanged {
public event PropertyChangedEventHandler? PropertyChanged;
public string Releases { get; set; } = "Releases";
public string Loading { get; set; } = "Loading...";
public string NoUpdated { get; set; } = "There is currently no updated version.";
}
}
19 changes: 10 additions & 9 deletions yt-dlp-gui/Themes/CustomUI.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<ResourceDictionary x:Class="yt_dlp_gui.Themes.CustomUI"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:app="clr-namespace:yt_dlp_gui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2" xmlns:controls="clr-namespace:yt_dlp_gui.Controls">
<!-- -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ -->
Expand Down Expand Up @@ -89,11 +90,11 @@
<ColumnDefinition Width="Auto" SharedSizeGroup="S4"/>
<ColumnDefinition Width="Auto" SharedSizeGroup="S5"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="Resolution"/>
<TextBlock Grid.Column="2" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="FPS"/>
<TextBlock Grid.Column="3" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="Ext."/>
<TextBlock Grid.Column="4" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="Codec"/>
<TextBlock Grid.Column="5" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="FileSize"/>
<TextBlock Grid.Column="1" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="{Binding Source={x:Static app:App.Lang}, Path=Main.VideoRes}"/>
<TextBlock Grid.Column="2" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="{Binding Source={x:Static app:App.Lang}, Path=Main.VideoFPS}"/>
<TextBlock Grid.Column="3" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="{Binding Source={x:Static app:App.Lang}, Path=Main.VideoExt}"/>
<TextBlock Grid.Column="4" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="{Binding Source={x:Static app:App.Lang}, Path=Main.VideoCodec}"/>
<TextBlock Grid.Column="5" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="{Binding Source={x:Static app:App.Lang}, Path=Main.VideoSize}"/>
</Grid>
<Separator Grid.Row="1" Height="2"/>
<ScrollViewer Grid.Row="2" x:Name="DropDownScrollViewer">
Expand Down Expand Up @@ -181,10 +182,10 @@
<ColumnDefinition Width="Auto" SharedSizeGroup="S4"/>
<ColumnDefinition Width="Auto" SharedSizeGroup="S5"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="ASR"/>
<TextBlock Grid.Column="3" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="Ext."/>
<TextBlock Grid.Column="4" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="Codec"/>
<TextBlock Grid.Column="5" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="FileSize"/>
<TextBlock Grid.Column="1" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="{Binding Source={x:Static app:App.Lang}, Path=Main.AudioSampleRate}"/>
<TextBlock Grid.Column="3" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="{Binding Source={x:Static app:App.Lang}, Path=Main.AudioExt}"/>
<TextBlock Grid.Column="4" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="{Binding Source={x:Static app:App.Lang}, Path=Main.AudioCodec}"/>
<TextBlock Grid.Column="5" FontSize="10" FontWeight="Bold" HorizontalAlignment="Center" Text="{Binding Source={x:Static app:App.Lang}, Path=Main.AudioSize}"/>
</Grid>
<Separator Grid.Row="1" Height="2"/>
<ScrollViewer Grid.Row="2" x:Name="DropDownScrollViewer">
Expand Down
7 changes: 5 additions & 2 deletions yt-dlp-gui/ViewModels/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public class ViewData :INotifyPropertyChanged {
}
}
}
public Lang Lang { get; set; } = new();
public Video? Video { get; set; } = new();
public ConcurrentObservableCollection<Config> Configs { get; set; } = new();
public IEnumerable<Config> ConfigsView => Configs.CollectionView;
Expand Down Expand Up @@ -285,9 +286,11 @@ public class ViewData :INotifyPropertyChanged {
}
}
if (Video.is_live == true) {
ExecText = IsDownload ? "Stop" : "Record";
//ExecText = IsDownload ? "Stop" : "Record";
ExecText = IsDownload ? App.Lang.Main.Stop : App.Lang.Main.Record;
} else {
ExecText = IsDownload ? "Cancel" : "Download";
//ExecText = IsDownload ? "Cancel" : "Download";
ExecText = IsDownload ? App.Lang.Main.Cancel : App.Lang.Main.Download;
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions yt-dlp-gui/Views/About.xaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Window x:Class="yt_dlp_gui.Views.About"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:app="clr-namespace:yt_dlp_gui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Controls="clr-namespace:yt_dlp_gui.Controls"
mc:Ignorable="d" Style="{DynamicResource DialogStyle}"
WindowStartupLocation="CenterOwner"
ShowInTaskbar="False"
Title="About" Height="150" Width="420">
Title="{Binding Source={x:Static app:App.Lang}, Path=About.About}" Height="150" Width="420">
<Window.Resources>
<ControlTemplate TargetType="ContentControl" x:Key="WindowLogo">
<Controls:Icons Kind="Information" Size="16"/>
Expand Down Expand Up @@ -45,10 +46,12 @@
<TextBlock x:Name="version" FontSize="12" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
<Separator Grid.Row="1" Margin="0,8,0,4"/>
<TextBlock Grid.Row="2" Grid.Column="1" LineHeight="20">
<Run Foreground="Gray" Text="Website :"/>
<Run Foreground="Gray" Text="{Binding Source={x:Static app:App.Lang}, Path=About.Website}"/>
<Run Foreground="Gray" Text=" :"/>
<Hyperlink NavigateUri="https://github.com/Kannagi0303/yt-dlp-gui" Click="Hyperlink_Click">https://github.com/Kannagi0303/yt-dlp-gui</Hyperlink>
<LineBreak/>
<Run Foreground="Gray" Text="Authors :"/>
<Run Foreground="Gray" Text="{Binding Source={x:Static app:App.Lang}, Path=About.Authors}"/>
<Run Foreground="Gray" Text=" :"/>
カンナギ Kannagi
</TextBlock>
</Grid>
Expand Down

0 comments on commit 3735467

Please sign in to comment.