Localization of Windows Desktop app - c#

I am starting a small project in C#/WPF writing a Windows desktop application. However, searching for information on how to localize the app seems a lot more challenging. Most of the information I find is very abstract and takes more about planning than actual code and how to do it.
Since I am writing a small application, I just need a very simple explained "how to" translate text, and good practices to consider.
Anyone have any experience that can share some resources or some pointers in the right direction?

I always recommend the WPF Localize extension: http://wpflocalizeextension.codeplex.com/
When using that you can do something like:
<Button Content="{lex:Loc Test}" />
and the Content of the button is pulled from the resources.
Once set up it is very easy to use and a good introduction to it can be found HERE.

Full on localization is so complex that one might argue to have an entirely separate UI by culture. Everything is different, dates, currency, text, layout, and even some colors or images would be a mistake in some cultures.
If it is just a small app and all you want to do is change the text based on culture here is a very simple example:
http://www.codeproject.com/Articles/299436/WPF-Localization-for-Dummies

Another simple but elegant way to localize applications can be found here:
http://wpftutorial.net/LocalizeMarkupExtension.html
It's based on markup extensions.

Related

How to properly adapt the app UI on different screens on W10

I'm about to start porting my WP8.1 app to W10, and looks like I'll have to make it a Universal Windows App. Now, I'm fine as for the back-end code, as I'll be able to reuse 90% of my classes (Models, ViewModels, and most of my helper classes, extension methods and converters).
The problem is for the UI: I understand I'll have to design the app for different screens and aspect rations, and I don't know how to actually implement that in code.
I mean, as for the UI scaling, I know I can use the VisualStateManager and AdaptiveTriggers to manually set the properties of the UI elements I want to adapt on any screen resolution, or I can use some converters, and that's fine.
Whan I mean is: what's the best method to have the whole UI adapt to different resolutions?
This is an example:
As you can see: the whole navigation pattern changes along the UI when on different screens. On phones, we have the contact page that covers the whole UI, while on tablets and PCs we have the contact page that's just a fraction of the UI, and the pivot pages are moved into another panel on the right. Also, many of the UI elements are completely rearranged.
And of course, some view-level back-end code will change as well.
Now, I'm wondering what's the best approach to do this whole thing.
Should I:
• Have a single XAML file (for every page) with a lot of VisualStates and stuff, and try to rearrange the UI for every screen resolution
• Have different projects with a shared project (like with W8.1 universal apps), so that I can focus on the UI on every specific device? This is the approach I'd be more comfortable with, as I'd be able to design platform specific UI elements without problems. Still, I didn't understand how to actually create a shared project and different projects for each device type in VS2015.
• Use that approach with different XAML pages that share the same code-behind file (even I'm not sure how to implement this, and how to implement platform-specific code-behind parts).
• Some other method
I mean, I'm sure I'm not the only W8.1/WP8.1 developer in trouble here, is there some kind of advice I can use? I already watched all the MVA videos about W10 development, but they didn't get into the implementation details there.
Thank you for your help
Sergio
It really depends on your project. If a UI isn't changing too drastically, I would definitely use AdaptiveTriggers. You can do a lot with very little XAML. Check out Microsoft's sample code if you haven't already: https://github.com/Microsoft/Windows-universal-samples/tree/master/xaml_responsivetechniques
If it is changing drastically, you can do it with AdaptiveTriggers, but it's probably easier to have multiple XAML files. A new way to do this in Win10 is to use DeviceFamily. Essentially, just create a folder called "DeviceFamily-Mobile", and stick a XAML view with the same file name in there. More info: http://sharpgis.net/post/2015/04/01/Creating-DeviceFamily-specific-layouts-in-a-Universal-App
Those two screenshots aren't necessarily that different, if you look at using the SplitView Control and the RelativePanel Control.
See this //build talk for more info.

How can I copy the Win8 metro File Picker UI

I'm creating a Windows 8 metro style application for navigating a rest api which is essentially the same as a file system. I would like to use the same UI as you get with the File picker and the built in search results.
How can I get the XAML (or ideally XAML+code) used in this UI? Are there any samples? Could I use a tool? Is the code available anywhere?
Thanks,
Jon
The FilePicker is provided as an OS piece of UI that is common across all the WinRT dev environments. There is not any source or XAML available for it.
Just build it, right? The UI is so simplistic, that I think an hour and some TLC and you will have what you want. You can't get the raw XAML as it's in the OS itself, but you don't want it anyway - it's certainly implemented with more complexity than you want or need.
I would offer this one bit of advice. It makes sense to copy the general look of the file picker for the sake of usability. However, do yourself a favor and make something different. There's no reason the user should be confused by the similarity - wondering where their SkyDrive is or something else. You may have already thought of this.

Creating your own forms designer

I would like start writing an application that will let my user design the interface by choosing some basic controls as Labels, TextBoxes etc. Once done I would like to save the layout in an xml file and be able later on runtime to reconstruct what user choose.
Is there anything similar ready and pre-made?
Can you suggest me the approach?
Any suggestion is welcome!
Cheers
Creating your own designer is a lot like building your own submarine in your basement. Programmers tend to take the quality of the Winforms or WPF designers as a standard of measure. Both are however the result of multi man-year efforts at Microsoft. Reproducing their work from scratch is a daunting task.
Best thing to do is leverage what's already done by them. Possible with the Winforms designer, this magazine article is excellent to help you get started. It is dated but I'm fairly sure it is still relevant, little has changed in Winforms in the past 6 years.

c# Tree/MindMap GUI

i am trying to research some gui technology for c# where i can display a tree view (opposed to the standard one provided.)
Essentially i want to have the gui draw a tree of data (as if you were going to draw a binary tree on a piece of paper or something) Then making each of the nodes clickable.
If this isnt available does anyone know of something where i could have a mindmap type GUI which shows links between elements and those are clickable?
I can guess people will say make one yourself, in which case i give up already ;) thats too advanced for me and as i am on a work placement i dont think i would be granted the time to make it as there are more pressing issues to get working first, like actually making the programme work!
Thank you
You can take a look at the controls in Kevin's WPF Bag-o-Tricks which has a WPF mind map style layout. Here is a nice example. If you want to use more professional components take a look at the product from Nevron Software, they have some great controls. There is also an opensource WPF graphing library - graphsharp (which I have no experience with, but I found a nice article by Sacha Barber). Since it's used in nDepend it must be pretty mature.
I hope you get some inspiration from those links :)
I also found XMind API for C#
https://xmindapi.codeplex.com/
It's free and looks easy to use.

creating iSeries like programs

my main language is vb/c#.net and I'd like to make a console program but with a menu system.
If any of you have worked with "dos" like programs or iSeries from IBM then thats the style I am going for.
so, was wondering if anyone knows of a "winforms" library that will make my form look like this. I dont mind a "fake winforms look" or a console application but thats how I'd like.
I've used iSeries extensively and I remember exactly what you're talking about. To simulate this look and feel in a C# app, you'll want to create a console project and write text to different areas of the screen with the help of the Console.CursorTop and Console.CursorLeft properties, then calling Console.Write or Console.WriteLine to write out the text in the previously set position. To change colors, before calling WriteLine you'll want to use the Console.ForegroundColor and Console.BackgroundColor properties.
You'll need to listen for input and upon finding a tab character, your program can use its own internal logic to determine where the cursor should appear next (on the next line in the same column, for instance, to simulate those left columns of input fields in your screenshot).
Doing this with a Windows Forms app will be a little trickier and you'd definitely want to write your own control for it (possibly sub-classed from one of the many types of standard multi-line text controls already available).
It's a good question. For many Use Cases the standard Windows (or other windowing) paradigm can be overkill, intimidating, and confusing.
Back in DOS days there were a number of "Windowing" libraries that created various abstractions for doing this.
[After Googling]
Here's a site that lists various libraries including a several that appear to be of interest.
A resource like this would also be handy for Mobile apps, where mouse-driven window apps tend to be not the best fit, especially for workflow-type processes. The Console is a pretty universal lowest-common-denominator abstraction available in most every environment.
You are looking for a curses like library but for windows. And usable from VB & C#.
Curses provides for a even richer text based UI than even iSeries. All sorts of widgetry!
Windows is not really supportive of text interfaces whether on purpose or not so are out of luck.
But ...
Well, how about MonoCurses? I don't know if it will work though. Also look at PDCurses.
And if you don't mind using Python for just the front-end see this.
There are a couple of webifiers or screen scraping programs for iSeries that will create a web or windows user interface on top of your iSeries application. I have never used any of those so there is not a particular one that I can recommend, but you might want to look their for inspiration or reuse.

Categories