1 Localization
Izzy edited this page 4 years ago


With v2.4 of HyperSQL, localization support was added. As gettext is the most supported system for these things, this system was used here.

Setting your locale

By default, HyperSQL should automatically detect your locale and use it – as long as your system is properly set up. If that fails for some reason, or you want to use a different language, you can force the program to use a specific locale - e.g.:

LANG=de_DE ./HyperSQL.py my_project

Or to tell the script to use its native settings (which is English):

LANG= ./HyperSQL.py my_project

Keep in mind, that there are fallbacks configured. Say you are living in Switzerland, and your language is German, your systems language (at least under *NIX) is probably set to LANG=de_CH. Currently, this is not directly supported by HyperSQL – though there is de_DE (German_Germany), which you would understand fine. Thanks to a symbolic link from de_DE to de, HyperSQL would still use German. But if you really want your Swiss German supported – read on to the next section, and go to create your de_CH support! If you send back your work to the project, it will be included with one of the next releases – of course with credits to you.

But if you're living in the French part of Switzerland, having LANG=fr_CH, you must live with HyperSQL falling back to English – until you created some French .po files for either fr_CH, or for fr_FR plus a symlink to fr.

Create missing translations

If your language seems not to be supported, you may first want to check the available translations: list up all directories below lang/ for this. If you find something suitable, and you are running a *NIX system supporting symbolic links, you can simply create a suitable link - so if you think your Afrikaans is almost English, ln -s en_US af would do the job (I know, this is a stupid example, as English would be the fallback either). If you find nothing suitable, you may have to create it yourself.

This is not a difficult task, and can be established easily even by non-programmers. With poedit, there's an editor available making this job quite simple. The only "handicap" so far is that poedit always scans all subdirectories – which means, when you want to edit the translations of the main application, it would also read the strings from all modules.

So if you are using poedit, this is the recommended way to create your language files:

  1. below the lang directory, create a directory for your language. It must be named in the scheme <language>[_<LOCATION>], where <language> is the two-letter ISO-639 language code (e.g. en for English or fr for French), and <LOCATION> the upper-case two-letter ISO-3166-1 country code (e.g. UK for the United Kingdom, or FR for France). The country part is optional.
  2. below that directory, create another one for the translation files. This must be named LC_MESSAGES. So for French, you should have created the directory lang/fr_FR/LC_MESSAGES by now.
  3. start poedit. From the File menu, select to create a new file from a POT catalog. Navigate to the lang/pot/ directory, and chose the first .pot file from here. poedit will now ask for a name and location to store the resulting file: navigate to your language directory (in our example, lang/fr_FR/LC_MESSAGES/) and set the name to the same as the *.pot file has been - except for the extension left to .po, as poedit suggested.
  4. edit the translations, and save the file when you are done
  5. continue from step 3 with the next .pot file, until you've processed them all

Once you are done and successfully created your translations, and they work to your convenience, please do not forget to send them back to the project (e.g. make it a pull request – or, if you're unfamiliar with Git and Github, create a new ticket and attach the files), so others may use them as well! Best way to do so is to simply tar/zip up the <your_LANG> directory, so you only have one file to attach.

Keep your translations up-to-date

With a new version, new phrases may have been added. poedit allows you to synchronize your .po file with a .pot file to check for those: If there are some new phrases, you will be told so – and can add the corresponding translations. Also, if some phrases have been removed, your .po file will be cleaned up.

The corresponding .pot files are to be found in the lang/pot/ subdirectory of the project, as mentioned before. This directory also holds a shell script named makepot to create them – just in case you want to make sure they are really up-to-date.