locked
Using Mutilingual App Toolkit: MultilingualApp could not be found RRS feed

  • Question

  • Hello everyone. I try to use MAT for a WPF application. I am using VS community 2013 Update 4 with MAT 4.

    I have read this article:

    http://blogs.msdn.com/b/synergist/archive/2015/03/05/using-the-multilingual-app-toolkit-with-wpf-applications.aspx

    and  made the steps 1 to 8.

    When I build, my problems are:

    Error    1    The type or namespace name 'MultilingualApp' could not be found (are you missing a using directive or an assembly reference?)    C:\ELA\DevC#\test\test\obj\Debug\MainWindow.g.cs

    And:

    Error    2    The name "Resources" does not exist in the namespace "clr-namespace:MultilingualApp.Properties".    C:\ELA\DevC#\test\test\MainWindow.xaml    7    17    test

    Please, Is anyone know what's wrong ? I 'm blocked, and I have no idea to continue...

    Wednesday, October 21, 2015 7:59 AM

All replies

  • EddyAtPessac,

    I was able to get a repro in my environment.  The issue you are seeing appears to be related to the namespace on step 7 of the directions.  Check to ensure that "xmlns:properties="clr-namespace:MultilingualApp.Properties" aligns with your app's name.  My repro required that I added a typo to get the same messages that you reported.  Ensuring the namespace is correct should solve the issue you are seeing.

    Thanks,

    Cameron

    Friday, October 23, 2015 9:26 PM
  • Hi Chris, thanks for you reply.

    I have read and re-read my Xaml file and I haven't find any error. I copied and pasted the text, rebuilt, and the error still staying.

    I tried to copy your text but the result is the same.

    Is this a reference to add for the multilanguages projects ? I don't find this indication.
    If you have the same project that is operational, please could you give me this sample project ? I spend a lot of time to try set up the same project as it is described  !

    Eddy

    Monday, October 26, 2015 11:21 AM
  • Hi Chris, thanks for you reply. I had a problem to log in MSDN.

    It is ok now. I had not understood the need to replace "MultilingualApp" by my app's name.

    I did it, and it is running.

    Thanks,

    EddyAtPessac.

    Wednesday, October 28, 2015 2:27 PM
  • Glad to hear that. Thanks for letting us know.

    BTW the actual answer came from Cameron ("alias Multilingual App Toolkit"), just to get the credit right.

    Thanks much for your use of MAT and Microsoft Translator.

    Chris Wendt
    Microsoft Translator

    Wednesday, October 28, 2015 4:41 PM
  • Ok for the answer. So thanks Cameron.

    I have my tools which are localised. Now, the next step, I need to manipulate string in the code. I read this article:
    http://stackoverflow.com/questions/20906153/multilingual-app-toolkit-for-windows-phone-8-in-code-c-sharp
    I created my "LocalisedString" class. But, I don't know where to place the key with "LocalisedString" in my xaml code.

    Indeed, I do not have a tag <Application>, but <Windows> and I can't declare the two in the same file.
    Where do I put this code in my xaml ? My xaml is this one:

    <Window x:Class="WpfMultiLang.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:LocStrings="clr-namespace:WpfMultiLang.Properties"
            xmlns:local="clr-namespace:WpfMultiLang"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
                <StackPanel>
                <TextBlock
                     Text="{x:Static LocStrings:Resources.TranslateMe}"/>
                <Button
                     Content="{x:Static LocStrings:Resources.PressMe}"/>
            </StackPanel>
            </Grid>
    </Window>

    And the example code to add is this one:

    <Application.Resources xmlns:my="clr-namespace:NameSpaceWhereLocalizedStrings">
        <my:LocalizedStrings x:Key="Localized"/>
    </Application.Resources>
    What should I do to declare my LocalisedStrings class in my  xaml ?

    Thursday, October 29, 2015 8:25 AM
  • Hi EddyAtPessac,

    I believe the issue you are seeing is the result of merging Windows Phone Silverlight resource model (as shown on the stackoverflow article) with WPF resource management.  While both are using XAML, the implementation is different.  I would recommend going with the WPF model for you WPF example as it is simpler to use then mapping to Windows Phone Silverlight model.  (This will remove the need to have the LocalisedStrings class and replace it with an auto generated class.)

    To help, I aligned my sample with your project's namespace.  Note: I used l10n for the localization namespace, but you can use any name that works for you.

    My WPF app's resources.resx file is in "Properties", which is the default location when the project is created.  If you open the auto generated file Resources.Designer.cs -which is a child of Resources.Resx- you will see that it's namespace is "WpfMultiLang.Properties".  This namespace has a class that matches the resx file name - in this case it is "Resources". Note: Be sure to open the Resources.Resx file and set the Access Modifier value to "Public".  If it is set to None, it will not create the related .cs file.

    This namespace is the key on how the WPF XAML connects to the Resources in the Resources.Resx file.  In the XAML code, just add a xml namespace (xmlns) to reference the resources in the .cs file by their namespace (WpfMultiLang.Properties).

      xmlns:l10n="clr-namespace:WpfMultiLang.Properties"

    In the XAML code, reference the xml namespace ("l10n"), class ("Resources") and property ("TranslateMe") like this:

      Text="{x:Static l10n:Resources.TranslateMe}"

    <Window x:Class="WpfMultiLang.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"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:l10n="clr-namespace:WpfMultiLang.Properties"
            mc:Ignorable="d"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <StackPanel>
                <TextBlock Text="{x:Static l10n:Resources.TranslateMe}"/>
                <Button x:Name="PressMeButton" Content="{x:Static l10n:Resources.PressMe}" Click="Button_Click"/>
            </StackPanel>
        </Grid>
    </Window>
    

    To access a resource in code-behind, reference the Resource by its namespace, class and property (the same basic steps as in XAML).

    ... using l10n = WpfMultiLang.Properties.Resources; ... private void Button_Click(object sender, RoutedEventArgs e) { // You could use the full namespace path, but I like to use aliases // PressMeButton.Content = WpfMultiLang.Properties.Resources.ThankYou;

    PressMeButton.Content = l10n.ThankYou; }


    I hope this helps.  If you are still having issue, I'll be happy to send you my example code.  Just email multilingual at Microsoft .com

    Thank you,

    Cameron

    Thursday, October 29, 2015 4:17 PM
  • It is so simple ! Effectively that's work!

    I could now writing my application.

    thank you a lot, Cameron

    EddyAtPessac.

    Friday, October 30, 2015 8:03 AM
  • Glad I could help. 

    Thank you,
    Cameron

    Friday, October 30, 2015 3:45 PM