[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Fwd from Michael Bramer: RFD: translated description with dpkg



¿Alguien le está diciendo a estos chiucos cómo van las cosas en
español? Si nadie lo ha hecho, puedo encargarme...

Saludos,

      Jesus.

--- Begin Message ---
Hello all


Martin and I make some cogitations about the translated package
description in the package management. 

Read it and send comments, improvments, questions etc. 



The past:
 
 The debian project support only english descriptions. Somebodys
 translate parts of the descriptions outside of the debian project
 (es, jp, maybe more) and use this local or only on web pages.


The presence:

 Now we habe a 'Debian Description Translation Project' (ddtp), and
 the translators of this project have already translated some
 description. 

 some stats:
  de    31%
  pt_BR  8%
  ja     4%
  fr     3%
  (and some more languages at the beginning)

 With a hack, this translated description are now also suitable. Daily
 the server make translated Packages files on gluck and you can use
 this with apt-cache [search|show] and without other sources in apt's
 sources.list also with all apt based tools (dselect, gnome-apt, etc.)

 For more information, see the gifs, guides, faq's etc. on
 http://auric.debian.org/~grisu/ddts/


The future:

 We need real support for translations in dpkg, apt and other package
 managemnt tools. 

 see this proposal for one possible strategy.




		   TRANSLATING SUPPORT WITH GETTEXT
		   --------------------------------

      (from Michael Bramer <grisu@debian.org> and
       Martin Quinson <Martin.Quinson@ens-lyon.fr>)


The ddts have all translated package descriptions in a central
database and the ddts can provide any form of this descriptions.

Principally we can go two ways:
 - decentral translation
   With this, the translated description is stored in the deb package
   (maybe the control file) and dinstall extracts the translated
   description and produces translated package files. Also dpkg can
   use this translation, store it in some files (/var/lib/dpkg/*) and
   use it with dpkg -l etc.

   This has some heavy cons:
    - this way will by very slow. We will never get all translation in
      all packages. The maintainer will collect some translation
      before make a new upload. All packages must build from the build
      servers. This all delay the process. Every selling error
      generates uploades, builds, ...
    - No package maintainer can't speaking all languages. He can't
      check the translation, he can't improve the translation, he only
      add blindly the translation in the package source. This is 
      unneeded work for the maintainer.
    - The deb package is growing with the number of translations
      added.
    - we must patch dpkg, dinstall, apt in a havy way. We need maybe
      more controll files, or new descriptions files. With this we
      must teach all maintainers and move all >800 Maintainer to the
      new system. 
    - We don't have the framework or ideas for this now
    - unneeded translation on the system.
      Normal a system have only one (or maybe some) system admins (aka
      root's). The all speach the same languages (or only some). A
      german root user don't need japanese package description. He
      only need the german and (as fallback) the english description. 
    - if you put all translations in the same file, you'll have
      encoding problems
    - This method does not help you to track changes to original, and
      see when the translations have to be updated.

    We don't see real pros of this. 

 - the central translation
   With this, the translated description is not stored in the package
   file. All translation are stored in one file or in one deb package. 
   You can download the file/package (one per languages) and you have
   the needed translation on your system.

   You don't have all the cons of the decentral way:
    - No delay. The way from the translator to this file/package is
      very fast and direct. (no detouring)
    - We have the same deb package, no change is need.
    - We must not reupload all >4000 Packages to include the
      translation
    - we must not patch dinstall. the patch in dpkg and apt are touch
      only the output process. only some lines in source code. 
    - on the system you have only the used translations. 
    - if some translator fix a japanese spelling, you don't need a
      update.

We propose the central translation for dpkg and co. But how should this
work?

The ddts can provide po files with all translated packages and build
own deb packages with this file. I put the first po files on
http://auric.debian.org/~grisu/ddts/po/.

But you don't believe, that the dpkg source code changes are small?
Show the attachment. Martin Quinson <Martin.Quinson@ens-lyon.fr> have
patch the dpkg source code and now we have a dpkg with translated
description support. This is only a -9/+30 patch! you see the patch is
pretty small.

If the translated descriptions are store in 
/usr/share/locale/<lang>/LC_MESSAGES/dpkg-desc.mo and you have patch all
outputs in dpkg and dpkg.

If you patch apt like this, you should have translated description on
all apt based programs (gnome-apt, deity, ...)


Maybe somebody will now say: "But some users don't get all packages
from debian project, there are some privat deb archives, Progreny,
..."

This is not a real problem. We can collect more po files in one dir
(maybe /var/lib/dpkg/dpkg-desc/<lang>/) and generate one dpkg-desc.mo
file from this *po-files. 


Gruss
Grisu
-- 
Michael Bramer  -  a Debian Linux Developer http://www.debian.org
PGP: finger grisu@db.debian.org  -- Linux Sysadmin   -- Use Debian Linux
"It's a modern Unix! It's stable, superior, enriching! It's gonna get
 creamed." -- Richard Brandt, Upside
Index: dselect/pkginfo.cc
===================================================================
RCS file: /cvs/dpkg/dpkg/dselect/pkginfo.cc,v
retrieving revision 1.6
diff -u -r1.6 pkginfo.cc
--- dselect/pkginfo.cc	2001/07/16 13:40:22	1.6
+++ dselect/pkginfo.cc	2001/08/28 14:25:49
@@ -106,7 +106,7 @@
     whatinfovb(_("description of "));
     whatinfovb(table[cursorline]->pkg->name);
 
-    const char *m= table[cursorline]->pkg->available.description;
+    const char *m= GETTEXT_DESC(table[cursorline]->pkg->available.description);
     if (!m || !*m) m= _("no description available.");
     const char *p= strchr(m,'\n');
     int l= p ? (int)(p-m) : strlen(m);
@@ -132,6 +132,7 @@
     whatinfovb(_("installed control info for "));
     whatinfovb(table[cursorline]->pkg->name);
     varbuf vb;
+    varbufdol10n(&vb);
     varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->installed);
     vb.terminate();
     if (debug)
@@ -148,6 +149,7 @@
     whatinfovb(_("available version of control info for "));
     whatinfovb(table[cursorline]->pkg->name);
     varbuf vb;
+    varbufdol10n(&vb);
     varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->available);
     vb.terminate();
     if (debug)
Index: dselect/pkglist.cc
===================================================================
RCS file: /cvs/dpkg/dpkg/dselect/pkglist.cc,v
retrieving revision 1.13
diff -u -r1.13 pkglist.cc
--- dselect/pkglist.cc	2001/07/16 15:29:03	1.13
+++ dselect/pkglist.cc	2001/08/28 14:25:49
@@ -533,7 +533,7 @@
     return 1;
 
   if (searchdescr) {
-    const char* descr = table[index]->pkg->available.description;
+    const char* descr = GETTEXT_DESC(table[index]->pkg->available.description);
     if (!descr || !*descr) return 0;
 
     if (regexec(&searchfsm, descr, 0, NULL, 0)==0)
Index: dselect/pkgtop.cc
===================================================================
RCS file: /cvs/dpkg/dpkg/dselect/pkgtop.cc,v
retrieving revision 1.12
diff -u -r1.12 pkgtop.cc
--- dselect/pkgtop.cc	2001/07/16 13:40:22	1.12
+++ dselect/pkgtop.cc	2001/08/28 14:25:50
@@ -219,7 +219,7 @@
     }
 
     i= description_width;
-    p= info->description ? info->description : "";
+    p= (info->description ? GETTEXT_DESC(info->description) : "");
     while (i>0 && *p && *p != '\n') { waddnstr(listpad,p,1); i--; p++; }
       
   } else {
Index: include/dpkg-db.h
===================================================================
RCS file: /cvs/dpkg/dpkg/include/dpkg-db.h,v
retrieving revision 1.21
diff -u -r1.21 dpkg-db.h
--- include/dpkg-db.h	2001/04/23 08:59:02	1.21
+++ include/dpkg-db.h	2001/08/28 14:25:50
@@ -236,6 +236,7 @@
 int varbufprintf(struct varbuf *v, const char *fmt, ...) PRINTFFORMAT(2,3);
 int varbufvprintf(struct varbuf *v, const char *fmt, va_list va);
 void varbufinit(struct varbuf *v);
+void varbufdol10n(struct varbuf *v);
 void varbufreset(struct varbuf *v);
 void varbufextend(struct varbuf *v);
 void varbuffree(struct varbuf *v);
@@ -258,6 +259,7 @@
  */
 struct varbuf {
   size_t used, size;
+  int l10n; /* true if we should translate this varbuf */
   char *buf;
 
 #ifdef __cplusplus
Index: include/dpkg.h.in
===================================================================
RCS file: /cvs/dpkg/dpkg/include/dpkg.h.in,v
retrieving revision 1.28
diff -u -r1.28 dpkg.h.in
--- include/dpkg.h.in	2001/06/08 22:51:26	1.28
+++ include/dpkg.h.in	2001/08/28 14:25:51
@@ -149,6 +149,7 @@
 # include <libintl.h>
 # define _(Text) gettext (Text)
 # define N_(Text) Text
+# define GETTEXT_DESC(Text) dgettext("dpkg-desc",Text)
 #else
 # undef bindtextdomain
 # define bindtextdomain(Domain, Directory) /* empty */
@@ -157,6 +158,7 @@
 # define _(Text) Text
 # define N_(Text) Text
 # define gettext(Text) Text
+# define GETTEXT_DESC(Text) Text
 #endif
 
 extern const char thisname[]; /* defined separately in each program */
Index: include/parsedump.h
===================================================================
RCS file: /cvs/dpkg/dpkg/include/parsedump.h,v
retrieving revision 1.1
diff -u -r1.1 parsedump.h
--- include/parsedump.h	2001/07/27 01:55:52	1.1
+++ include/parsedump.h	2001/08/28 14:25:51
@@ -53,7 +53,7 @@
                             const struct pkginfoperfile*, const struct fieldinfo*);
 fwritefunction w_name, w_charfield, w_priority, w_section, w_status, w_configversion;
 fwritefunction w_version, w_null, w_booleandefno, w_dependency, w_conffiles;
-fwritefunction w_filecharf;
+fwritefunction w_filecharf, w_i18n_charfield;
 
 struct fieldinfo {
   const char *name;
Index: lib/dbmodify.c
===================================================================
RCS file: /cvs/dpkg/dpkg/lib/dbmodify.c,v
retrieving revision 1.12
diff -u -r1.12 dbmodify.c
--- lib/dbmodify.c	2001/06/08 22:51:26	1.12
+++ lib/dbmodify.c	2001/08/28 14:25:52
@@ -179,7 +179,7 @@
 
   if (cstatus >= msdbrw_write) {
     createimptmp();
-    uvb.used= 0;
+    uvb.used= uvb.l10n= 0;
     uvb.size= 10240;
     uvb.buf= m_malloc(uvb.size);
   }
Index: lib/dump.c
===================================================================
RCS file: /cvs/dpkg/dpkg/lib/dump.c,v
retrieving revision 1.6
diff -u -r1.6 dump.c
--- lib/dump.c	2001/05/07 21:06:16	1.6
+++ lib/dump.c	2001/08/28 14:25:52
@@ -88,6 +88,16 @@
   varbufaddc(vb,'\n');
 }
 
+void w_i18n_charfield(struct varbuf *vb,
+                 const struct pkginfo *pigp, const struct pkginfoperfile *pifp,
+                 const struct fieldinfo *fip) {
+  const char *value= pifp->valid ? PKGPFIELD(pifp,fip->integer,const char*) : NULL;
+  if (!value || !*value) return;
+  varbufaddstr(vb,fip->name); varbufaddstr(vb, ": "); 
+  varbufaddstr(vb, vb->l10n ? GETTEXT_DESC(value) : value);  
+  varbufaddc(vb,'\n');
+}
+
 void w_filecharf(struct varbuf *vb,
                  const struct pkginfo *pigp, const struct pkginfoperfile *pifp,
                  const struct fieldinfo *fip) {
@@ -208,7 +218,7 @@
   if (pifp->valid) {
     for (afp= pifp->arbs; afp; afp= afp->next) {
       varbufaddstr(vb,afp->name); varbufaddstr(vb,": ");
-      varbufaddstr(vb,afp->value); varbufaddc(vb,'\n');
+      varbufaddstr(vb,vb->l10n ? GETTEXT_DESC(afp->value) : afp->value); varbufaddc(vb,'\n');
     }
   }
 }
@@ -218,6 +228,7 @@
   struct varbuf vb;
 
   varbufinit(&vb);
+  varbufdol10n(&vb);
   varbufrecord(&vb,pigp,pifp);
   varbufaddc(&vb,'\0');
   if (fputs(vb.buf,file) < 0)
Index: lib/parse.c
===================================================================
RCS file: /cvs/dpkg/dpkg/lib/parse.c,v
retrieving revision 1.20
diff -u -r1.20 parse.c
--- lib/parse.c	2001/05/02 04:08:31	1.20
+++ lib/parse.c	2001/08/28 14:25:52
@@ -68,7 +68,7 @@
   { "Size",             f_filecharf,       w_filecharf,      FILEFOFF(size)           },
   { "MD5sum",           f_filecharf,       w_filecharf,      FILEFOFF(md5sum)         },
   { "MSDOS-Filename",   f_filecharf,       w_filecharf,      FILEFOFF(msdosname)      },
-  { "Description",      f_charfield,       w_charfield,      PKGIFPOFF(description)   },
+  { "Description",      f_charfield,       w_i18n_charfield, PKGIFPOFF(description)   },
   /* Note that aliases are added to the nicknames table in parsehelp.c. */
   {  NULL   /* sentinel - tells code that list is ended */                               }
 };
Index: lib/varbuf.c
===================================================================
RCS file: /cvs/dpkg/dpkg/lib/varbuf.c,v
retrieving revision 1.11
diff -u -r1.11 varbuf.c
--- lib/varbuf.c	2001/05/01 05:35:00	1.11
+++ lib/varbuf.c	2001/08/28 14:25:53
@@ -88,12 +88,16 @@
 
 void varbufinit(struct varbuf *v) {
   /* NB: dbmodify.c does its own init to get a big buffer */
-  v->size= v->used= 0;
+  v->size= v->used=v->l10n= 0;
   v->buf= NULL;
 }
 
 void varbufreset(struct varbuf *v) {
   v->used= 0;
+}
+
+void varbufdol10n(struct varbuf *v) {
+  v->l10n= 1;
 }
 
 void varbufextend(struct varbuf *v) {
Index: main/query.c
===================================================================
RCS file: /cvs/dpkg/dpkg/main/query.c,v
retrieving revision 1.8
diff -u -r1.8 query.c
--- main/query.c	2001/08/01 13:41:17	1.8
+++ main/query.c	2001/08/28 14:25:53
@@ -92,7 +92,7 @@
   const char *pdesc, *p;
   int l;
   
-  pdesc= pkg->installed.valid ? pkg->installed.description : 0;
+  pdesc= (pkg->installed.valid ? GETTEXT_DESC(pkg->installed.description) : 0);
   if (!pdesc) pdesc= _("(no description available)");
   p= strchr(pdesc,'\n');
   if (!p) p= pdesc+strlen(pdesc);

Attachment: pgpx67GMmrO6K.pgp
Description: PGP signature


--- End Message ---
-- 
Jesus M. Gonzalez Barahona                | Grupo de Sistemas y Comunicaciones
jgb@gsyc.escet.urjc.es / jgb@computer.org | ESCET, Universidad Rey Juan Carlos 
tel: +34 91 664 74 67                     | c/ Tulipan s/n
fax: +34 91 664 74 90                     | 28933 Mostoles, Spain

Reply to: