├── .gitignore ├── Documentation └── Images │ ├── WPF Globalization Example English.png │ ├── WPF Globalization Example Hebrew.png │ ├── WPF Globalization Example Spanish.png │ ├── WPFSharp.Globalizer.pdn │ └── WPFSharp.Globalizer.png ├── License.txt ├── README.md ├── appveyor.yml └── src ├── Examples ├── WPF.Globalizer.Example │ ├── App.xaml │ ├── App.xaml.cs │ ├── Globalization │ │ ├── en-US │ │ │ ├── en-US-style.xaml │ │ │ └── en-US.xaml │ │ ├── es-ES │ │ │ ├── es-ES-style.xaml │ │ │ └── es-ES.xaml │ │ └── he-IL │ │ │ ├── he-IL-style.xaml │ │ │ └── he-IL.xaml │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── DesignTimeResources.xaml │ ├── Styles │ │ ├── Default Style.xaml │ │ └── Red.xaml │ ├── WPF.Globalizer.Example.csproj.DotSettings │ ├── WPFSharp.Globalizer.Example.csproj │ └── app.config └── WPFSharp.Globalizer.MVVMExample │ ├── App.xaml │ ├── App.xaml.cs │ ├── Graphics │ └── Icons.xaml │ ├── MVVM │ ├── RelayCommand.cs │ └── ViewModelBase.cs │ ├── Model │ ├── Person.cs │ └── RelationType.cs │ ├── Properties │ ├── AssemblyInfo.cs │ └── DesignTimeResources.xaml │ ├── README.txt │ ├── Styles │ └── Red.xaml │ ├── View │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── PersonView.xaml │ └── PersonView.xaml.cs │ ├── ViewModel │ ├── MainWindowViewModel.cs │ └── PersonViewModel.cs │ └── WPFSharp.Globalizer.MVVMExample.csproj ├── WPFSharp.Globalizer.sln └── WPFSharp.Globalizer ├── AvailableLanguages.cs ├── AvailableStyles.cs ├── Controls ├── LanguageSelectionComboBox.cs ├── LanguageSelectionMenuItemList.cs ├── LanguageSelectionStyle.xaml ├── RelayCommand.cs └── StyleSelectionMenuItemList.cs ├── Converters ├── LanguageNameConverter.cs ├── LocalizationConverter.cs └── MultiValueStringsMatchConverter.cs ├── EnhancedResourceDictionary.cs ├── FallBackResourceDictionary.cs ├── GlobalizationManager.cs ├── GlobalizationResourceDictionary.cs ├── GlobalizedApplication.cs ├── GlobalizedResourceExtension.cs ├── IManageResourceDictionaries.cs ├── LocalizationBinding.cs ├── Properties └── AssemblyInfo.cs ├── ResourceDictionaryChangedEvent.cs ├── ResourceDictionaryManagerBase.cs ├── StyleManager.cs ├── StyleResourceDictionary.cs ├── WPFSharp.Globalizer.Key.snk └── WPFSharp.Globalizer.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | # ASP.NET 5 42 | project.lock.json 43 | artifacts/ 44 | 45 | *_i.c 46 | *_p.c 47 | *_i.h 48 | *.ilk 49 | *.meta 50 | *.obj 51 | *.pch 52 | *.pdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *.log 63 | *.vspscc 64 | *.vssscc 65 | .builds 66 | *.pidb 67 | *.svclog 68 | *.scc 69 | 70 | # Chutzpah Test files 71 | _Chutzpah* 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opensdf 78 | *.sdf 79 | *.cachefile 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | *.vspx 85 | 86 | # TFS 2012 Local Workspace 87 | $tf/ 88 | 89 | # Guidance Automation Toolkit 90 | *.gpState 91 | 92 | # ReSharper is a .NET coding add-in 93 | _ReSharper*/ 94 | *.[Rr]e[Ss]harper 95 | *.DotSettings.user 96 | 97 | # JustCode is a .NET coding addin-in 98 | .JustCode 99 | 100 | # TeamCity is a build add-in 101 | _TeamCity* 102 | 103 | # DotCover is a Code Coverage Tool 104 | *.dotCover 105 | 106 | # NCrunch 107 | _NCrunch_* 108 | .*crunch*.local.xml 109 | 110 | # MightyMoose 111 | *.mm.* 112 | AutoTest.Net/ 113 | 114 | # Web workbench (sass) 115 | .sass-cache/ 116 | 117 | # Installshield output folder 118 | [Ee]xpress/ 119 | 120 | # DocProject is a documentation generator add-in 121 | DocProject/buildhelp/ 122 | DocProject/Help/*.HxT 123 | DocProject/Help/*.HxC 124 | DocProject/Help/*.hhc 125 | DocProject/Help/*.hhk 126 | DocProject/Help/*.hhp 127 | DocProject/Help/Html2 128 | DocProject/Help/html 129 | 130 | # Click-Once directory 131 | publish/ 132 | 133 | # Publish Web Output 134 | *.[Pp]ublish.xml 135 | *.azurePubxml 136 | # TODO: Comment the next line if you want to checkin your web deploy settings 137 | # but database connection strings (with potential passwords) will be unencrypted 138 | *.pubxml 139 | *.publishproj 140 | 141 | # NuGet Packages 142 | *.nupkg 143 | # The packages folder can be ignored because of Package Restore 144 | **/packages/* 145 | # except build/, which is used as an MSBuild target. 146 | !**/packages/build/ 147 | # Uncomment if necessary however generally it will be regenerated when needed 148 | #!**/packages/repositories.config 149 | 150 | # Windows Azure Build Output 151 | csx/ 152 | *.build.csdef 153 | 154 | # Windows Store app package directory 155 | AppPackages/ 156 | 157 | # Others 158 | *.[Cc]ache 159 | ClientBin/ 160 | [Ss]tyle[Cc]op.* 161 | ~$* 162 | *~ 163 | *.dbmdl 164 | *.dbproj.schemaview 165 | *.pfx 166 | *.publishsettings 167 | node_modules/ 168 | bower_components/ 169 | 170 | # RIA/Silverlight projects 171 | Generated_Code/ 172 | 173 | # Backup & report files from converting an old project file 174 | # to a newer Visual Studio version. Backup files are not needed, 175 | # because we have git ;-) 176 | _UpgradeReport_Files/ 177 | Backup*/ 178 | UpgradeLog*.XML 179 | UpgradeLog*.htm 180 | 181 | # SQL Server files 182 | *.mdf 183 | *.ldf 184 | 185 | # Business Intelligence projects 186 | *.rdl.data 187 | *.bim.layout 188 | *.bim_*.settings 189 | 190 | # Microsoft Fakes 191 | FakesAssemblies/ 192 | 193 | # Node.js Tools for Visual Studio 194 | .ntvs_analysis.dat 195 | 196 | # Visual Studio 6 build log 197 | *.plg 198 | 199 | # Visual Studio 6 workspace options file 200 | *.opt 201 | 202 | *.nupkg 203 | *.bak 204 | /Examples/WPFSharp.Globalizer.MVVMExample/WPFSharp.Globalizer.MVVMExample.csproj.DotSettings 205 | -------------------------------------------------------------------------------- /Documentation/Images/WPF Globalization Example English.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhyous/WPFSharp.Globalizer/c1a246c2843272b691a276b2c4b0d7bf9dd7031b/Documentation/Images/WPF Globalization Example English.png -------------------------------------------------------------------------------- /Documentation/Images/WPF Globalization Example Hebrew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhyous/WPFSharp.Globalizer/c1a246c2843272b691a276b2c4b0d7bf9dd7031b/Documentation/Images/WPF Globalization Example Hebrew.png -------------------------------------------------------------------------------- /Documentation/Images/WPF Globalization Example Spanish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhyous/WPFSharp.Globalizer/c1a246c2843272b691a276b2c4b0d7bf9dd7031b/Documentation/Images/WPF Globalization Example Spanish.png -------------------------------------------------------------------------------- /Documentation/Images/WPFSharp.Globalizer.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhyous/WPFSharp.Globalizer/c1a246c2843272b691a276b2c4b0d7bf9dd7031b/Documentation/Images/WPFSharp.Globalizer.pdn -------------------------------------------------------------------------------- /Documentation/Images/WPFSharp.Globalizer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhyous/WPFSharp.Globalizer/c1a246c2843272b691a276b2c4b0d7bf9dd7031b/Documentation/Images/WPFSharp.Globalizer.png -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | WPFSharp.Globalizer - A project deisgned to make localization and styling 2 | easier by decoupling both process from the build. 3 | 4 | Copyright (c) 2015, Jared Barneck (Rhyous) 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 3. Use of the source code or binaries that in any way competes with WPFSharp.Globalizer 16 | or competes with distribution, whether open source or commercial, is 17 | prohibited unless permission is specifically granted under a separate 18 | license by Jared Barneck (Rhyous). 19 | 4. Forking for personal or internal, or non-competing commercial use is allowed. 20 | Distributing compiled releases as part of your non-competing project is 21 | allowed. 22 | 5. Public copies, or forks, of source is allowed, but from such, public 23 | distribution of compiled releases is forbidden. 24 | 6. Source code enhancements or additions are the property of the author until 25 | the source code is contributed to this project. By contributing the source 26 | code to this project, the author immediately grants all rights to the 27 | contributed source code to Jared Barneck (Rhyous). 28 | 29 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 30 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 31 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 32 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 33 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 34 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 35 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 36 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 38 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## WPFSharp.Globalizer ## 2 | 3 | A tool to simplify localization for WPF. 4 | 5 | You should use this project if: 6 | * Want to runtime language switching? 7 | * Want to be able to change the style at runtime? 8 | * Want to have localization decoupled from build? 9 | * Want to give users or customers the power to add a language themselves if their language is missing? 10 | * Want to localize WPF without having to put UIDs on every single WPF Element? 11 | * Want the style to change with the language? (or even only certain parts of the style) 12 | 13 | ## How to install ## 14 | 15 | 1. In a WPF application, install from NuGet. 16 | 17 | ``` 18 | PM> install-package WPFSharp.Globalizer 19 | ``` 20 | 21 | NuGet installs the dll, some sample language files, an example Xaml page. 22 | 23 | 2. During the NuGet install, when prompted to overwirte your App.xaml and App.xaml.cs file, choose No if you have custom code in their. Choose Yes if you don't. 24 | 25 | If you choose yes, great. Done. 26 | If you choose no, then manually change App.xaml and App.xaml.cs to inherit GlobalizedApplication. 27 | 28 | ## How to Add a language ## 29 | 30 | A language implementation involves two files in the following folder structure: 31 | 32 | Path | Description 33 | ---- | ---- 34 | Globalization | Top level folder 35 | Globalization\ | Folder for the language using the five character language name 36 | Globalization\en-US\-style.xaml | Style changes associated with a language 37 | Globalization\en-US\.xaml | The language resource file 38 | 39 | In the example, there are three languages: 40 | 41 | Path | Description 42 | ---- | ---- 43 | Globalization | Top level folder 44 | Globalization\en-US | Five character language name for english 45 | Globalization\en-US\en-US-style.xaml | Style changes associated with a language 46 | Globalization\en-US\en-US.xaml | The language resource file 47 | Globalization\es-ES | Five character language name for spanish 48 | Globalization\es-ES\es-ES-style.xaml | 49 | Globalization\es-ES\es-ES.xaml | 50 | Globalization\he-IL | Five character language name for Hebrew 51 | Globalization\he-IL\he-IL-style.xaml | Notice that the flowdirection changes as Hebrew is left to right. 52 | Globalization\he-IL\he-IL.xaml | 53 | 54 | To add an additional language file, follow these steps. 55 | 56 | Easy way: 57 | 58 | 1. Copy one of the existing language folders. 59 | 2. Change the folder name to the 5 character ISO name. This means it is the two letter language code followed by a dash then the two letter country code. You can read RFC5646 (http://tools.ietf.org/html/rfc5646) if you want. 60 | 61 | Hard way: 62 | 63 | 1. Add a folder names using the 5 character ISO name as the to the Globalization folder. 64 | 2. Manually create the .xaml file. 65 | 3. Make the root of the Xaml file GlobalizationResourceDictionary. 66 | 4. The Name property must be the 5 character lang, same as the folder. 67 | 5. The LinkedStyle attribute is optional. IF you use it, you must be the name of style file minus the .xaml extension. 68 | 6. Add a few strings. The x:Key is the localization key. The inner text is what is displayed when the language is selected. 69 | 70 | ``` 71 | 79 | WPF Globalization Example (English) 80 | _File 81 | _Exit 82 | 83 | ``` 84 | 85 | 7. (Optional) Create a language style file. For this example, create en-us-style.xaml. Whatever you name it, it must be the same name as the LinkedStyle attribute in the .xaml file. 86 | 8. Make the root object StyleResourceDictionary. 87 | 9. Set the Name attribute. Notces the name is the same as the filename without the extension. 88 | 10. Add some styles. This file shouldn't be too big. It should only hold styles changes specific to a language. 89 | 90 | ``` 91 | 97 | LeftToRight 98 | RightToLeft 99 | 106 | 107 | ``` 108 | 109 | ## How to add a style ## 110 | 111 | Styles can also be applied at runtime. You can create any number of styles. Styles are not the same as Language styles. 112 | 113 | * Language Styles = Has styles changes specific to a language. For example, in Hebrew the FlowDirection changes to right to left. 114 | * Styles = The overall theme of the application. If you have a blue theme, the blue theme should remain in effect even if the language changes. 115 | 116 | Style folder structure is simple. There is a single file for a style. 117 | 118 | Styles\Default Style.xaml 119 | Styles\Red.xaml 120 | Styles\Blue.xaml 121 | 122 | To add an additional style, follow these steps: 123 | 124 | 1. Create a style file in the Styles folder. For this example, create DefaultStyle.xaml. 125 | 2. Make the root object StyleResourceDictionary. 126 | 3. Set the Name attribute. Notces the name is the same as the filename without the extension. 127 | 4. Add some styles. This file could get massive as unlike the language file, this could hold all styles. 128 | 129 | ``` 130 | 137 | LeftToRight 138 | RightToLeft 139 | 14 140 | 141 | 148 | 149 | 150 | ``` 151 | 152 | 153 | ## Design Time ## 154 | There is a DesignTimeResources.xaml file added by the NuGet package into the Properties directory. This is what allows Design Time to work. This is a standard Xaml feature. 155 | 156 | ``` 157 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | ``` 167 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.2.{build} 2 | image: Visual Studio 2019 3 | dotnet_csproj: 4 | patch: true 5 | file: '**\*.csproj' 6 | version: '{version}' 7 | version_prefix: '{version}' 8 | package_version: '{version}' 9 | assembly_version: '{version}' 10 | file_version: '{version}' 11 | informational_version: '{version}' 12 | before_build: 13 | - pwsh: nuget restore src/WPFSharp.Globalizer.sln 14 | configuration: 15 | Release 16 | build: 17 | project: src/WPFSharp.Globalizer.sln 18 | verbosity: minimal 19 | test: 20 | categories: 21 | except: 22 | - slow 23 | nuget: 24 | disable_publish_on_pr: true 25 | artifacts: 26 | - path: '**\*.nupkg' 27 | deploy: 28 | - provider: NuGet 29 | on: 30 | branch: master 31 | api_key: 32 | secure: hXdAkbkR+htASNv3WTjj2VOzqpIGLS0yj7JVUEsG3Ujzqpv353hiGCldpMH0WOLh 33 | -------------------------------------------------------------------------------- /src/Examples/WPF.Globalizer.Example/App.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Examples/WPF.Globalizer.Example/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace WPFSharp.Globalizer.Example 2 | { 3 | /// 4 | /// Interaction logic for App.xaml 5 | /// 6 | public partial class App : GlobalizedApplication 7 | { 8 | public App() 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Examples/WPF.Globalizer.Example/Globalization/en-US/en-US-style.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | LeftToRight 9 | RightToLeft 10 | 11 | 18 | 19 | -------------------------------------------------------------------------------- /src/Examples/WPF.Globalizer.Example/Globalization/en-US/en-US.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | WPF Globalization Example (English) 12 | 13 | 14 | _File 15 | _Exit 16 | _Language 17 | _English 18 | _Spanish 19 | _Hebrew 20 | 21 | _Language 22 | 23 | 24 | 25 | 26 | 27 | Last Name 28 | Age 29 | Clear 30 | 31 | -------------------------------------------------------------------------------- /src/Examples/WPF.Globalizer.Example/Globalization/es-ES/es-ES-style.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | LeftToRight 10 | RightToLeft 11 | 12 | 19 | 20 | -------------------------------------------------------------------------------- /src/Examples/WPF.Globalizer.Example/Globalization/es-ES/es-ES.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | WPF Globalization Example (Spanish) 12 | 13 | 14 | _Archivo 15 | _Salir 16 | _Idioma 17 | _Inglés 18 | _Español 19 | _Hebreo 20 | 21 | 22 | _Inglés (en-US) 23 | _Español (es-ES) 24 | _Hebreo (he-IL) 25 | 26 | _Idioma 27 | 28 | 29 | Nombre de pila 30 | Appellido 31 | Edad 32 | borrar 33 | 34 | -------------------------------------------------------------------------------- /src/Examples/WPF.Globalizer.Example/Globalization/he-IL/he-IL-style.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | RightToLeft 10 | LeftToRight 11 | 12 | 19 | -------------------------------------------------------------------------------- /src/Examples/WPF.Globalizer.Example/Globalization/he-IL/he-IL.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | WPF Globalization Example (Hebrew) 12 | 13 | 14 | קובץ 15 | קובץ 16 | _שפה 17 | (en-US) אנגלית 18 | (es-ES) ספרדית 19 | (he-IL) עברית 20 | 21 | 22 | (en-US) אנגלית 23 | (es-ES) ספרדית 24 | (he-IL) עברית 25 | 26 | 27 | _שפה 28 | 29 | 30 | שם פרטי 31 | שם משפחה 32 | גיל 33 | ברור 34 | -------------------------------------------------------------------------------- /src/Examples/WPF.Globalizer.Example/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 |