Просмотр исходного кода

Add gettext plurals infrastructure support

Guillem Jover лет назад: 16
Родитель
Сommit
4509efdc14
5 измененных файлов с 12 добавлено и 4 удалено
  1. 1 0
      debian/changelog
  2. 2 1
      lib/dpkg/i18n.h
  3. 1 1
      po/Makevars
  4. 7 1
      scripts/Dpkg/Gettext.pm
  5. 1 1
      scripts/po/Makevars

+ 1 - 0
debian/changelog

@@ -8,6 +8,7 @@ dpkg (1.15.8.5) UNRELEASED; urgency=low
     Thanks to Joey Hess, based on a patch by Tanguy Ortolo.
   * Clarify effect of “dpkg --purge” on homedir files in dpkg(1).
     Thanks to The Fungi <fungi@yuggoth.org>. Closes: #593628
+  * Add gettext plurals infrastructure support.
 
   [ Raphaël Hertzog ]
   * Fix dpkg-genchanges to not split the short description in the middle of a

+ 2 - 1
lib/dpkg/i18n.h

@@ -2,7 +2,7 @@
  * libdpkg - Debian packaging suite library routines
  * i18n.h - i18n support
  *
- * Copyright © 2008 Guillem Jover <guillem@debian.org>
+ * Copyright © 2008-2010 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@ DPKG_BEGIN_DECLS
 #include <gettext.h>
 
 #define _(str) gettext(str)
+#define P_(str, str_plural, n) ngettext(str, str_plural, n)
 #define N_(str) gettext_noop(str)
 
 DPKG_END_DECLS

+ 1 - 1
po/Makevars

@@ -8,7 +8,7 @@ subdir = po
 top_builddir = ..
 
 # These options get passed to xgettext.
-XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --from-code=UTF-8
+XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --keyword=P_:1,2 --from-code=UTF-8
 
 MSGMERGE_OPTIONS = --previous
 

+ 7 - 1
scripts/Dpkg/Gettext.pm

@@ -44,17 +44,23 @@ BEGIN {
 					return $_[1];
 				}
 			}
+			sub P_ {
+				return ngettext(@_);
+			}
 		};
 	} else {
 		eval q{
 			sub _g {
 				return gettext(shift);
 			}
+			sub P_ {
+				return ngettext(@_);
+			}
 		};
 	}
 }
 
 use base qw(Exporter);
-our @EXPORT=qw(_g textdomain ngettext);
+our @EXPORT=qw(_g P_ textdomain ngettext);
 
 1;

+ 1 - 1
scripts/po/Makevars

@@ -8,7 +8,7 @@ subdir = scripts/po
 top_builddir = ../..
 
 # These options get passed to xgettext.
-XGETTEXT_OPTIONS = --from-code=iso-8859-1 --keyword=_g
+XGETTEXT_OPTIONS = --from-code=iso-8859-1 --keyword=_g --keyword=P_:1,2
 
 MSGMERGE_OPTIONS = --previous