Lightweight API for localization of images, icons, etc.
Chusslove Illich
caslav.ilic at gmx.net
Tue Jan 15 00:21:27 GMT 2008
I thought it would be nice to have a simple system (in 4.1) for localizing
general external resources in KDE apps -- splash screens, icons, sounds,
whatever is provided as a non-text file.
The solution would proceed as follows. For a resource file installed by the
application at $SOMEDIR/foo.bar, a localized counterpart (for any language
that cares to supply one), would be installed in $SOMEDIR/l10n/LL/foo.bar,
where LL is the language code. If the app scoops the original foo.bar
through one of standard mechanisms, e.g. KStandardDirs::locate(), these
localized alternatives would automatically be returned when existing and
appropriate. If the application assembles the path itself, then a wrap of
i18nFilePath(finalPath) would do the same lookup (these manual wraps would
be added only on explicit translator request).
I've opted for the $SOMEDIR/l10n/LL/foo.bar approach, instead of e.g.
$SOMEDIR/LL.foo.bar or $SOMEDIR/LL/foo.bar, because it will produce the
least clutter in directories, both packed and installed. It makes it easy
for a maintainer of an extragear app to collect any such localized resources
for his app from l10n-kde4/LL/data language directories, and add simple
INSTALL(DIRECTORY l10n ...) rules in his CMakeLists.txt files which install
the original resources (even if that).
The attached patch implements the i18nFilePath() and it's underlying
KLocale::localizedFilePath() worker. It also adds i18nFilePath() at only two
places in KStandardDirs and one in KIconTheme, by which all the well-behaved
resource lookups and icons become localizable without further intervention.
The total code is shorter than its doc-comments :)
(Something half-way like this already exists in form of
KLocale::langLookup(), but is used only by help center and kio help, isn't
exactly equivalent to the above proposal, and crosses into terrain of
KStandardDirs as a special case. So in the patch I decided deprecating it.)
--
Chusslove Illich (Часлав Илић)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kdelibs-locfpath-01.diff
Type: text/x-diff
Size: 5658 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080115/830f9ac9/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080115/830f9ac9/attachment.sig>
More information about the kde-core-devel
mailing list