Jefim Borissov Житие мое

19Mar/102

Localizing a WPF application

I know, Google knows so much about this, yet still, no clear and simple step-by-step guide. So here it goes:

  • Download LocBaml tool here
  • Compile it and get the LocBaml.exe
  • Open your project file with Notepad.
  • Add the following there: <UICulture>en-US</UICulture> under all <PropertyGroup> tags (for all build configs that is).
  • In your XAML files add x:Uid="someUniqueUid" to any element you want to localize.
  • Build your project.
  • Navigate your explorer to the build folder - you will see that it has a new subfolder called en-US. Inside you will find a file - YourProject.resources.dll
  • Copy the binary of your project (e.g. YourProject.exe), LocBaml.exe and any referenced project binaries into this en-US folder.
  • Open a command line prompt in this folder (under Windows seven you can press [Shift] + Right click and choose the command prompt window from the context menu).
  • Run the following: locbaml /parse YourProject.resources.dll /out:YourProject.txt - a human-readable text file will appear in the folder.
  • Edit the text file (translate the values in it). Excel is your best option - open the file from Excel menu and it will ask you if you want to treat tab symbols as text separators).
  • Run the following after you localized the text file: locbaml /generate /trans:YourProject.txt /out:..\ru-RU /cul:ru-RU YourProject.resources.dll (replace ru-RU with the culture you are localizing into).
  • Now all you have to do is to set the CultureInfo for your application thread like this:
var cultureInfo = new CultureInfo("ru-RU");
System.Threading.CurrentThread.CurrentCulture = cultureInfo;
System.Threading.CurrentThread.CurrentUICulture = cultureInfo;

And you are done. You app should be localized now!

Filed under: Programming, WPF 2 Comments
11Dec/096

CodeIgniter – Cart crap with Cyrillic characters

Ok, now this is so ridiculous that I have to blog about this even though I do not want to. CodeIgniter just blew my mind some time ago when I upgraded to 1.7.2 for the new Cart library. I realize, that it is a basic functionality, yet still... It does not support cyrillic characters in the product name! It is freaking 2009, almost 2010 and one of the most popular MVC frameworks does not support cyrillic? And I bet any other "strange" characters too, because basically they have a filter there with a regexp:

var $product_name_rules	= '\.\:\-_ a-z0-9';

Now that is some serious shit! :)

Anyway, if you have trouble with the same thing - doing non-latin chars in product names just find and comment out the following part from system/libraries/Cart.php:

if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name']))
{
	log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces');
	return FALSE;
}

Also, if you are using a database table for your sessions - do not forget to check that the user_data field uses UTF-8 as its encoding (otherwise it won't let cyr chars into the field).

29Oct/0914

Basic CSS layout

The basic CSS layout I use in my work is plain simple - header, sontent, sidebar and footer.

The HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
  <title>My page</title>
  <base href="http://localhost/" />
  <link rel="stylesheet" href="css/style.css" />
</head>
<body>
  <div id="wrap">
    <div id="header">
      Header
    </div>
    <div id="content">
      Content
    </div>
    <div id="sidebar">
      Sidebar
    </div>
    <div class="clr"></div>
    <div id="footer">
      Footer
    </div>
  </div>
</body>
</html>

And the CSS is very simple:

#wrap    { width: 960px; margin: 0 auto; }
#header  { }
#content { width: 700px; float: left; }
#sidebar { width: 260px; float: right; }
#footer  { }
.clr     { clear:both; height:0px; overflow:hidden; }

This is it. This code will show a simple page which is ready for hardcore modification. I know this is pretty basic yet it is one of the most used code snippets in my IDE. Good luck!

Tagged as: , 14 Comments
26Oct/094

Image / file upload with CodeIgniter

Image upload can be a pain in the *ss. And even though CI has a lot to offer (in the means of documentation) it still lacks a direct copy-paste code on their website so that people can just put it into their controller and use away.
Here we will have:

  • Image upload form with 5 images
  • And a controller function that will upload those
  • Thumbnails will be there too ;)
15Oct/090

Komodo Edit tools – add style.css and reset.css

Good morning, planet. Today I am going to share a very useful script I am using in Komodo Edit (it automates adding style.css). It is very (!) simple yet very effective for me and, probably for others who are doing a lot of HTML files and face a problem of repetitive actions.
This thing works as follows (the use case):

  1. You create a new HTML file in komodo and save it in some directory.
  2. You double-click the script in the Komodo Edit toolbox.
  3. The script adds the following folders/files to the project (paths relative to the file currently in editor!)
    • css/
    • css/style.css
    • css/reset.css
  4. Also the file adds the following HTML code at the cursor in current opened file:


Voila. The needed action is done.

12Oct/096

How-To: Create a horizontal menu

This is a tutorial on how to create a fully costomizable horizontal menu. Why another menu how-to? Well, mostly because there are situations when there are no suitable google results (based on my experience) and you have to come up with something yourself.

These are the features we will try to get into our menu:

  1. It will be horizontal
  2. It will have splitters (made with images)
  3. It will have active class for rollover / selected item (background change)
  4. Menu items will be of different size

This code works for Internet Explorer 6+, Firefox 2.0+, Opera 9+, Safari (at least on Safari 4 - tested on Windows version of it).

Here is a mockup that we have:

Menu mockup

Menu mockup

NB! If you just want to see how to do it - go here for the demo / full code.

12Jun/090

Web development tools I use and recommend

Ok, not being original here, but still... a web developer's blog is never complete without this. Maybe somebody will find at least something useful here. So here goes:

Tasks

  • slicing designs into images and cobining it to (X)HTML/CSS
  • script writing (PHP / JavaScript)
  • debugging
  • testing IE compatibility
  • quick editing
  • database handling
  • OS: Microsoft Windows
  • others
29May/091

A bit of MODx CMS criticism

Today I am going to talk about MODx CMS again. Now, the first post on this topic covered my first impressions of this product. And now I have something else to say.

This time I am going to go a bit deeper into minuses of MODx. Why? Well, all the pluses are available on the official website and I do not see the reason for repeating those. This post does not in anyway mean that MODx is a bad product! It just has some bad sides that I would find very useful to read about before starting to build a website based on this system. This post is healthy citicism and maybe a precaution for those wondering what can't you do with MODx.

Tagged as: , , Continue reading
12May/090

MODx CMS overview

Some MODx related post discussing MODx cons is also here.

0. Intro

Today I am going to say something about MODx CMS.

At the moment I have used it to make one website as well as I am using it right now to make another. This is mainly the suggestion of the client, so I am using it not because I like it so very much, but just because of circumstances.

So far my experience with it is, actually, quite pleasant. MODx CMS has a lot of fine features. At the moment I can tell that it at least has the minimal things that are required to make a website. So far I have understood, that most of the MODx functionality relies on the following things: templates, template variables (TV), chunks and snippets. All the other things are quite auxiliary.
So, let us take a look and see what those are.

Tagged as: , , Continue reading
31Jul/082

Hehe Text Editor: so it begins

So, today I will start telling you about a very simple text editor I am making just for the fun of it. The thought appeared to me while I was extremely bored just "stumbling" sites. I thought - "Hey, instead of wasting your time doing nthing why don't you make a simple text editor and log the whole proccess in your blog?". And that is basically it. I wrote up some code. The main window and stuff and that was it.

Anyway, some thing I want to achieve during this "session":

  1. Tabbed documents
  2. Support for large documents
  3. Windows context integration (like Noepad++ does)
  4. Code highlighting
  5. Code folding
  6. Code structure
  7. Autocomplete for functions and variables

And maybe something will be added later. This is a very minimalistic feature list for me right now. Next time I'll show you what I've done so far.