01
sept
2011

Gettext on a debian server doesn’t work

Gettext is a powerful tool to manage translations in a website but sometimes it just desn’t want to work. You use it on a windows test environment with wamp or easyPHP and everything works just fine and when you put your files on your server, it just don’t.

When searching the net you will find comments about the permissions of you translations files but that’s rarely the problem. You will have to check if the locales you want to use are correctly configured on your server with :

dpkg-reconfigure locales

Choose wisely the locales you want to use and mind the encoding. You will have less problems with UTF-8 locales. But it’s not quite finished yet. When you’ve configured the locales, you will have to use their complete name in your php code with the encoding. You can have the names with :

locale -a

In my case, I had to use fr_FR.utf8 and en_US.utf8. It wouldn’t work without the « .utf8″ part. So here is the code needed by my application to work on my server

  1. $language = ‘fr_FR.utf8′;
  2. putenv(‘LC_ALL=’ . $language);
  3. setlocale(LC_ALL, $language);
  4.  
  5. // Specify location of translation tables
  6. $domain = ‘messages’;
  7. bindtextdomain($domain, ‘./languages’);
  8. bind_textdomain_codeset($domain, ‘UTF-8′);
  9. textdomain($domain);
Posted in Non classé | Leave a comment
18
juil
2011

Choose the height of a facebook application

By default, a facebook app will have a maximum width of 760 pixels if you choose to use an automatic resize of your application. But doing this, the default height is about 800 pixels and you can’t have a scrollbar this way. Choosing scrollbars for your application is a way of having virtually unlimited height but you will see that facebook also add an horizontal scrollbar even if it will be unused, like this :

Fortunately, there is a way to choose precisely (well more or less) the height of your application. You just have to choose the automated resize and use a bit of javascript. Keep in mind that this code is made for applications only and may not work with pages.

  1. <div id="fb-root">
  2. <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js">
  3. </script><script type="text/javascript">
  4. // <![CDATA[
  5.     window.fbAsyncInit = function () {
  6.          FB.init({
  7.              appId:‘YOUR_APP_ID’,
  8.              status:true,
  9.              cookie:true,
  10.              xfbml:true
  11.          });
  12.          FB.Canvas.setSize({
  13.             width: 700,
  14.             height: 1000
  15.         });
  16.      };
  17.      (function() {
  18.          var e = document.createElement(‘script’);
  19.          e.async = true;
  20.          e.src = document.location.protocol + ‘//connect.facebook.net/en_US/all.js’;
  21.          document.getElementById(‘fb-root’).appendChild(e);
  22.      }());
  23. // ]]>
  24. </div>

Don’t ask me why you have to repeat twice the same code (the second half is just another way of doing the first) but you have to do it and to put this snippet of code just after your <body> tag to make it work. As you can see, I choose an height of 1000 pixels. It seems facebook is doing a bit of dark mathematics there, so you’d be wise to put a little more than what you need in order to have the height you want.

Facebook is known to often change its API so this code works as of now but I can’t say for sure it will still do in a few months. Check the date, hope for the best, enjoy long facebook applications.

Posted in Facebook, Javascript | Tagged , , , | Leave a comment
08
juin
2011

kdenlive crashes when I open my project

For those who uses the video edition software kdenlive, if you encounter a crash when opening a saved project or when you try to play it. You just have to go to your project folder (kdenlive in your home if you choose the default) and erase the .thumb directory in there. You can then reopen your project and all should be good again.

Posted in Linux, Video editing | Tagged , , , | Leave a comment