summaryrefslogtreecommitdiff
path: root/Debian/Dgit/I18n.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Debian/Dgit/I18n.pm')
-rw-r--r--Debian/Dgit/I18n.pm28
1 files changed, 28 insertions, 0 deletions
diff --git a/Debian/Dgit/I18n.pm b/Debian/Dgit/I18n.pm
new file mode 100644
index 0000000..e8068ff
--- /dev/null
+++ b/Debian/Dgit/I18n.pm
@@ -0,0 +1,28 @@
+# -*- perl -*-
+
+package Debian::Dgit::I18n;
+
+# This module provides
+# __ a function which is an alias for gettext
+# f_ sprintf wrapper that gettexts the format
+# i_ identify function, but marks string for translation
+#
+# In perl the sub `_' is a `superglobal', which means there
+# is only one of it in the whole program and every reference
+# is to the same one. So it's not really useable in modules.
+# Hence __.
+
+use Locale::gettext;
+
+BEGIN {
+ use Exporter;
+ @ISA = qw(Exporter);
+ @EXPORT = qw(__ f_ i_);
+}
+
+
+sub __ ($) { gettext @_; }
+sub i_ ($) { $_[0]; }
+sub f_ ($$;@) { my $f = shift @_; sprintf +(gettext $f), @_; }
+
+1;