mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Conversion to gettext to allow localization
This is just the first step - convert the string literals, try to catch all the places where this isn't possible and the program needs to convert string constants at runtime (those are the N_ macros). Add a very rough first German localization so I can at least test what I have done. Seriously, I have never used a localized OS, so I am certain that I have many of the 'standard' translations wrong. Someone please take over :-) Major issues with this: - right now it hardcodes the search path for the message catalog to be ./locale - that's of course bogus, but it works well while doing initial testing. Once the tooling support is there we just should use the OS default. - even though de_DE defaults to ISO-8859-15 (or ISO-8859-1 - the internets can't seem to agree) I went with UTF-8 as that is what Gtk appears to want to use internally. ISO-8859-15 encoded .mo files create funny looking artefacts instead of Umlaute. - no support at all in the Makefile - I was hoping someone with more experience in how to best set this up would contribute a good set of Makefile rules - likely this will help fix the first issue in that it will also install the .mo file(s) in the correct place(s) For now simply run msgfmt -c -o subsurface.mo deutsch.po to create the subsurface.mo file and then move it to ./locale/de_DE.UTF-8/LC_MESSAGES/subsurface.mo If you make changes to the sources and need to add new strings to be translated, this is what seems to work (again, should be tooled through the Makefile): xgettext -o subsurface-new.pot -s -k_ -kN_ --add-comments="++GETTEXT" *.c msgmerge -s -U po/deutsch.po subsurface-new.pot If you do this PLEASE do one commit that just has the new msgid as changes in line numbers create a TON of diff-noise. Do changes to translations in a SEPARATE commit. - no testing at all on Windows or Mac It builds on Windows :-) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a2afe41280
commit
99846da77f
16 changed files with 1255 additions and 250 deletions
22
main.c
22
main.c
|
|
@ -1,8 +1,11 @@
|
|||
/* main.c */
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <libintl.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "dive.h"
|
||||
#include "divelist.h"
|
||||
|
|
@ -29,17 +32,19 @@ static int sortfn(const void *_a, const void *_b)
|
|||
|
||||
const char *weekday(int wday)
|
||||
{
|
||||
static const char wday_array[7][4] = {
|
||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
||||
static const char wday_array[7][7] = {
|
||||
/*++GETTEXT: these are three letter days - we allow up to six code bytes */
|
||||
N_("Sun"), N_("Mon"), N_("Tue"), N_("Wed"), N_("Thu"), N_("Fri"), N_("Sat")
|
||||
};
|
||||
return wday_array[wday];
|
||||
}
|
||||
|
||||
const char *monthname(int mon)
|
||||
{
|
||||
static const char month_array[12][4] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
||||
static const char month_array[12][7] = {
|
||||
/*++GETTEXT: these are three letter months - we allow up to six code bytes*/
|
||||
N_("Jan"), N_("Feb"), N_("Mar"), N_("Apr"), N_("May"), N_("Jun"),
|
||||
N_("Jul"), N_("Aug"), N_("Sep"), N_("Oct"), N_("Nov"), N_("Dec"),
|
||||
};
|
||||
return month_array[mon];
|
||||
}
|
||||
|
|
@ -221,6 +226,13 @@ int main(int argc, char **argv)
|
|||
int i;
|
||||
gboolean no_filenames = TRUE;
|
||||
|
||||
/* set up l18n - the search directory needs to change
|
||||
* so that it uses the correct system directory when
|
||||
* subsurface isn't run from the local directory */
|
||||
setlocale( LC_ALL, "" );
|
||||
bindtextdomain("subsurface", "./locale");
|
||||
bind_textdomain_codeset("subsurface", "utf-8");
|
||||
textdomain("subsurface");
|
||||
output_units = SI_units;
|
||||
|
||||
subsurface_command_line_init(&argc, &argv);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue