Skip to content
  • Ævar Arnfjörð Bjarmason's avatar
    i18n: add no-op _() and N_() wrappers · 65784830
    Ævar Arnfjörð Bjarmason authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    The _ function is for translating strings into the user's chosen
    language.  The N_ macro just marks translatable strings for the
    xgettext(1) tool without translating them; it is intended for use in
    contexts where a function call cannot be used.  So, for example:
    
    	fprintf(stderr, _("Expansion of alias '%s' failed; "
    		"'%s' is not a git command\n"),
    		cmd, argv[0]);
    
    and
    
    	const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {
    		/* ERROR_WOULD_OVERWRITE */
    		N_("Entry '%s' would be overwritten by merge. Cannot merge."),
    	[...]
    
    Define such _ and N_ in a new gettext.h and include it in cache.h, so
    they can be used everywhere.  Each just returns its argument for now.
    _ is a function rather than a macro like N_ to avoid the temptation to
    use _("foo") as a string literal (which would be a compile-time error
    once _(s) expands to an expression for the translation of s).
    
    Signed-off-by: default avatarÆvar Arnfjörð Bjarmason <avarab@gmail.com>
    Signed-off-by: default avatarJonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    65784830