ImaginativeThinking.ca


A developers blog

What the Heck is Long English?

By: Brad

Hey Brad what the heck is Long English? A college of mine told me to use it when I started working on a project which would be translated into multiple languages.

ThinkingPig

Long English (or if your a native Français speaker maybe you call it Long Français, or Long Deutsch if your a native German speaker, basically the concept is really Long <Your Native Language>) is a technique used to test to see if you have written your application in a way that will support translating the words shown to the user into other languages. I came up with Long English during a conversation with a college about Star English where we were talking about how Star English is great and all to verify that you’ve built your UI in a manner which will allow for your native strings to be swapped out for translated strings but it does not help you figure out if your UI’s layout is done in a way that will accommodate different lengthen strings.

Why do we use Long English?

Like Star English we use Long English when we want to translate our application; lets say you have written an application which shows the words “Hello World” to the user but you want to release it in different parts of the world which are not all native English speakers. To gain market share in those locations having your application use their native language would be a plus. So if you release your application in France instead of “Hello World” your application when in Français mode would read “Bonjour Le Monde”.

starEnglish_1

* Note I’m just using Google Translate here so if the wording is off that’s why.

Most programming languages or tool kits have a mechanism to allow you to substitute the strings you use in your application with other strings depending on what language the user selects (which could be done automatically by asking the Operating System what language it is in). If your language/toolkit does not have a built in way of doing this its not that hard to write your own; the idea is pretty simple:

  1. For each language you want to support you create a map which uses your native language string as a key and associates it with the translated version of said string.
  2. When your application starts up or when the user explicitly picks a language your application loads the correct map as the one to use.
  3. Anywhere you have a string which will be shown to the user you wrap it in a method which will look up the given string in the map to find the translated string to use.
  4. The method returns the translated string and uses it instead of your native string you wrote in the code.

starEnglish_2

The exact syntax is different for different programming languages / tool kits but here is an example of the above done in Qt.

myLabel->setText( tr( "Hello World" ) );

In Qt the tr( QString ) method is used to do the look up; if Français is selected as the language to use the tr( QString ) method will look in a resource file (*.qm) which holds all the strings used in the application in Français and will search for the Français version of the string using Hello World as the key. If all goes well it will find the entry in the resource file and return the string “Bonjour Le Monde” setting it to the text property of the myLabel object.

starEnglish_3

So what is Long English Then?

Long English is used to make sure your UI will adapt to different length strings as the fact of the matter is that some words are longer in some languages then others. Take for example the above UI but lets nestle the word Hello World between two icons.

longenglish_1

In English the string is 11 characters wide however if I were to translate the string into Français it would become Bonjour Le Monde which is 16 characters wide; will the string still fit between the two icons or will it now bleed out under them? The same question can be made for any buttons you have in your UI which has text within it, if you translate the text will the text still fit within the bounds of the button or bleed out? If the button correctly resize will it start overlapping other controls situated around it?

As anyone in our business will tell you its cheaper and quicker to catch and fix bugs sooner rather then later. So instead of putting off the testing to make sure that your UI’s layout will adjust correctly until the very end use the Long English technique.

Long English

So how do I visualize my UI with all the strings slightly longer then they are in my native language? How do I test to make sure my UI will adjust itself correctly with longer strings so that I can hunt down and fix minor cosmetic problems which would otherwise make my application look some what unpolished? In other words how do I test to make sure my application will support translations without having to wait until the very end when the translations finally come in? By providing a debugging or testing translation matrix.

If I create a translation map (in Qt its a resource file with the extension *.qm) which is full of dummy translations strings I can verify that my UI adapts appropriately to longer strings.

Instead of actually translating all your strings for testing purposes (which may render the UI only readable by a portions of your team assuming not everyone can read multiple langues) simply create a test matrix which returns strings which are still legible but noticeably longer then you native language.

LongEnglish_2

For example if I have the string Hello World my testing translation matrix will contain a translation for that string which reads WWWWWHello WorldWWWWW.

Notice the W’s on either side of the English word, The W is a fairly wide character and by placing a number of them on either side of your string you can increase its length; hence the name Long English. If your code is not written in English then use your native language and a native wide character. That is if you are a native Français speaker then your testing translation matrix would look like this: Bonjour Le Monde ==> WWWWWWWWBonjour Le MondeWWWWWWWW and you would probably call the technique Longue Français.

What this technique gives me is a way to visualize what my UI will look like when translated into a language whose words are typically spelled longer then they are in my native language. This allows me to verify that I wrote my application correctly to support translations and that the translation mechanism is working as expected as soon as I created the UI instead of waiting weeks or months for translations to come in. This allows me to fix bugs quickly and to catch errors in assumptions before they spread throughout the applications design.

longenglish_3

How Long should Long English be?

So now the question is how many W’s should I place around my native string? How long should I make the string?

For me I find that English is a rather compact language at times compared to some other languages like German or Russian so I feel that to get a relatively good picture of what my UI will look like when translated into a language such as German I need to double the length of my English strings. This isn’t always the case mind you I’m sure there are English words which are longer then say the same word in Russian or German and there are probably a number of words in common or only a single character difference but I’m not looking for 100% accurate nor am I looking for the best case scenario. What I’m trying to achieve is a quick test which will allow me to test the worst case scenario so that when the translations do come in I’ll have little or no code changes required; I of course would have to give the UI a once over with actual translations but the bulk of my testing is achievable with Long English.

When I implement Long English I tend to take the total length of the string divide it by two then place that number of W’s on either side of the string effectively doubling it; I round down in cases of uneven strings so Hello at 5 characters will become WWHelloWW. This I feel gets me 95% of the way there as a worst case test. If your native language is already verbose then maybe you only need to add a few characters, maybe only add a third of the native strings length or a quarter. Implement your Long English for the worst case you expect to encounter but don’t go ridiculous nor wast to much time trying to be 100% accurate.

Great but my translation mechanism only supports standard language codes (i.e. en_CA)?

Yes well that is an issue isn’t it, how do you inject a testing translation matrix if you can only use standard language codes; There is no such thing as a debug language code (debug_DEBUG).

Well the only option is to pick one and use it as a testing place holder.

The trick is not to pick one that you might actually need to use either now or in the near future.

If your application is net new and lets say is currently only in English but you know it will be translated into Français soon I would not recommend using the fr_Fr code as your Long English language matrix as you will have to remove it and replace it with the actual translation matrix. This could be an issue down the road when you go to release a new version and you’ve changed or added new UI elements and need to re-do the Long English test. Yes you could temporarily replace the fr_FR matrix with the Long English version but if you want QA to also use this technique for testing you will have to check it in and what happens if you forget to revert the change or if someone releases the wrong build?

If your translating it into Français I wouldn’t pick de_DE, it_IT, es_ES, or pt_PT as its likely you will probably support them down the road to even if its not on the immediate road map.

For me I choose to use fo_FO (which is why Long English is some times referred to as FOH-FOH). The fo_FO code is used for the language used by the people of the Faroe Islands. No disrespect to the native speakers of this fine language but according to Wikipedia they have a population of only about 50 000 people as of 2013 and in the grand scheme of things is probably not a language I’ll be asked to support for the foreseeable future (unless it is then I’ll just pick another language code which I’ll likely not be needing to support). Again no disrespect intended.

Flag_of_the_Faroe_Islands

Faroe_Islands_in_its_region

Because of the low likely hood that I will need to provide actual translations for Faroese I’ll use it to hold my Long English testing matrix. What I also like to do is leave it in place (usually only when the application is built in Debug mode) that way I don’t have to rebuild a whole new testing matrix when I make changes to the code over time.

longenglish_4

So that is what the heck Long English is, a technique used to see if you have written your application in a way that will support translating it into other languages. If you have any questions or comments please leave them below and I’ll write back as time permits.

If your looking for a tool to help generate a Long English translation map and your using Qt I have two version here on my GitHub. One is a Python script which you can use say in an automated build system and the other is a Qt desktop application if your looking for something a bit more user friendly.

Until next time think imaginatively and design creatively

Brad

My interest in computer programming started back in high school and Software Development has remained a hobby of mine ever since. I graduated as a Computer Engineering Technologist and have been working as a Software Developer for many years. I believe that software is crafted; understanding that how it is done is as important as getting it done. I enjoy the aesthetics in crafting elegant solutions to complex problems and revel in the knowledge that my code is maintainable and thus, will have longevity. I hold the designation Certified Technician (C.Tech.) with the Ontario Association of Computer Engineering Technicians and Technologists (OACETT), have been certified as a Professional Scrum Master level 1 (PSM I) and as a Professional Scrum Developer level 1 (PSD I) by Scrum.org as well as designated as an Officially Certified Qt Developer by the Qt Company. For more on my story check out the about page here

Feel free to write a reply or comment.