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
-1
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\IWeakCultureObserver.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\Translation.cs
D:\Projects\CS\mpv.net\src\NGettext.Wpf\Common\GettextStringFormatConverter.cs
+624 -621
View File
File diff suppressed because it is too large Load Diff
+627 -620
View File
File diff suppressed because it is too large Load Diff
+582 -584
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -1 +0,0 @@
-36
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 }
-73
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", ""))
}
}