The last few days I worked on getting translations to work with gettext. Somehow it didn’t work the way I wanted it. Big problem there is: You need to restart the server when you update translations. But I kind of liked the gettext style and tools that already exist.
Because of that I wrote my own class in PHP which allows me to get translations done on the future web site for an Android Project.
Here a quick example of code how it works:
1
2
3
4
5
require_once"includes/Localization.class.php";$loc=new Localization;$loc->setDomain("test");$loc->setLocale("de_DE");echo$loc->_("This is a test!");// translates "This is a test!"
Well. This is the website constructed. But now we need to create the .pot file for this website. Well. No problem. Just run the following command after you set the domain (setDomain). You can as well give an array of files if you have more than one file in the same domain.
1
$loc->createGettextPotFor(__FILE__);
This will create the locale/test.pot through running a shell command (xgettext needs to be installed). You have to do this for every domain you create through the website. Best is probably to make a .php file which has all the domains with its files. Than you can run this once and get all the files done.
Now you can take that file and copy it to your language folder with the ending .po. For example we place it into “locale/de/LC_MESSAGES/test.po”. This is the same way as you would do with gettext. And in this file you can do your translations for German.
Gettext always compiles things. So I thought why should I not do the same? Instead of always read through the entire .po file and filling the array I could just do that once. So I did. When you compile the file will be read, filled into an array and then serialized. The following command will do that for all files in locale:
1
$loc->compileAll();
Well that’s it. And don’t forget, that the whole locale folder needs to be writable .
Here I give you my example files to test it out.
If you have any questions or improvements, let me know in the comments .
Problem: With Android 2.2 (Froyo) packages can’t be force closed through restartPackage() anymore. Exactly this is what SleepTimer relied on to turn off the different Services which are running music.
Thanks to Corsin Camichel I found an example on how Google force closes packages in Android 2.2 (Froyo). This happens over an internal API. Method name is: forceStopPackage(String pkgName).
So I tried my luck with reflection.
1
2
3
4
5
6
7
8
Class c =Class.forName("android.app.ActivityManagerNative");Method getDefaultMethod = c.getMethod("getDefault");
getDefaultMethod.setAccessible(true);Object nativeManager = getDefaultMethod.invoke(null);
c = nativeManager.getClass();Method forceStopPackageMethod = c.getMethod("forceStopPackage", String.class);
forceStopPackageMethod.setAccessible(true);
forceStopPackageMethod.invoke(nativeManager, pkgName);
But I get an exception when calling the last line.
java.lang.SecurityException: Permission Denial: forceStopPackage() from pid=1965, uid=10075 requires android.permission.FORCE_STOP_PACKAGES
I tried adding it to the AndroidManifest.xml. But without luck.
If somebody figures out how to get this working, I would be happy for a message! Or an e-mail from Google how to get this working would be nice.
Update:
According to velazcod and rac2030 it is not possible to get the required permissions for this
The only problem is that in order to use this method, you need the “android.permission.FORCE_STOP_PACKAGES” permission, and that permission requires a “signature” protectionLevel, so the system will not grant it unless the app is signed with the same signature as the system
When I was still in Switzerland I thought if I can not sit down in the train means it is pretty full. Or there were times in Zurich where I thought the train really is full. But I have learned that there was still a lot of space left! With a lot of space I mean that you can fit twice as many people in there, if not even more! That is what I can say after experiencing rush hour every morning in Tokyo. Rush hour here is between 7:30am and 9am.
Here a video to demonstrate how it is every morning. I didn’t take that video. But that kind of how i feel every morning. just that i don’t stay outside. I go inside too.
This is how it feels. You stand in this huge crowd of people who are all waiting for the train. You just think: “Are they really all gonna fit?” And yes. Most of the time they do. Or they try to fit everyone inside . To be honest, on my line it is worse than in this video – I take the Saikyō Line (埼京線). Here the people actually didn’t have to push that hard to get in. You probably think: “They hardly could get in there!” But really. There could fit 2-5 more people in there for sure! Just search for “Tokyo pushers” on youtube and you will see what I mean . Those pushers are no joke! They really stand there every morning! I see them every day!
And here some pictures I took this morning. From the outside and inside of the train.
Well. Saying that I was even able to get my camera out means that it was not that full. Normally it is so full that I can’t take my camera (Nexus One ) out.
Now you might wonder: “How do I get out of the train?”. Well there is only one way: Push! Hopefully you are not the only one getting out at the station. But if you are, just show them you need to get out. And some people will get out of the train to make space. Or at least so much space, that you can get yourself out somehow.
So you see that I do some fitness every morning!
My host father hates it when it is crowded this much. I understand him now. It is kind of hard and always requires an effort to get in and out and to be able to survive inside. So I once went with him in the morning. We took a train at 6:45 in the morning. I have to say it was a lot nicer . But too early for me to get to work. Office opens a little before 9am and it takes me 1 hour to get to work. So I found myself at the station of my work place at 7:30 in the morning. But I had my notebook with me and sat into a cafe and had my hot chocolate. Luckily there was an open wireless network that i could use. And opening the VPN tunnel to my school made me feel secure enough to surf around the internet .
So much to my experience with the rush hour in Tokyo Japan. If you have questions, feel free to ask in the comments (or directly).
A lot happened in the last few days. It is too much to write down and I have forgotten a lot already. But let me tell you some things about my first day at work.
My room
I have about 1 hour to travel to my work place in Yotsuyasanchome (close to Shinjuku). And I don’t live in Tokyo by the way. I live in Saitama. But that basically is still Tokyo. I didn’t realize, that I left Tokyo . I had a really bad night before my first working day. I wanted to sleep around 11pm. But I was just too awake because of the jet lag. So I kind of fell asleep around 12:30am. But guess what. I was totally awake again around 3am. I tried to continue sleeping. I wasn’t really successful. Around 5:30am I fell asleep nicely, but had to get up at 6am. So I took a shower and then ate breakfast here at my host family’s place. They are really nice by the way! I will have to write more about them another time. So after that I went on my way to work around 7:30am. I was already warned, that it is rush hour. And yes it was! Whatever we call rush hour in Switzerland is nothing compared to rush hour here in Tokyo. When I walked to the train station there were dozens of people on their way. And all of them had to fit into the train. First train was kind of okay. Second one was the hard one. Well. Have you heard about “pushers” in Tokyo? The ones working at the train stations to push the people into the train. Yes, it is for real! Every morning! And of course I can’t forget the humidity here. So everyone is sweating. But at least the airconditioner in the train is working.
So after a little more than an hour I got to my working place. Already an adventure before getting to work. There I was greeted nicely by my co-workers. The boss was not there. But I was able to get a little bit into the system and analyze what the process is. Since there were different interns working on the computer system it is quite big and not really well documented. Every intern has his documents and the password list is not updated and so on. Basically there is a Microsoft Access database where they put their articles in. Then there is a Web Server in the company to get the data from that access database and store it into an own MySQL database. And there are some additional tasks that can be done. And afterwards the data from that Web Server is transfered through a script onto the Web Server in the Internet running on Typo3. So this is what I fought with the first day. Understanding everything, finding passwords and access and reading HTML, JavaScript and PHP. During the afternoon I got really tired because of the lack of sleep. But somehow I made it without falling asleep.
After work I quickly meet with a special someone at the trainstation in Ikebukuro. But we only had 30min to meet and talk. Too bad. Because once at least in this week I should have dinner with my host family. So I got home on time and we had a great dinner! I just love the way Japanese people cook! Not that I wanna say that the food at home was not good. I liked everything my mother cooked . Maybe I am too easy to be satisfied? Or was it that I was too tired the last days? Well however. After dinner I thought I will go to bed early. But guess what. I was soon feeling awake again. And today (one night later) it is exactly the same. Now 1am. I haven’t sleept that much last night either. But now I should go to bed.
Yesterday we finished our bachelor project called ScrumTable which we did at the HSR. It was a fun time together with Michael Gfeller and Silvan Gehrig. We received wonderful feedback about ScrumTable. Michael and Silvan will continue to develop ScrumTable at the HSR.
ScrumTable can be used in Scrum Meetings in cooperation with a Microsoft Team Foundation Server. You can move and edit your Work Items from the Team Foundation Server during the scrum meetings and it will be saved back to the Team Foundation Server immediately.
Used technologies: