Faciliate translation workflow, look at TRANSLATE for details

Also three strings are marked untranslatable since they never
appear in the user interface and 'Unhandled settings value'
is reworded to 'Invalid configuration value'.
This commit is contained in:
Christian Dywan 2008-11-10 01:08:38 +01:00
parent 38c6ad5dad
commit 0bfb12f0b1
5 changed files with 49 additions and 62 deletions

View file

@ -4,13 +4,18 @@ This file is licensed under the terms of the expat license, see the file EXPAT.
If you want to translate Midori, you need a few preparations.
First enable localization file updates when building:
First create/ update the localization template:
./waf configure --enable-update-po && ./waf build
./waf build --update-po
Running this command again will also update all translations
as needed, according to changes in the template.
If you want to add a new language 'aa', create it like this:
msginit -l aa_CC -o aa.po -i midori.pot && sed -i 's/PACKAGE/midori/g' aa.po
cd po
msginit -l aa_CC -o aa.po -i midori.pot
sed -i 's/PACKAGE/midori/g' aa.po
To check your language 'aa' for errors, do this:

View file

@ -57,6 +57,10 @@ stock_items_init (void)
guint keyval;
gchar* fallback;
} FatStockItem;
GtkIconSource* icon_source;
GtkIconSet* icon_set;
GtkIconFactory* factory = gtk_icon_factory_new ();
gsize i;
static FatStockItem items[] =
{
@ -82,12 +86,7 @@ stock_items_init (void)
{ STOCK_WINDOW_NEW, N_("New _Window"), 0, 0, GTK_STOCK_ADD },
};
GtkIconSource* icon_source;
GtkIconSet* icon_set;
GtkIconFactory* factory = gtk_icon_factory_new ();
guint i;
for (i = 0; i < (guint)G_N_ELEMENTS (items); i++)
for (i = 0; i < G_N_ELEMENTS (items); i++)
{
icon_set = gtk_icon_set_new ();
icon_source = gtk_icon_source_new ();
@ -191,7 +190,7 @@ settings_new_from_file (const gchar* filename)
g_type_class_unref (enum_class);
}
else
g_warning (_("Unhandled settings value '%s'"), property);
g_warning (_("Invalid configuration value '%s'"), property);
}
return settings;
}
@ -208,6 +207,7 @@ settings_save_to_file (MidoriWebSettings* settings,
GParamSpec* pspec;
GType type;
const gchar* property;
gboolean saved;
key_file = g_key_file_new ();
class = G_OBJECT_GET_CLASS (settings);
@ -260,9 +260,9 @@ settings_save_to_file (MidoriWebSettings* settings,
enum_value->value_name);
}
else
g_warning (_("Unhandled settings value '%s'"), property);
g_warning (_("Invalid configuration value '%s'"), property);
}
gboolean saved = sokoke_key_file_save_to_file (key_file, filename, error);
saved = sokoke_key_file_save_to_file (key_file, filename, error);
g_key_file_free (key_file);
return saved;
}

View file

@ -79,9 +79,9 @@ midori_load_status_get_type (void)
if (type)
return type;
static const GEnumValue values[] = {
{ MIDORI_LOAD_PROVISIONAL, "MIDORI_LOAD_PROVISIONAL", N_("Load Provisional") },
{ MIDORI_LOAD_COMMITTED, "MIDORI_LOAD_COMMITTED", N_("Load Committed") },
{ MIDORI_LOAD_FINISHED, "MIDORI_LOAD_FINISHED", N_("Load Finished") },
{ MIDORI_LOAD_PROVISIONAL, "MIDORI_LOAD_PROVISIONAL", "Load Provisional" },
{ MIDORI_LOAD_COMMITTED, "MIDORI_LOAD_COMMITTED", "Load Committed" },
{ MIDORI_LOAD_FINISHED, "MIDORI_LOAD_FINISHED", "Load Finished" },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriLoadStatus", values);

View file

@ -1,34 +0,0 @@
#! /usr/bin/env python
# WAF build script for midori
# This file is licensed under the terms of the expat license, see the file EXPAT.
import Params
import pproc as subprocess
import os
APPNAME = 'midori'
if bld.env ()['INTLTOOL_UPDATE']:
os.chdir ('./po')
try:
try:
size_old = os.stat (APPNAME + '.pot').st_size
except:
size_old = 0
subprocess.call (['intltool-update', '--pot'])
size_new = os.stat (APPNAME + '.pot').st_size
if size_new <> size_old:
Params.pprint ('YELLOW', "Updated po template.")
try:
intltool_update = subprocess.Popen (['intltool-update', '-r'],
stderr=subprocess.PIPE)
intltool_update.wait ()
Params.pprint ('YELLOW', "Updated translations.")
except:
Params.pprint ('RED', "Failed to update translations.")
except:
Params.pprint ('RED', "Failed to generate po template.")
os.chdir ('..')
obj = bld.create_obj ('intltool_po')
obj.appname = APPNAME

42
wscript
View file

@ -50,16 +50,6 @@ def configure (conf):
nls = 'no'
conf.check_message_custom ('localization', 'support', nls)
if Params.g_options.enable_update_po:
conf.find_program ('intltool-update', var='INTLTOOL_UPDATE')
if conf.env['INTLTOOL_UPDATE']:
update_po = 'yes'
else:
update_po = 'not available'
else:
update_po = 'no'
conf.check_message_custom ('localization file', 'updates', update_po)
# We support building without intltool
# Therefore datadir may not have been defined
if not conf.is_defined ('DATADIR'):
@ -150,11 +140,12 @@ def set_options (opt):
opt.add_option ('--disable-sqlite', action='store_true', default=False,
help='Disables sqlite support', dest='disable_sqlite')
opt.add_option ('--enable-update-po', action='store_true', default=False,
help='Enables localization file updates', dest='enable_update_po')
opt.add_option ('--enable-api-docs', action='store_true', default=False,
help='Enables API documentation', dest='enable_api_docs')
opt.add_option ('--update-po', action='store_true', default=False,
help='Update localization files', dest='update_po')
def build (bld):
def mkdir (path):
if not os.access (path, os.F_OK):
@ -188,7 +179,9 @@ def build (bld):
install_files ('DOCDIR', '/midori/user/', blddir + '/docs/user/midori.html')
if bld.env ()['INTLTOOL']:
bld.add_subdirs ('po')
obj = bld.create_obj ('intltool_po')
obj.podir = 'po'
obj.appname = APPNAME
if bld.env ()['GTKDOC_SCAN'] and Params.g_commands['build']:
bld.add_subdirs ('docs/api')
@ -234,3 +227,26 @@ def shutdown ():
if not icon_cache_updated:
Params.pprint ('YELLOW', "Icon cache not updated. After install, run this:")
Params.pprint ('YELLOW', "gtk-update-icon-cache -q -f -t %s" % dir)
elif Params.g_options.update_po:
os.chdir('./po')
try:
try:
size_old = os.stat (APPNAME + '.pot').st_size
except:
size_old = 0
subprocess.call (['intltool-update', '--pot'])
size_new = os.stat (APPNAME + '.pot').st_size
if size_new <> size_old:
Params.pprint ('YELLOW', "Updated po template.")
try:
intltool_update = subprocess.Popen (['intltool-update', '-r'],
stderr=subprocess.PIPE)
intltool_update.wait ()
Params.pprint ('YELLOW', "Updated translations.")
except:
Params.pprint ('RED', "Failed to update translations.")
except:
Params.pprint ('RED', "Failed to generate po template.")
Params.pprint ('RED', "Make sure intltool is installed.")
os.chdir ('..')