0
votes

I am refactoring an existing WinForms application into WPF and MVVM (little knowledge apart from theory in MVVM). The application needs to be fully localized. I am OK with this as far as the UI goes (store resources and bind to them based off enumerations and other structures).

The application must present a dynamically generated pdf to the user. Where should this localization information go:

  1. In the backend with the pdf creation logic

    Pro: easier logic flow

    Con: against MVVM theory, as backend is not supposed to know anything about how it is being displayed. Also less maintainable (2 places with localization data)

  2. Pass the objects to the view to translate. This will mean PDF generation code would need to come into the view.

    Pro: Only one spot to maintain localization

    Con: Also against MVVM theory, as view is not supposed to have logic in it

Neither solution really seems ideal to me. Any ideas?

2

2 Answers

1
votes

These details might help for Globalization and Localization (http://msdn.microsoft.com/en-us/library/ms753931.aspx)

and there is also a guidance on codeplex:WPF Localization Guidance (http://wpflocalization.codeplex.com/releases/view/29389)

0
votes

Your question is quite not understandable but practical solution to localization is :

1.Create project with .resx files (project name can be e.g. Localization)

2.Add namespace to your XAML file e.g.

xmlns:localPresentation="clr-namespace:Localization.Presentation;assembly=Localization"

3.Localize UI text in this way

Text="{x:Static localPresentation:PresentationResources.SomeResourceKey}"

This localization is not dynamic. When you change language of the application, you have to restart it. Dynamic localization is more tricky but everything is possible.