Localization support for language identifier

Something’s wrong when a language identifier doesn’t have localization support. So I cooked up a little localization code for What Language Is This?, which proved to be not as easy as one might guess. That’s because some of the textual content of the web app is in HTML, other is generated by PHP, and yet other is generated in JavaScript. I wanted to have one single source of localized strings for all three output paths to simplify overviewing, translating, changing, and adding strings to the web app.

I’m not sure if there’s any good solution for this out there, but I cooked up my own. Each language translation has its strings in a text file formatted like an ini file with id keys and localized strings separated by an equals sign. You can view the English and Japanese raw text files if you like. These are read into a PHP array (i.e. dictionary), after first looking at what language is specified by the URL (/en for English, /ja for Japanese or any other code), and if that is not specified then looking at what languages the browser is set to prefer via the Accept-Language HTTP header. If the requested language is not available then default to English.

To get the html output localized, the php script that reads through and configures the app (the plain html file itself is set up to run offline for debugging purposes only) looks for string ids enclosed in percent signs, i.e. like %strings id%. These are then replaced with the localized strings from the dictionary. The php-generated content is trivially changed to look up strings from the dictionary. On the JavaScript side, I wanted access to the same string dictionary that I had on the php side, so this is inserted into a <script> block of the generated html output as a JavaScript object (i.e. dictionary). String id lookups can then be done on this object from the JavaScript code just like on the php side. In other words, the php string dictionary is converted into JSON, which is used from the JavaScript side.

あれ何語? What Language Is This? in 日本語

あれ何語? What Language Is This? in 日本語

It all works pretty well and meets my goals. The only downside is that it relies on the server to do some processing, so when I develop on the offline version the strings aren’t available, instead I get to see the raw string ids, which can be useful too, but you have to rely on imagination to envision the end result. Isn’t programming always like that anyway, though?

The first translated version of What Language Is This? is of course Japanese, done by myself and my wife (初めての共同作業? lol), not just because it’s easy for me to do, but also because when looking at the AddThis stats, Japan is the top ranking country, and also as you know the average English skills in Japan are pretty bad, so I suspect there is a demand for a Japanese translation. Looking at the access stats, and discounting those with good English skills (India, Netherlands, Scandinavia, for example), next in line would most likely be Spanish, French, and German, in that order. Anyone feel like helping? Please drop me a comment in that case. I can offer proper credit and a link back from the site in return.

Bookmark and Share

Getting a credit card in racist Japan

Japan is a country where racial discrimination is so commonplace that it makes news headlines when people are not racially discriminated against, such as when a Japanese company hires foreigners or a local government body allows foreigners to take the tests for working there. For us white westerners, it works both ways though. But one place where it really hits you (besides trying to find a landlord that will let you live in his apartment) is when it comes to getting a credit card.

I’ve been living in Japan for more than 4½ years now and tried many times to get one, always to be turned down. This especially includes applying for ones from my bank, Shinsei Bank, that I’ve used exclusively for all my time in Japan, and where I now have “platinum” status, meaning that I have many million yen entrusted at their bank, a significant part of which is in risky assests where they make a lot of profit. So they clearly rank me as one of their best customers, and I’m clearly bound to keep significant assets in their bank for the immediate future (so I cannot just “escape”), but still turn me down every time I apply for a credit card. Why is that?

Being turned down for a VISA credit card by my Japanese bank

Being turned down for a VISA credit card by my Japanese bank

When I visited one of Shinsei’s branch offices recently for a completely different, but somewhat time-consuming and complicated issue, I got to talk quite a lot with one of the staff there. As I have “platinum” status, they treat me quite well too, not hurriedly at all. This was one of the branches where a lot of foreigners visit, and she seemed quite used to working with foreigners, although we spoke only in Japanese. So at the end she asked if there was something else I’d like to inquire about, and I asked something along the lines of why do you turn my credit card applications down all the time, despite me being a “platinum” level customer and having millions of yen in your bank?. And surprisingly, she did have a good answer for that, not just the usual appologies.

The reason, it seems, why Shinsei Bank (which is, by the way, founded by a foreigner based on foreign capital) systematically turns down foreigners’ credit card applications is that the company that is contracted to handle credit cards for the bank doesn’t have any support line in English. Since we’d just been having a conversation about quite complicated banking matters in Japanese for half an hour, that reason obviously seemed very silly at that point. Still, that’s why. And since Japan doesn’t have any laws against racial discrimination, systematically turning down anyone with a foreign-sounding name (they don’t actually check your nationality) is just fine here.

Anyhow, at long last I went to Citibank to beg for a credit card there, since I’ve heard they’re more open to foreigners’ business. Considering the bank would have gone bankrupt if it hadn’t been bailed out by the US government, it’s not exactly my primary choice for doing banking, but anyway. And they gave me a credit card within less than a week, with a 1 million yen limit, which I think is very high. And unlike Shinsei Bank where I have the highest available “platinum” status, that was the first time I walked in to a Citibank office. I have no prior history with them at all. And they still gave me a pretty sweet credit card.

Finally got a Japanese credit card.

Finally got a Japanese credit card.

So what is the conclusion from all this? Go to Citibank. It seems Shinsei Bank and Citibank are the two somewhat modern banks in Japan, with Shinsei being about 10 years behind the average Swedish bank instead of the Japanese average of 50 years behind. Citibanks seems just as (comparatively) moderen. Shinsei seemed very foreigner-friendly when I opened an account there, but in the end they certainly do practice discrimination against foreigners, so I must say that I regret my decision – I should have gone with Citibank instead. That is the best advice I can give to anyone non-Japanese who’s getting a bank account and/or credit card in Japan.

Bookmark and Share

Good-bye Binero, hello DreamHost!

For many years now I have been hosting this site henrikfalck.com as well as all the other more or less useful web sites that I run at a company that was called Aleborg Solutions when I started using it, but is now known as Binero. They came highly recommended among web hosting services in Sweden at the time when I signed up with them.

However, as things have changed I have now decided to move all my web activities over to the humongous and well known DreamHost hosting service. Moving it all has been extraordinarily boring, but at least it’s finished now so I can concentrate on making new, fun stuff for the web instead of worrying about my hosting, since I’ve known for about a month that I had to make this move. This three day weekend provided a good opportunity to move things over in stages to prevent a total meltdown of all my sites at the same time (which happened quite a lot when I hosted with Binero). That last remark brings me to why I’m changing to DreamHost. These are the reasons:

1. A more stable hosting service. Binero used to be very good and all, but at some point they just started sucking. This peaked last month when I found all my sites being broken due to changes made by Binero (without informing me in advance) three times in one month. That is just a bit too often for me to tolerate. I’ve had my sites broken by Binero in the past too, but not that often. And once it took them two weeks to fix a simple problem introduced by one of their changes, by which time I had of course already worked around the it.

Binero’s tech support has always been very quick to respond, but usually had some snide, unnecessary remark in the response as well, and usually blamed me for problems caused by them randomly changing stuff. I’ve been a customer with them for a long time, so even if they’ve been telling new customers how to set things up correctly for the last five years, that doesn’t mean I know it automatically without them telling me about it. It’s not good when being a loyal customer is used against you. So I definitely can’t recommend Binero to anyone who’s thinking about getting web hosting somewhere.

Lately they’ve started hyping a new system they call Binero 2.0, which is exactly what I don’t want – even more changes, bound to break stuff if I know Binero correctly. On the other hand, the sysadmin at work has had sites running at DreamHost for many years without any breakage or changes. That kind of stability is what I want. I also like DreamHost’s attitude that you can essentially do whatever you want as long as it’s not a security risk or malicious. Binero on the other hand disabled sftp (encrypted) access, allowing only ftp (unencrypted) access for security reasons, according to their tech support. That is about as stupid as it gets. Besides, they also disabled ssh shell access (of course, unannounced), which is a pain in the ass when you need to fix something quickly, besides being just silly.

2. Better located hosting for faster response times. When I started making web sites I lived in Sweden and most people who accessed the sites were in that area as well, so it made sense to use Sweden-based hosting. Now, however, I live in Japan and most of the people accessing my sites (whatlanguageisthis.com is by far the most accessed one now) are in North America, Japan, or India, as well as from all over Europe with no country in particular standing out. My ping time to my sites on Binero’s servers was 300 ms, but DreamHost has 125 ms ping, which is a very noticeable improvement. DreamHost’s servers are located in California, which is the center of the physical Internet, unlike Sweden, which is about as far out on the fringe as you can get except Russia and Africa. (For example, Internet traffic from Japan to Sweden goes via the US, not via Russia, and all Asian countries are connected via the US west coast.)

3. Get away from Sweden due to FRA. If you don’t know what FRA (“National Defence Radio Establishment”) is, would you believe me if I said that the Swedish government/military intercepts all Internet traffic crossing the border? Hopefully you wouldn’t, since you’re thinking that Sweden is a nice, modern, democratic society that doesn’t need to spy on its citizens nor the Russians, since the Cold War is over by now. Unfortunately, that’s what they’re doing, and Sweden seems to be moving in the wrong direction in many other ways too now when it comes to information privacy. Not nice. Since I’m in Japan, and stupid Binero didn’t allow encrypted access, that meant the FRA could intercept anything I uploaded to my sites. Not that I would upload something sensitive without encrypting it first, but still, it’s just silly. The US is a better place to host web sites, so score one more for DreamHost.

Anyway, that’s the end of this rant. Finally the move is over, and I’m looking forward to not having to wake up and find my sites being broken much often any more. I’ll also be writing more interesting stuff on this blog now that I’ve finished both the moves to a better blogging platform (WordPress instead of Blogger) and hosting service (DreamHost instead of Binero). No need to procrastinate any further now that the boring stuff is done.

Bookmark and Share