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.


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.