Bug 20575 - No localization in WebKitGtk
Summary: No localization in WebKitGtk
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Christian Dywan
URL:
Keywords: Gtk
Depends on:
Blocks:
 
Reported: 2008-08-30 12:33 PDT by Andreas Büsching
Modified: 2009-04-06 12:40 PDT (History)
4 users (show)

See Also:


Attachments
Implemented l10n support for WebKitGTK+. (40.71 KB, patch)
2009-04-01 07:29 PDT, Gustavo Noronha (kov)
no flags Details | Formatted Diff | Diff
Implemented l10n support for WebKitGTK+. (42.12 KB, patch)
2009-04-06 10:44 PDT, Gustavo Noronha (kov)
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Büsching 2008-08-30 12:33:31 PDT
At least the GObject properties in WebKit/gtk/webkit/webkitwebsettings.cpp do not have any translations. 

For example the browser midori uses these properties directly as configuration item in the preferences dialog, which leads to missing translations for these options.
Comment 1 Christian Dywan 2008-08-31 05:04:46 PDT
To be exact WebKit provides context menu which have user visible strings in the context menu and there are the GObject nicks and blurbs. Both should be localized with gettext usually, but WebKitGtk doesn't currently do this.

Wrt Midori, a few WebSettings strings are currently exposed in the user interface. The phenomenon is that due to missing localization in WebKit those are, obviously, not localized.
Comment 2 Mark Rowe (bdash) 2008-08-31 19:37:15 PDT
Localizing context menus make sense to me, but I'm not convinced that it makes sense for descriptions of GObject properties to be localized.  
Comment 3 Richard Hult 2008-09-22 07:05:03 PDT
The main reason gobject property nicks/blurbs are translated in GTK+ itself is for UI builders. I wouldn't recommend using them directly in any other type of UI really.
Comment 4 Gustavo Noronha (kov) 2009-04-01 07:29:38 PDT
Created attachment 29159 [details]
Implemented l10n support for WebKitGTK+.

 ChangeLog                                          |   11 +
 GNUmakefile.am                                     |  196 ++++++++++++-
 WebCore/ChangeLog                                  |   12 +
 WebCore/platform/gtk/FileChooserGtk.cpp            |    1 -
 WebCore/platform/gtk/LocalizedStringsGtk.cpp       |    2 +-
 WebKit/gtk/ChangeLog                               |   21 ++
 WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp      |    2 +-
 WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp |    2 +-
 WebKit/gtk/po/POTFILES                             |    6 +
 WebKit/gtk/po/README                               |   11 +
 WebKit/gtk/po/pt_BR.po                             |  322 +++++++++++++++++++
 WebKit/gtk/po/webkit.pot                           |  323 ++++++++++++++++++++
 WebKit/gtk/webkit/webkitdownload.cpp               |   29 +-
 WebKit/gtk/webkit/webkitprivate.cpp                |    4 +
 WebKit/gtk/webkit/webkitwebframe.cpp               |   13 +-
 configure.ac                                       |    7 +-
 16 files changed, 931 insertions(+), 31 deletions(-)
Comment 5 Christian Dywan 2009-04-01 12:37:39 PDT
(In reply to comment #4)
> Created an attachment (id=29159) [review]
> Implemented l10n support for WebKitGTK+.
> 
>  ChangeLog                                          |   11 +
>  GNUmakefile.am                                     |  196 ++++++++++++-
>  WebCore/ChangeLog                                  |   12 +
>  WebCore/platform/gtk/FileChooserGtk.cpp            |    1 -
>  WebCore/platform/gtk/LocalizedStringsGtk.cpp       |    2 +-
>  WebKit/gtk/ChangeLog                               |   21 ++
>  WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp      |    2 +-
>  WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp |    2 +-
>  WebKit/gtk/po/POTFILES                             |    6 +
>  WebKit/gtk/po/README                               |   11 +
>  WebKit/gtk/po/pt_BR.po                             |  322 +++++++++++++++++++
>  WebKit/gtk/po/webkit.pot                           |  323 ++++++++++++++++++++
>  WebKit/gtk/webkit/webkitdownload.cpp               |   29 +-
>  WebKit/gtk/webkit/webkitprivate.cpp                |    4 +
>  WebKit/gtk/webkit/webkitwebframe.cpp               |   13 +-
>  configure.ac                                       |    7 +-
>  16 files changed, 931 insertions(+), 31 deletions(-)

This is looking nice, much better than the half-finished patch I had on my disk anyway :)

I am not really skilled with bashscript so I can't judge it. The rest looks good. While you were at fixing includes you might have wanted to remove superfluous glib.h and glib/glib-object.h before gtk/gtk.h but that's not important for the matter of the feature.

And one thing I'd like to ask you is, please commit pt_BR.po separately from the other changes.

I will donate a de.po if we get this in.
Comment 6 Holger Freyther 2009-04-02 23:20:49 PDT
Have you considered using AM_GLIB_GNU_GETTEXT?
Comment 7 Jan Alonzo 2009-04-04 19:29:52 PDT
Comment on attachment 29159 [details]
Implemented l10n support for WebKitGTK+.

> diff --git a/GNUmakefile.am b/GNUmakefile.am
> index 13cf5ee..f659da8 100644
> --- a/GNUmakefile.am
> +++ b/GNUmakefile.am
> @@ -49,6 +49,103 @@ IDL_BINDINGS :=
>  
>  TEST_PROGS :=
>  
> +# Gettext stuff
> +
> +DOMAIN=$(GETTEXT_PACKAGE)
> +MSGFMT = $(shell which msgfmt)
> +XGETTEXT = $(shell which xgettext)
> +MSGMERGE = $(shell which msgmerge)
> +MSGMERGE_UPDATE = $(MSGMERGE) --update
> +
> +POFILES = $(shell ls $(srcdir)/WebKit/gtk/po/*.po)
> +MOFILES = $(shell echo $(POFILES) | sed "s,^$(srcdir)/,,g" | sed 's/\.po/.mo/g')
> +
> +.po.mo:
> +	test -d WebKit/gtk/po/ || mkdir -p WebKit/gtk/po/
> +	@echo "$(MSGFMT) -c -o $@ $<"; \
> +	$(MSGFMT) -c -o $@ $<
> +
> +# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
> +# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
> +# we don't want to bother translators with empty POT files). We assume that
> +# LINGUAS is empty in this case, i.e. $(POFILES) and $(MOFILES) are empty.
> +# In this case, stamp-po is a nop (i.e. a phony target).
> +
> +# stamp-po is a timestamp denoting the last time at which the CATALOGS have
> +# been loosely updated. Its purpose is that when a developer or translator
> +# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
> +# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
> +# invocations of "make" will do nothing. This timestamp would not be necessary
> +# if updating the $(CATALOGS) would always touch them; however, the rule for
> +# $(POFILES) has been designed to not touch files that don't need to be
> +# changed.
> +stamp-po: $(srcdir)/WebKit/gtk/po/$(DOMAIN).pot $(MOFILES)
> +	test ! -f $(srcdir)/WebKit/gtk/po/$(DOMAIN).pot || \
> +	  test -z "$(MOFILES)" || $(MAKE) $(MOFILES)
> +	@test ! -f $(srcdir)/WebKit/gtk/po/$(DOMAIN).pot || { \
> +	  echo "touch stamp-po" && \
> +	  echo timestamp > stamp-poT && \
> +	  mv stamp-poT stamp-po; \
> +	}
> +
> +# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
> +# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
> +$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/WebKit/gtk/po/POTFILES
> +	package_gnu=''; \
> +	if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
> +	  msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
> +	else \
> +	  msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
> +	fi; \
> +	case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
> +	  '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
> +	    $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(srcdir) \
> +	      --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
> +	      --files-from=$(srcdir)/WebKit/gtk/po/POTFILES \
> +	      --copyright-holder='$(COPYRIGHT_HOLDER)' \
> +	      --msgid-bugs-address="$$msgid_bugs_address" \
> +	      --keyword=_ --keyword=N_ -o $(srcdir)/WebKit/gtk/po/webkit.pot \
> +	    ;; \
> +	  *) \
> +	    $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(srcdir) \
> +	      --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
> +	      --files-from=$(srcdir)/WebKit/gtk/po/POTFILES \
> +	      --copyright-holder='$(COPYRIGHT_HOLDER)' \
> +	      --package-name="$${package_gnu}@PACKAGE@" \
> +	      --package-version='@VERSION@' \
> +	      --msgid-bugs-address="$$msgid_bugs_address" \
> +	      --keyword=_ --keyword=N_ -o $(srcdir)/WebKit/gtk/po/webkit.pot \
> +	    ;; \
> +	esac
> +
> +# This rule has no dependencies: we don't need to update $(DOMAIN).pot at
> +# every "make" invocation, only create it when it is missing.
> +# Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
> +$(srcdir)/WebKit/gtk/po/$(DOMAIN).pot:
> +	$(MAKE) $(DOMAIN).pot-update
> +
> +# This target rebuilds a PO file if $(DOMAIN).pot has changed.
> +# Note that a PO file is not touched if it doesn't need to be changed.
> +$(POFILES): $(srcdir)/WebKit/gtk/po/$(DOMAIN).pot
> +	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
> +	if test -f "$(srcdir)/WebKit/gtk/po/$${lang}.po"; then \
> +	  test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir)/WebKit/gtk/po && "; \
> +	  echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
> +	  cd $(srcdir)/WebKit/gtk/po && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
> +	else \
> +	  $(MAKE) $${lang}.po-create; \
> +	fi
> +
> +update-po: GNUmakefile
> +	$(MAKE) $(DOMAIN).pot-update
> +	$(MAKE) $(POFILES)
> +	$(MAKE) $(MOFILES)
> +
> +.nop.po-create:
> +	@lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
> +	echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
> +	exit 1
> +

Can we add all of the above in WebKit/gtk/po/GNUmakefile.am and include it in the top-level GNUMakefile?
You need to declare POFILES, MOFILES, etc.. here though and define them in po/GNUmakefile.am.

Assuming you've tested this, looks good to me.
Comment 8 Gustavo Noronha (kov) 2009-04-06 08:43:48 PDT
(In reply to comment #6)
> Have you considered using AM_GLIB_GNU_GETTEXT?
> 

Yes. I also tried using AM_GNU_GETTEXT itself. I have not been able to use any of them without making our build recursive. Too much is assumed about the location of the po directory, the presence of various files, and about the overall build process by those macros, so I end up giving up on them and "porting" the rules manually.
Comment 9 Gustavo Noronha (kov) 2009-04-06 10:44:15 PDT
Created attachment 29279 [details]
Implemented l10n support for WebKitGTK+.

 ChangeLog                                          |   11 +
 GNUmakefile.am                                     |   22 ++-
 WebCore/ChangeLog                                  |   12 +
 WebCore/platform/gtk/FileChooserGtk.cpp            |    1 -
 WebCore/platform/gtk/LocalizedStringsGtk.cpp       |    2 +-
 WebKit/gtk/ChangeLog                               |   21 ++
 WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp      |    2 +-
 WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp |    2 +-
 WebKit/gtk/po/ChangeLog                            |    5 +
 WebKit/gtk/po/GNUmakefile.am                       |  210 +++++++++++++
 WebKit/gtk/po/POTFILES                             |    6 +
 WebKit/gtk/po/README                               |   11 +
 WebKit/gtk/po/pt_BR.po                             |  321 ++++++++++++++++++++
 WebKit/gtk/po/webkit.pot                           |  319 +++++++++++++++++++
 WebKit/gtk/webkit/webkitdownload.cpp               |   29 +-
 WebKit/gtk/webkit/webkitprivate.cpp                |    4 +
 WebKit/gtk/webkit/webkitwebframe.cpp               |   13 +-
 configure.ac                                       |    7 +-
 18 files changed, 969 insertions(+), 29 deletions(-)
Comment 10 Gustavo Noronha (kov) 2009-04-06 10:45:35 PDT
Comment on attachment 29279 [details]
Implemented l10n support for WebKitGTK+.

Addressed comments by Xan. I will commit my pt_BR.po separately as requested by Christian Dywan, I am keeping it for now for simplicity.

I have tested this with make dist check, and tested that make update-po does the right thing, too.
Comment 11 Sam Weinig 2009-04-06 11:46:01 PDT
Comment on attachment 29279 [details]
Implemented l10n support for WebKitGTK+.

rs=me
Comment 12 Gustavo Noronha (kov) 2009-04-06 11:47:37 PDT
(In reply to comment #10)
> (From update of attachment 29279 [details] [review])
> Addressed comments by Xan. I will commit my pt_BR.po separately as requested by

s/Xan/Jan/ here =)

Comment 13 Gustavo Noronha (kov) 2009-04-06 12:40:15 PDT
Landed as r42251 and r42252.