c# - How to localize text in WPF XAML without embedding the resource file -


i trying localize wpf application support different languages using resource files. have set build action resource files "resource". managed localize strings .cs file using resgen, resourcemanager , getstring() method not able using binding xaml file. tried resx extension , static resources in xaml file none of them seem work. not want build action resource files embedded resources has compiled again. please suggest me how localize text xaml build action set "resource" resource files or me other approach resources not embedded application. in advance!!

<window x:class="myapplication.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         title="mainwindow" height="350" width="525">     <grid>         <button name="btn1" height="50" width="150" content="{binding source={staticresource localizedstrings}, path=myresource.world}" />         <button name="btn2" height="50" width="150" horizontalalignment="left" verticalalignment="top" />     </grid> </window> 

the code behind is:

namespace myapplication {     public partial class mainwindow : window     {         public mainwindow()         {             string strresourcespath = "c:\\program files\\myapplication\\myapplication";             initializecomponent();             culturemanager.uiculture = new cultureinfo("fr-fr");             //resourcemanager resourcemgr = resourcemanager.createfilebasedresourcemanager("newresource", strresourcespath, null);             resourcemanager resourcemgr = resourcemanager.createfilebasedresourcemanager("myresource", strresourcespath, null);             string msg = resourcemgr.getstring("hello");             btn2.content = msg;         }     } } 

localizedstring.cs:

namespace myapplication {     class localizedstrings     {         public localizedstrings()         {         }         private static myapplication.myresource myresource = new myapplication.myresource();         public myapplication.myresource myresource { { return myresource; } }     } } 

app.xaml:

<application x:class="myapplication.app"              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              xmlns:local="clr-namespace:myapplication"              startupuri="mainwindow.xaml">     <application.resources>          <local:localizedstrings xmlns:local ="clr-namespace:myapplication" x:key="localizedstrings"/>     </application.resources> </application> 


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -