diff --git a/gnu/usr.bin/groff/tmac/mdoc.local b/gnu/usr.bin/groff/tmac/mdoc.local index 190aeaf00a1b..288026cf6f23 100644 --- a/gnu/usr.bin/groff/tmac/mdoc.local +++ b/gnu/usr.bin/groff/tmac/mdoc.local @@ -56,9 +56,9 @@ .ec . .\" Locale support -.if d doc-lang \{\ -. ie "\*[doc-lang]"ru.KOI8-R" \ +.if d doc-locale \{\ +. ie "\*[doc-locale]"ru.KOI8-R" \ . mso mdoc/koi8-r -. el \{ .if "\*[doc-lang]"fr.ISO8859-1" \ +. el \{ .if "\*[doc-locale]"fr.ISO8859-1" \ . mso mdoc/fr.ISO8859-1 .\}\} diff --git a/gnu/usr.bin/man/man/man.c b/gnu/usr.bin/man/man/man.c index 3633e8836d86..31ccd8c1d7b6 100644 --- a/gnu/usr.bin/man/man/man.c +++ b/gnu/usr.bin/man/man/man.c @@ -89,6 +89,8 @@ static int print_where; #ifdef __FreeBSD__ static char *locale, *locale_opts, *locale_nroff, *locale_codeset; static char locale_terr[3], locale_lang[3]; +static char *man_locale; +static int use_man_locale; static int use_original; struct ltable { char *lcode; @@ -443,6 +445,7 @@ man_getopt (argc, argv) break; } } + asprintf(&man_locale, "%s.%s", locale_lang, locale_codeset); } } else { if (locale == NULL) { @@ -1030,8 +1033,10 @@ parse_roff_directive (cp, file, buf, bufsize) #ifdef __FreeBSD__ char lbuf[FILENAME_MAX]; - snprintf(lbuf, sizeof(lbuf), "%s -T%s", NROFF, - locale_opts == NULL ? "ascii" : locale_opts); + snprintf(lbuf, sizeof(lbuf), "%s -T%s%s%s", NROFF, + locale_opts == NULL ? "ascii" : locale_opts, + use_man_locale ? " -dlocale=" : "", + use_man_locale ? man_locale : ""); add_directive (&first, lbuf, file, buf, bufsize); #else add_directive (&first, NROFF " -Tascii", file, buf, bufsize); @@ -1583,6 +1588,7 @@ man (name) l_found = 0; if (locale != NULL) { locale_opts = locale_nroff; + use_man_locale = 1; if (*locale_lang != '\0' && *locale_terr != '\0') { snprintf(buf, sizeof(buf), "%s/%s_%s.%s", *mp, locale_lang, locale_terr, locale_codeset); @@ -1596,6 +1602,7 @@ man (name) if (is_directory (buf) == 1) l_found = try_section (buf, shortsec, longsec, name, glob); } + use_man_locale = 0; if (!l_found && strcmp(locale_lang, "en") != 0) { snprintf(buf, sizeof(buf), "%s/en.%s", *mp, locale_codeset); @@ -1604,6 +1611,7 @@ man (name) } } locale_opts = NULL; + use_man_locale = 0; } if (!l_found) { #endif @@ -1632,6 +1640,7 @@ man (name) l_found = 0; if (locale != NULL) { locale_opts = locale_nroff; + use_man_locale = 1; if (*locale_lang != '\0' && *locale_terr != '\0') { snprintf(buf, sizeof(buf), "%s/%s_%s.%s", *mp, locale_lang, locale_terr, locale_codeset); @@ -1645,6 +1654,7 @@ man (name) if (is_directory (buf) == 1) l_found = try_section (buf, *sp, longsec, name, glob); } + use_man_locale = 0; if (!l_found && strcmp(locale_lang, "en") != 0) { snprintf(buf, sizeof(buf), "%s/en.%s", *mp, locale_codeset); @@ -1653,6 +1663,7 @@ man (name) } } locale_opts = NULL; + use_man_locale = 0; } if (!l_found) { #endif