For our main product, Ideanet, we have over 2500 lines in our yml translation files. That is, 2500 lines per language.
Currently we support Dutch, English, French, Spanish and German. We manage Dutch and English ourselves, but for the other languages we need the help of a translation agency.
The problem is that Ideanet grows dynamically, and so do the translation files. We can’t send all the translation files to the translation agency once in a while and tell them ‘figure out which of the English translations are added and add those to the other languages’.
So we need an extract of the translations that are in the English (and Dutch) files, but not in the other ones. We save those extracts (which contain the English values) to de.yml, es.yml and fr.yml in separate directories. This is done using rake locales:extract
These are sent to the translation company.
When we receive the translated files back, we need them merged back into the translation files. We execute rake locales:merge
The translation files are sorted alphabetically in the process. This is useful when removing translations, which needs to be done in all translation files.
Code:
Posted August 16th, 2011 by
Martijn Lafeber
It has always been a little annoying including video files for our clients. Since most of them use a outdated version of Internet Explorer, we have to resort to Flash video.
We like to show demos to new potential clients on our iPads. The videos won’t display on the iPad since Flash is not supported. There’s a nice solution using html video tag and a flash fallback using flowplayer.
Here’s the code:
<video id="movie" width="320" height="240" preload controls src="demo.mp4" />
This format is currently supported by Chrome, Safari and IE>8.
You will need a bit of javascript code that will replace the video tag with flash for all other browsers:
replaceVideoWithFlash = function() {
if(navigator.userAgent.indexOf('Firefox') != -1 || navigator.userAgent.indexOf('Opera') != -1 || ( navigator.userAgent.indexOf('MSIE') != -1 && parseFloat(navigator.appVersion.split("MSIE")[1]) < 9 )) {
var videos = document.getElementsByTagName('video');
for(var i=0; i < videos.length ; i++) {
var video = videos[i];
fvideodiv = document.createElement('div');
if(video['poster'] != '') {
var config = '{"playlist":[{"url": "'+ video['poster'] +'","scaling": "orig"},{"url":"' + video['src'] + '", "autoPlay":false, "autoBuffering":true}]}';
} else {
var config = '{"clip":{"url":"' + video['src'] + '", "autoPlay":false, "autoBuffering":true}}';
}
fvideodiv.innerHTML = '<object style="z-index:3;" id="flowplayer_'+i+'" width="' + video['width'] + '" height="' + video['height'] + '" data="/flowplayer/flowplayer-3.2.7.swf" type="application/x-shockwave-flash">‘ +
‘<param name=”movie” value=”/flowplayer/flowplayer-3.2.7.swf” />’ +
‘<param name=”allowfullscreen” value=”true” />’ +
‘<param name=”flashvars” value=\’config=’ + config + ‘\’ />’ +
‘</object>’;
video.parentNode.insertBefore(fvideodiv, video);
video.parentNode.removeChild(video);
}
}
}
Note: We prefer .webm over the h.264 format. The latter is not open and thus not supported by Firefox and Opera, for which we have to resort to flash too
However, it’s currently the only format that works out of the box on Safari - and works in the flash fallback as well.
Please Apple, Please Microsoft: support the open Theora Webm format. This is the only way that in a few decades, when all the sluggish large companies have upgraded to modern browsers, we can all use just one, open format.
Posted May 31st, 2011 by
Martijn Lafeber