Support Chinese language

This commit is contained in:
stax76
2023-12-08 21:33:10 +01:00
parent 8d601525b5
commit f937273fe3
16 changed files with 1860 additions and 1966 deletions

View File

@@ -6,14 +6,12 @@
🎞 mpv.net 🎞 mpv.net
========== ==========
mpv.net is a media player for Windows based on the [mpv](https://mpv.io) player. mpv.net is a media player for Windows that has a modern GUI.
The player is based on the popular [mpv](https://mpv.io) media player.
mpv.net is designed to be mpv compatible, almost all mpv features are available, mpv.net is designed to be mpv compatible, almost all mpv features are available,
this means the official [mpv manual](https://mpv.io/manual/master/) applies to mpv.net. this means the official [mpv manual](https://mpv.io/manual/master/) applies to mpv.net,
differences are documented in the [mpv.net manual](docs/manual.md#differences-compared-to-mpv).
mpv focuses on the usage of the command line and the terminal,
mpv.net retains the ability to be used from the command line and
the terminal and adds a modern Windows GUI on top of it.
#### Graphical User Interface #### Graphical User Interface

View File

@@ -31,15 +31,12 @@ Table of contents
About About
----- -----
mpv.net is a modern desktop media player for Windows based on the popular mpv player. mpv.net is a media player for Windows that has a modern GUI.
mpv.net is designed to be mpv compatible, almost all mpv features are available The player is based on the popular [mpv](https://mpv.io) media player.
because they are all contained in libmpv, this means the official mpv.net is designed to be mpv compatible, almost all mpv features are available,
[mpv manual](https://mpv.io/manual/master/) applies to mpv.net. this means the official [mpv manual](https://mpv.io/manual/master/) applies to mpv.net,
differences are documented in this manual under [Differences compared to mpv](#differences-compared-to-mpv).
mpv focuses on the usage of the command line and the terminal,
mpv.net retains the ability to be used from the command line and
the terminal and adds a modern Windows GUI on top of it.
Download Download
@@ -565,8 +562,12 @@ In fullscreen mode clicking the top right corner closes the player.
Differences compared to mpv Differences compared to mpv
--------------------------- ---------------------------
mpv.net is designed to work exactly like mpv, there are a few limitations: mpv.net is designed to work exactly like mpv, there are a few
differences and limitations:
The settings folder is named `mpv.net` instead of `mpv`:
`C:\Users\username\AppData\Roaming\mpv.net`
### Window Limitations ### Window Limitations

View File

@@ -102,7 +102,6 @@ D:\Projects\CS\mpv.net\src\NGettext.Wpf\GettextExtension.cs
D:\Projects\CS\mpv.net\src\NGettext.Wpf\GettextFormatConverterExtension.cs D:\Projects\CS\mpv.net\src\NGettext.Wpf\GettextFormatConverterExtension.cs
D:\Projects\CS\mpv.net\src\NGettext.Wpf\IWeakCultureObserver.cs D:\Projects\CS\mpv.net\src\NGettext.Wpf\IWeakCultureObserver.cs
D:\Projects\CS\mpv.net\src\NGettext.Wpf\Localizer.cs D:\Projects\CS\mpv.net\src\NGettext.Wpf\Localizer.cs
D:\Projects\CS\mpv.net\src\NGettext.Wpf\NGettextWpfDependencyResolver.cs
D:\Projects\CS\mpv.net\src\NGettext.Wpf\TrackCurrentCultureBehavior.cs D:\Projects\CS\mpv.net\src\NGettext.Wpf\TrackCurrentCultureBehavior.cs
D:\Projects\CS\mpv.net\src\NGettext.Wpf\Translation.cs D:\Projects\CS\mpv.net\src\NGettext.Wpf\Translation.cs
D:\Projects\CS\mpv.net\src\NGettext.Wpf\Common\GettextStringFormatConverter.cs D:\Projects\CS\mpv.net\src\NGettext.Wpf\Common\GettextStringFormatConverter.cs

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@

View File

@@ -1,36 +0,0 @@
# # Extract msgids from xaml files in project into pot file.
# . $PSScriptRoot/XGetText-Xaml.ps1
# $xamlFiles = Get-ChildItem -Recurse -File -Filter *.xaml |
# Where { $_.FullName -NotLike '*\obj\*' } | ForEach-Object { $_.FullName }
# XGetText-Xaml -o obj/xamlmessages.pot -k Gettext,GettextFormatConverter $xamlFiles
# # Merge two pot files into one
# msgcat.exe --use-first -o obj/result.pot obj/source.pot obj/xamlmessages.pot
# $Header = @"
# # Translation of mpv.net to ???
# # Copyright (C) 2023 Frank Skare (stax76) <frank.skare.de@gmail.com>
# # Copyright (C) 2023 ???
# # This file is distributed under the same license as the mpv.net package.
# msgid ""
# msgstr ""
# "Project-Id-Version: mpv.net\n"
# "Report-Msgid-Bugs-To: Frank Skare (stax76) <frank.skare.de@gmail.com>\n"
# "POT-Creation-Date: 2023-11-04 16:50+0100\n"
# "PO-Revision-Date: 2023-11-04 16:54+0100\n"
# "Last-Translator: ???\n"
# "Language-Team: ???\n"
# "Language: ???\n"
# "MIME-Version: 1.0\n"
# "Content-Type: text/plain; charset=UTF-8\n"
# "Content-Transfer-Encoding: 8bit\n"
# "Plural-Forms: nplurals=2; plural=(n != 1);\n"
# "@
# $Locales = @('bg', 'ca', 'cs', 'de', 'es', 'eu', 'fr', 'it', 'ja', 'ko', 'lt', 'nl', 'pl', 'pt', 'pt_BR', 'ro', 'ru', 'sr_RS', 'sr_RS@latin', 'sv', 'tr', 'uk', 'zh_CN', 'zh_SG', 'zh_TW')
# $Locales | foreach { $Header -replace '"Language: \?\?\?\\n"', "`"Language: $($_)\n`"" |
# Out-File $PSScriptRoot\PO\$_.po }

View File

@@ -1,73 +0,0 @@
function XGetText-Xaml {
param(
[Parameter(Mandatory=$true,
Position=0,
ParameterSetName="sourceFiles",
HelpMessage="XAML files to extract msgids from.")]
[ValidateNotNullOrEmpty()]
[string[]]$sourceFiles,
[Parameter(Mandatory=$true,
HelpMessage="Additional keywords that match MarkupExtensions enclosing msgids to be extracted.")]
[Alias("k")]
[string[]]
$Keywords,
[Parameter(Mandatory=$false,
HelpMessage="Write output to specified file.")]
[Alias("o")]
[string]$output="messages.pot")
$extractedIds = New-Object -TypeName System.Collections.Hashtable
ForEach ($keyword in $Keywords)
{
ForEach ($sourceFile in $sourceFiles)
{
Select-String $sourceFile -Pattern $("{[a-z]?[a-z0-9]*:"+$keyword+ " (([^}{]|{[^}]*})*)}") -AllMatches | ForEach-Object {
$filename = $sourceFile
$lineNumber = $_.LineNumber
$_.Matches | ForEach-Object {
$msgid = $_.Groups[1].ToString()
if ($msgid.StartsWith("'") -and $msgid.EndsWith("'")){
$msgid = $msgid.Substring(1, $msgid.Length-2);
}
$msgid = $msgid.Replace("\'", "'")
$msgid = $msgid.Replace("\,", ",")
if (-Not $extractedIds.ContainsKey($msgid))
{
$extractedIds.Add($msgid, @{Locations = New-Object System.Collections.ArrayList})
}
[void] $extractedIds[$msgid].Locations.Add('#: ' + $Filename + ':' + $LineNumber)
}
}
}
}
$result = '#, fuzzy
msgid ""
msgstr ""
"POT-Creation-Date: ' + $(Get-Date -Format 'yyyy-mm-dd HH:mmK') + '\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n\n"' + [System.Environment]::NewLine + [System.Environment]::NewLine
$extractedIds.GetEnumerator() | ForEach-Object {
if ($_.Key -like '*|*' ) {
$msgid = $_.Key.Substring($_.Key.indexof("|") +1)
$msgctxt = $_.Key.Substring(0, $_.Key.indexof("|"))
$result = $result + $($_.Value.Locations -join [System.Environment]::NewLine) + [System.Environment]::NewLine + "msgctxt """ + $msgctxt + """" + [System.Environment]::NewLine + "msgid """ + $msgid + """" + [System.Environment]::NewLine + "msgstr """"" + [System.Environment]::NewLine + [System.Environment]::NewLine + [System.Environment]::NewLine
}
else {
$result = $result + $($_.Value.Locations -join [System.Environment]::NewLine) + [System.Environment]::NewLine + "msgid """ + $_.Key + """" + [System.Environment]::NewLine + "msgstr """"" + [System.Environment]::NewLine + [System.Environment]::NewLine + [System.Environment]::NewLine
}
}
if ($output -eq '-') {
Write-Output $result.ToString()
} else {
[System.IO.File]::WriteAllLines($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($output), ($result -replace "\r", ""))
}
}

View File

@@ -9,7 +9,7 @@ public class WpfTranslator : ITranslator
{ {
static Language[] Languages { get; } = new Language[] { static Language[] Languages { get; } = new Language[] {
new("english", "en", "en"), new("english", "en", "en"),
new("chinese-china", "zh-Hans", "zh"), // Chinese (Simplified) new("chinese-china", "zh-CN", "zh"), // Chinese (Simplified)
new("german", "de", "de"), new("german", "de", "de"),
}; };
@@ -44,7 +44,7 @@ public class WpfTranslator : ITranslator
if (lang.MpvNetName == name) if (lang.MpvNetName == name)
return new CultureInfo(lang.CultureInfoName); return new CultureInfo(lang.CultureInfoName);
throw new Exception($"Unknown language {name}."); return new CultureInfo("en");
} }
class Language class Language

View File

@@ -1,4 +1,4 @@
using System; 
using System.Globalization; using System.Globalization;
using System.Windows.Data; using System.Windows.Data;
@@ -10,7 +10,7 @@ namespace NGettext.Wpf.Common
public GettextStringFormatConverter(string msgId) public GettextStringFormatConverter(string msgId)
{ {
this.MsgId = msgId; MsgId = msgId;
} }
public static ILocalizer Localizer { get; set; } public static ILocalizer Localizer { get; set; }

View File

@@ -1,4 +1,4 @@
using System; 
using System.Globalization; using System.Globalization;
namespace NGettext.Wpf namespace NGettext.Wpf

View File

@@ -1,5 +1,4 @@
using System; 
using System.Linq;
using System.Reflection; using System.Reflection;
namespace NGettext.Wpf.EnumTranslation namespace NGettext.Wpf.EnumTranslation

View File

@@ -1,5 +1,4 @@
using System; 
namespace NGettext.Wpf.EnumTranslation namespace NGettext.Wpf.EnumTranslation
{ {
public class EnumMsgIdAttribute : Attribute public class EnumMsgIdAttribute : Attribute

View File

@@ -1,4 +1,4 @@
using System; 
using System.Globalization; using System.Globalization;
using System.Windows.Data; using System.Windows.Data;

View File

@@ -1,5 +1,5 @@
using System.Reflection; 
using System.Runtime.CompilerServices; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following