Multilingual WPF Applications - on CodeProject
Well it seems that multilingual WPF applications is a hot topic, at least according to my most visited posts and a few questions posted on CodeProject. That has kick-started me into writing an article based on my implementation described on this site.
The article may be viewed at:
http://www.codeproject.com/KB/WPF/Multilingual-WPF-Apps.aspx
Being my first CodeProject article, it was a bit of a learning experience. Fortunately there's some good information on getting started with writing & submitting articles and perspectives on how to make it a good article.
The good thing that an article template [ZIP] is provided with HTML file for writing the article, which is a good way to work on it offline and preview how it will look when it's published.
When it comes to submission and publishing, I chose to use the submission wizard rather than email it by ZIP file. While this has its convenient advantages, there are a few points to note:
- You can't simply upload the ZIP file containing the article (in HTML), code sample (in nested ZIP) and images in one step. Instead, you need to upload each image and ZIP file (containing code) separately on one page, then input the article on the next page of the wizard.
- The article itself is input using the WYSIWYG editor that supports rich formatting. Fortunately, this contains an HTML mode, so you can simply copy the article body from your HTML file and paste in the HTML view. You don't need to copy the <pre> tag containing the information you fill out online earlier in the submission wizard.
- If you have images, you'll need to change the URL to be relative to your article (as the instructions indicate on the wizard page). This is largely dependent on what you choose as your base name as displayed in the browser's address bar.
- Code fragments in <pre> tags need to have the 'lang' attribute assigned if using any language apart from C++. You won't see the difference when editing the article offline, but when it comes to previewing it online, this will make the difference for what syntax colouring you get. Doing this earlier saves time when you go through the submission process.
Other things I learned in the process:
- When quoting internationalised text, watch the encoding of the HTML file. I changed this to UTF-8 so that foreign scripts like Japanese ひらがな (Hiragana) didn't show up as blocks or question marks.
- Take care of how the HTML comments are handled. In the text editor (Notepad++), everything was fine. When it came to viewing it in Firefox, most of the article ended up being commented out. Fortunately I discovered a hack - simply add "<!--><-->" (without quotes) before your article content. I've no idea what was causing this!
- While it takes a bit of time writing the article, don't underestimate how long it takes to provide a code sample, even if it can be extracted from a different project. It takes a long time to tidy things up so that redundant parts are removed, and to ensure that the sample is of good quality (as much as the article). There is a tricky balance - to ensure the code is easy to follow and credible, while getting it done as quickly as possible.
And lastly, it's a good thing to have fun in the process - it probably shows, given that I styled the sample.