Tuesday, May 3, 2011

Gettext workflow

1. Define your bindtextdomain and textdomain as
bindtextdomain('hello', '/usr/share/locale')
textdomain('hello')

2. Wrap strings to be translated in gettext('translate me') or, using the gettext alias, _('translate me').
return _('this string is to be translated');
3. Extract the strings using the xgettext utility.
xgettext -d hello -s -o hello.pot hello.c
4. Turn the .pot file into a .po file that can be passed on to the translators
msginit -l es_US -o spanish.po -i hello.pot
5. Translate the strings in the .po file
msgid "Hello\n"
msgstr "Hola\n"
6. Convert the .po file into a compiled .mo using the msgfmt utility, note that the output filename must match the domain given as the first argument to bindtextdomain and textdomain and must be placed in the location specified as the second argument to bindtextdomain
joined with the language set in setlocale or set in the environment
msgfmt -c -v -o hello.mo spanish.po
cp hello.mo /usr/share/locale/es_US/LC_MESSAGES
source

Friday, April 22, 2011

Veetle player and ICEauthority

Installing the Veetle player on Ubuntu by running the install script as super user causes issues by changing the owner of your home directory to 1016 (or a similar #). This can easily be rectified by simply chown/chgrp your home directory back to your user and by replacing .ICEauthority file in your home directory with the /var/lib/gdm/.ICEauthority file (you also have to chown/chgrp the .ICEauthority file once you've copied it).



Source

Adding locales for gettext

Go to System -> Administration -> Language Support and add the languages you want to support.

Once those have installed, run

sudo dpkg-reconfigure locales

Done

Source

Wednesday, April 6, 2011

Emacs Tramp Cheatsheet

Open a file on a remote machine:
C-c C-f /user@machine:path/to.file

Sudo with Tramp:
C-c C-f /sudo::/path/to/file

Source

Tuesday, March 15, 2011

Emacs back references in replace-regex.

From http://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp-Replace.html

In replace-regexp, the newstring need not be constant: it can refer to all or part of what is matched by the regexp. ‘\&’ in newstring stands for the entire match being replaced. ‘\d’ in newstring, where d is a digit, stands for whatever matched the dth parenthesized grouping in regexp. (This is called a “back reference.”) ‘\#’ refers to the count of replacements already made in this command, as a decimal number. In the first replacement, ‘\#’ stands for ‘0’; in the second, for ‘1’; and so on. For example,

M-x replace-regexp <RET> c[ad]+r <RET> \&-safe <RET>

replaces (for example) ‘cadr’ with ‘cadr-safe’ and ‘cddr’ with ‘cddr-safe’.

Wednesday, February 9, 2011

mod_proxy in ubuntu

In order to get mod_proxy running in ubuntu I had to:
  • ln -s /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled/proxy.conf
  • ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled/proxy.load
  • ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled/proxy_http.load
Then in my conf file (sites-enabled/my-site) I added between the VirtualHost tag

<proxy>
Order deny,allow
Allow from all
</proxy>

<location /pickup >
ProxyPass http://qa-ox3-datamart-xv-01.xv.dc.openx.org/pickup/
ProxyPassReverse http://qa-ox3-datamart-xv-01.xv.dc.openx.org/pickup/
</location>

Delete a remote branch in git

git push origin :branchname