Skip to content

Commit

Permalink
Merge pull request #29 from NovaRaine/msgid-unicode-support
Browse files Browse the repository at this point in the history
Add support for UTF8

This resolves #20
  • Loading branch information
robert-j-engdahl authored Feb 19, 2019
2 parents 0451226 + 915e4e6 commit d40c7cf
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
Binary file modified NGettext.Wpf.Example/Locale/da-DK/LC_MESSAGES/Example.mo
Binary file not shown.
14 changes: 9 additions & 5 deletions NGettext.Wpf.Example/Locale/da-DK/LC_MESSAGES/Example.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-02-18 14:06+0100\n"
"PO-Revision-Date: 2019-02-18 14:18+0100\n"
"POT-Creation-Date: 2019-02-19 11:03+0100\n"
"PO-Revision-Date: 2019-02-19 11:25+0100\n"
"Last-Translator: Robert Jørgensgaard Engdahl <rje@accuratech.dk>\n"
"Language-Team: \n"
"Language: da_DK\n"
Expand Down Expand Up @@ -48,7 +48,7 @@ msgstr "Inhyllende apostroffer er valgfrie."
msgid "English"
msgstr "Engelsk"

#: MainWindow.xaml:68
#: MainWindow.xaml:69
msgctxt "Example"
msgid "GNOME glib syntax context example"
msgstr "GNOME glib syntaks-context-eksempel"
Expand All @@ -69,15 +69,15 @@ msgstr "Lokalformateret enum-combobox-eksempel:"
msgid "Localized number format example:"
msgstr "Lokalformateret tal-eksempel:"

#: MainWindow.xaml:73
#: MainWindow.xaml:74
msgid "Memory leak test progress:"
msgstr "Memory-leak-testfremgang:"

#: C:\git\ngettext-wpf\NGettext.Wpf.Example\MainWindow.xaml.cs:95
msgid "NGettext.WPF Example"
msgstr "NGettext.WPF-eksempel"

#: MainWindow.xaml:70
#: MainWindow.xaml:71
msgid "Run TrackCurrentCultureBehavior memory leak test"
msgstr "Udfør TrackCurrentCultureBehavior memory-leak-test"

Expand Down Expand Up @@ -112,6 +112,10 @@ msgstr "En værdi"
msgid "Unenclosed escaped single-quotes (') are supported."
msgstr "Ikke-inhyllende, escapede apostroffer (') er understøttet."

#: MainWindow.xaml:68
msgid "Unicode™ in msgIds is supported"
msgstr "Unicode™ i msgId'er er understøttet"

#: MainWindow.xaml:61
msgid "Varying cAsE ExamPle:"
msgstr "Eksempel På VaRiAtiOn i store og små bogstavEr:"
Expand Down
Binary file modified NGettext.Wpf.Example/Locale/de-DE/LC_MESSAGES/Example.mo
Binary file not shown.
14 changes: 9 additions & 5 deletions NGettext.Wpf.Example/Locale/de-DE/LC_MESSAGES/Example.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-02-18 14:06+0100\n"
"PO-Revision-Date: 2019-02-18 14:20+0100\n"
"POT-Creation-Date: 2019-02-19 11:03+0100\n"
"PO-Revision-Date: 2019-02-19 11:28+0100\n"
"Last-Translator: Robert Jørgensgaard Engdahl <rje@accuratech.dk>\n"
"Language-Team: \n"
"Language: de_DE\n"
Expand Down Expand Up @@ -48,7 +48,7 @@ msgstr "Einschließende einfache Anführungszeichen (Apostrophe) sind optional."
msgid "English"
msgstr "Englisch"

#: MainWindow.xaml:68
#: MainWindow.xaml:69
msgctxt "Example"
msgid "GNOME glib syntax context example"
msgstr "GNOME glib-Syntaxkontextbeispiel"
Expand All @@ -69,15 +69,15 @@ msgstr "Lokalisierte Enum-Combobox-Beispiel:"
msgid "Localized number format example:"
msgstr "Lokales Zahlenformatbeispiel:"

#: MainWindow.xaml:73
#: MainWindow.xaml:74
msgid "Memory leak test progress:"
msgstr "Speicherlecktestfortschritt:"

#: C:\git\ngettext-wpf\NGettext.Wpf.Example\MainWindow.xaml.cs:95
msgid "NGettext.WPF Example"
msgstr "NGettext.WPF-Beispiel"

#: MainWindow.xaml:70
#: MainWindow.xaml:71
msgid "Run TrackCurrentCultureBehavior memory leak test"
msgstr "Den TrackCurrentCultureBehavior-Speicherlecktest ausführen"

Expand Down Expand Up @@ -112,6 +112,10 @@ msgstr "Ein gewisser Wert"
msgid "Unenclosed escaped single-quotes (') are supported."
msgstr "Unclosed maskierte einfache Anführungszeichen (') werden unterstützt."

#: MainWindow.xaml:68
msgid "Unicode™ in msgIds is supported"
msgstr "Unicode™ in msgIds wird unterstützt"

#: MainWindow.xaml:61
msgid "Varying cAsE ExamPle:"
msgstr "Beispiel von Variation zwiScHen Groß- und KleInBUchstaBen:"
Expand Down
3 changes: 2 additions & 1 deletion NGettext.Wpf.Example/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
xmlns:system="clr-namespace:System;assembly=mscorlib"
SizeToContent="Height"
Title="{Binding ElementName=Window, Path=Header}"
mc:Ignorable="d" Width="525" x:Name="Window">
mc:Ignorable="d" Width="525" x:Name="Window">
<Window.Resources>
<!-- The following ensures all enum values are translated when displayed -->
<enumTranslation:LocalizeEnumConverter x:Key="LocalizeEnumConverter" />
Expand Down Expand Up @@ -65,6 +65,7 @@
<!--<TextBlock Text="{wpf:Gettext 'Enclosing single-quotes (\') are optional'}" HorizontalAlignment="Center" />-->
<TextBlock Text="{wpf:Gettext 'Enclosing single-quotes (apostrophes) are optional.'}" HorizontalAlignment="Center" />
<TextBlock Text="{wpf:Gettext Unenclosed escaped single-quotes (\') are supported.}" HorizontalAlignment="Center" />
<TextBlock Text="{wpf:Gettext Unicode™ in msgIds is supported}" HorizontalAlignment="Center" />
<TextBlock Text="{wpf:Gettext Example|GNOME glib syntax context example}" HorizontalAlignment="Center"/>
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="40">
<Button Content="{wpf:Gettext Run TrackCurrentCultureBehavior memory leak test}" Width="340"
Expand Down
18 changes: 14 additions & 4 deletions XGetText.Xaml/XGetText-Xaml.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"

Describe "XGetText-Xaml" {
Set-Content -Path TestDrive:\TestFile.xaml -Value '<Window x:Class="NGettext.Wpf.Example.MainWindow"
Set-Content -Path TestDrive:\TestFile.xaml -Encoding 'UTF8' -Value '<Window x:Class="NGettext.Wpf.Example.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand Down Expand Up @@ -33,8 +33,9 @@ Describe "XGetText-Xaml" {
<TextBlock Text="{wpf:Gettext Quotes are optional}"/>
<TextBlock Text="{wpf:Gettext ''Quotes are optional''}"/>
<TextBlock Text="{wpf:Gettext Escaped single-quotes (\'') are supported.}"/>
<TextBlock Text="{wpf:Gettext Unicode™ in msgIds is supported.}" />
<TextBlock Text="{wpf:Gettext Sequential ordering|Order}" />
<TextBlock Text="{wpf:Gettext Placing an order|Order}" />
<TextBlock Text="{wpf:Gettext Placing an order|Order}" />
</StackPanel>
</Grid>
</Window>'
Expand All @@ -57,13 +58,13 @@ Describe "XGetText-Xaml" {
}

It "Does not ignore casing of msgids when joining" {
XGetText-Xaml TestDrive:\TestFile.xaml -k Gettext -o TestDrive:\Output.pot
XGetText-Xaml TestDrive:\TestFile.xaml -k Gettext -o $TestDrive\Output.pot
"TestDrive:\Output.pot" | Should -FileContentMatchExactly "^msgid ""German""$"
"TestDrive:\Output.pot" | Should -FileContentMatchExactly "^msgid ""german""$"
}

It "Writes output to specified file" {
XGetText-Xaml TestDrive:\TestFile.xaml -k Gettext -o TestDrive:\Output.pot
XGetText-Xaml TestDrive:\TestFile.xaml -k Gettext -o $TestDrive\Output.pot
'TestDrive:\Output.pot' | Should -FileContentMatchMultiline '#, fuzzy\nmsgid ""\nmsgstr ""'
}

Expand All @@ -75,4 +76,13 @@ Describe "XGetText-Xaml" {
XGetText-Xaml TestDrive:\TestFile.xaml -k Gettext -o - | Should -Match ([regex]::Escape("msgid ""Escaped single-quotes (') are supported."""))
}

It "Supports unicode in msgIds when writing to stdout" {
XGetText-Xaml TestDrive:\TestFile.xaml -k Gettext -o - | Should -Match ([regex]::Escape("msgid ""Unicode™ in msgIds is supported."""))
}

It "Supports unicode in msgIds when writing to .pot" {
XGetText-Xaml TestDrive:\TestFile.xaml -k Gettext -o $TestDrive\Output.pot
'TestDrive:\Output.pot' | Should -FileContentMatchExactly "msgid ""Unicode™ in msgIds is supported."""
}

}
2 changes: 1 addition & 1 deletion XGetText.Xaml/XGetText-Xaml.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ msgstr ""
Write-Output $result.ToString()
}
else {
$result -replace "\r", "" | Out-File -Encoding 'ascii' -NoNewline $output
[System.IO.File]::WriteAllLines($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($output), ($result -replace "\r", ""))
}

}

0 comments on commit d40c7cf

Please sign in to comment.