Monday, August 8, 2011

Setting 'git pull' to use --rebase for all branches

git config --global branch.autosetuprebase always

Thursday, June 30, 2011

Gettext and codesets. UTF-8 in particular

For the longest time, Japanese translations weren't working and kept returning ???? instead of the correct Japanese characters. A college finally found the solution:

bind_textdomain_codeset("messages", 'UTF-8');


where "messages" is the text domain that was bound with the textdomain command.

Stupidly difficult bug to tackle.

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’.