Friday, October 7, 2011
Languages in the web interface
Today, if you want to sell products, you have to support multiple languages. Even if you are in a country that has clearly a primary language, there are so many people from other countries that a support for additional languages does not hurt. The way it is done in the handset is different from the way it is done in the base; today’s topic is about the base.
If you want to change the language on the base, you first have to log in. The first time you login, you will get US-English content; hopefully your language skills are good enough to navigate to the page where you can change the language. Then after this, you have to log out and log in again. Then you should see your favorite language. The language settings is global, so if you have other folks that want to log in, you will have to agree on a common language.
On the base, practically all texts are used in the web interface. The m9 has a built-in web server and due to the space limitations, it cannot be a full-blown PHP or ASP server. However, the m9 web server does come with some smart functions, including language items. When the m9 web server has to produce a page, it looks for special tags in the file and replaces them with dynamically created content. The syntax is pretty simple: it just references a number; that’s because all items are just indexed by a number. Other products like the snom ONE are using texts, but we figured that for a small embedded product like the m9, number will have to do.
The syntax of a language file is also pretty simple. There is no XML, just plain line-based items terminated with a CR/LF. Each line contains a number in the beginning, followed by the translation text. Comment lines start with a pound symbol, and there is one more special line, which tells the web server which language this is. Upon boot up, the web server just reads the whole file, and then when it has to generate language content, it just puts it into the HTML text. Everything is UTF-8 encoded, so we would even be able to support Japanese, Chinese, Koran, Urdu, you name it. Not sure if Hebrew and Arabic are problems, as they are writing from the right to the left. For those guys who read the blog entry how to log into the base via telnet, you can find those files in the html directory with the name lang_xx.txt, where xx is the language.
If one of you finds out that a translation could be improved, please drop us a note and we can easily change it for the next release. We actually thought about having a “feedback button” where the end users can propose other translations; but at the end of the day this does not only occupy valuable development time, it also does occupy more code in the base so we forgot about it for now and let’s do it the good old fashioned way: email to support.