public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/1] RISC-V: i18n enablement on error messages
@ 2022-06-10  9:52 Tsukasa OI
  2022-06-10  9:52 ` [PATCH 1/1] RISC-V: Prepare i18n for required ISA extensions Tsukasa OI
  0 siblings, 1 reply; 3+ messages in thread
From: Tsukasa OI @ 2022-06-10  9:52 UTC (permalink / raw)
  To: Tsukasa OI, Palmer Dabbelt, Andrew Waterman, Jim Wilson, Nelson Chu
  Cc: binutils

Hello,

This patchset contains i18n enablement.

When extensions are missing for an instruction, it will print an error
message like this:

    Error: unrecognized opcode `fence.i', extension `zifencei' required

This is formatted in gas/config/tc-riscv.c:

    as_bad ("%s `%s', extension `%s' required", error.msg,
            error.statement, error.missing_ext);

error.missing_ext is a return value from the function
`riscv_multi_subset_supports_ext' in bfd/elfxx-riscv.c.

If required "extension" IS simple, that's fine.  All we have to do
with i18n is to translate "%s `%s', extension `%s' required".
But if requirementS get complex, that's not that simple.  There are
13 complex strings representing required extensions:

    return "f' and `c";
    return "d' and `c";
    return "f' or `zfinx";
    return "d' or `zdinx";
    return "q' or `zqinx";
    return "zbb' or `zbkb";
    return "zbc' or `zbkc";
    return "zknd' or `zkne";
    return "v' or `zve64x' or `zve32x";
    return "v' or `zve64d' or `zve64f' or `zve32f";
    return "zfh' or 'zhinx";
    return "('d' and 'zfh') or 'zhinx";
    return "('q' and 'zfh') or 'zhinx";

For i18n, we have to translate words like "and" and "or".  In Japanese,
we should translate:
    "f' and `c"
to:
    "f' および `c"

This is simple (I replaced "and" with equivalent Japanese word "および").
But more complex requirements (e.g. involving V or Zfh) will need
natural sentense (that would depend on each language).

This patch wraps such 13 strings with _() for i18n enablement.
It will be a prerequisite to my future submission of quick Zhinx fixes
and larger Z{h,f,d,q}inx fixes.

Thanks,
Tsukasa




Tsukasa OI (1):
  RISC-V: Prepare i18n for required ISA extensions

 bfd/elfxx-riscv.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)


base-commit: 6a72edd8e26c670bbdce7aeae3c0c8f793fc8612
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] RISC-V: Prepare i18n for required ISA extensions
  2022-06-10  9:52 [PATCH 0/1] RISC-V: i18n enablement on error messages Tsukasa OI
@ 2022-06-10  9:52 ` Tsukasa OI
  2022-06-22 10:35   ` Nelson Chu
  0 siblings, 1 reply; 3+ messages in thread
From: Tsukasa OI @ 2022-06-10  9:52 UTC (permalink / raw)
  To: Tsukasa OI, Palmer Dabbelt, Andrew Waterman, Jim Wilson, Nelson Chu
  Cc: binutils

Some strings returned by the riscv_multi_subset_supports_ext function
contain not just extension names but words like "and" and "or".
This commit wraps such strings with the gettext macro (_) for
internationalization in the future.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_multi_subset_supports_ext): Wrap some
	strings with the gettext macro to prepare future i18n.
---
 bfd/elfxx-riscv.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 7c36123338c..a4609b995b8 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -2462,7 +2462,7 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
     case INSN_CLASS_F_AND_C:
       if (!riscv_subset_supports (rps, "f")
 	  && !riscv_subset_supports (rps, "c"))
-	return "f' and `c";
+	return _("f' and `c");
       else if (!riscv_subset_supports (rps, "f"))
 	return "f";
       else
@@ -2470,17 +2470,18 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
     case INSN_CLASS_D_AND_C:
       if (!riscv_subset_supports (rps, "d")
 	  && !riscv_subset_supports (rps, "c"))
-	return "d' and `c";
+	return _("d' and `c");
       else if (!riscv_subset_supports (rps, "d"))
 	return "d";
       else
 	return "c";
     case INSN_CLASS_F_OR_ZFINX:
-      return "f' or `zfinx";
+      /* i18n: Formatted like "extension `f' or `zfinx' required".  */
+      return _("f' or `zfinx");
     case INSN_CLASS_D_OR_ZDINX:
-      return "d' or `zdinx";
+      return _("d' or `zdinx");
     case INSN_CLASS_Q_OR_ZQINX:
-      return "q' or `zqinx";
+      return _("q' or `zqinx");
     case INSN_CLASS_ZBA:
       return "zba";
     case INSN_CLASS_ZBB:
@@ -2496,9 +2497,9 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
     case INSN_CLASS_ZBKX:
       return "zbkx";
     case INSN_CLASS_ZBB_OR_ZBKB:
-      return "zbb' or `zbkb";
+      return _("zbb' or `zbkb");
     case INSN_CLASS_ZBC_OR_ZBKC:
-      return "zbc' or `zbkc";
+      return _("zbc' or `zbkc");
     case INSN_CLASS_ZKND:
       return "zknd";
     case INSN_CLASS_ZKNE:
@@ -2506,25 +2507,25 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
     case INSN_CLASS_ZKNH:
       return "zknh";
     case INSN_CLASS_ZKND_OR_ZKNE:
-      return "zknd' or `zkne";
+      return _("zknd' or `zkne");
     case INSN_CLASS_ZKSED:
       return "zksed";
     case INSN_CLASS_ZKSH:
       return "zksh";
     case INSN_CLASS_V:
-      return "v' or `zve64x' or `zve32x";
+      return _("v' or `zve64x' or `zve32x");
     case INSN_CLASS_ZVEF:
-      return "v' or `zve64d' or `zve64f' or `zve32f";
+      return _("v' or `zve64d' or `zve64f' or `zve32f");
     case INSN_CLASS_SVINVAL:
       return "svinval";
     case INSN_CLASS_ZFH:
       return "zfh";
     case INSN_CLASS_ZFH_OR_ZHINX:
-      return "zfh' or 'zhinx";
+      return _("zfh' or 'zhinx");
     case INSN_CLASS_D_AND_ZFH_INX:
-      return "('d' and 'zfh') or 'zhinx";
+      return _("('d' and 'zfh') or 'zhinx");
     case INSN_CLASS_Q_AND_ZFH_INX:
-      return "('q' and 'zfh') or 'zhinx";
+      return _("('q' and 'zfh') or 'zhinx");
     default:
       rps->error_handler
         (_("internal: unreachable INSN_CLASS_*"));
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] RISC-V: Prepare i18n for required ISA extensions
  2022-06-10  9:52 ` [PATCH 1/1] RISC-V: Prepare i18n for required ISA extensions Tsukasa OI
@ 2022-06-22 10:35   ` Nelson Chu
  0 siblings, 0 replies; 3+ messages in thread
From: Nelson Chu @ 2022-06-22 10:35 UTC (permalink / raw)
  To: Tsukasa OI; +Cc: Palmer Dabbelt, Andrew Waterman, Jim Wilson, Binutils

OK, committed.

Thanks
Nelson

On Fri, Jun 10, 2022 at 5:53 PM Tsukasa OI <research_trasio@irq.a4lg.com> wrote:
>
> Some strings returned by the riscv_multi_subset_supports_ext function
> contain not just extension names but words like "and" and "or".
> This commit wraps such strings with the gettext macro (_) for
> internationalization in the future.
>
> bfd/ChangeLog:
>
>         * elfxx-riscv.c (riscv_multi_subset_supports_ext): Wrap some
>         strings with the gettext macro to prepare future i18n.
> ---
>  bfd/elfxx-riscv.c | 27 ++++++++++++++-------------
>  1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
> index 7c36123338c..a4609b995b8 100644
> --- a/bfd/elfxx-riscv.c
> +++ b/bfd/elfxx-riscv.c
> @@ -2462,7 +2462,7 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
>      case INSN_CLASS_F_AND_C:
>        if (!riscv_subset_supports (rps, "f")
>           && !riscv_subset_supports (rps, "c"))
> -       return "f' and `c";
> +       return _("f' and `c");
>        else if (!riscv_subset_supports (rps, "f"))
>         return "f";
>        else
> @@ -2470,17 +2470,18 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
>      case INSN_CLASS_D_AND_C:
>        if (!riscv_subset_supports (rps, "d")
>           && !riscv_subset_supports (rps, "c"))
> -       return "d' and `c";
> +       return _("d' and `c");
>        else if (!riscv_subset_supports (rps, "d"))
>         return "d";
>        else
>         return "c";
>      case INSN_CLASS_F_OR_ZFINX:
> -      return "f' or `zfinx";
> +      /* i18n: Formatted like "extension `f' or `zfinx' required".  */
> +      return _("f' or `zfinx");
>      case INSN_CLASS_D_OR_ZDINX:
> -      return "d' or `zdinx";
> +      return _("d' or `zdinx");
>      case INSN_CLASS_Q_OR_ZQINX:
> -      return "q' or `zqinx";
> +      return _("q' or `zqinx");
>      case INSN_CLASS_ZBA:
>        return "zba";
>      case INSN_CLASS_ZBB:
> @@ -2496,9 +2497,9 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
>      case INSN_CLASS_ZBKX:
>        return "zbkx";
>      case INSN_CLASS_ZBB_OR_ZBKB:
> -      return "zbb' or `zbkb";
> +      return _("zbb' or `zbkb");
>      case INSN_CLASS_ZBC_OR_ZBKC:
> -      return "zbc' or `zbkc";
> +      return _("zbc' or `zbkc");
>      case INSN_CLASS_ZKND:
>        return "zknd";
>      case INSN_CLASS_ZKNE:
> @@ -2506,25 +2507,25 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
>      case INSN_CLASS_ZKNH:
>        return "zknh";
>      case INSN_CLASS_ZKND_OR_ZKNE:
> -      return "zknd' or `zkne";
> +      return _("zknd' or `zkne");
>      case INSN_CLASS_ZKSED:
>        return "zksed";
>      case INSN_CLASS_ZKSH:
>        return "zksh";
>      case INSN_CLASS_V:
> -      return "v' or `zve64x' or `zve32x";
> +      return _("v' or `zve64x' or `zve32x");
>      case INSN_CLASS_ZVEF:
> -      return "v' or `zve64d' or `zve64f' or `zve32f";
> +      return _("v' or `zve64d' or `zve64f' or `zve32f");
>      case INSN_CLASS_SVINVAL:
>        return "svinval";
>      case INSN_CLASS_ZFH:
>        return "zfh";
>      case INSN_CLASS_ZFH_OR_ZHINX:
> -      return "zfh' or 'zhinx";
> +      return _("zfh' or 'zhinx");
>      case INSN_CLASS_D_AND_ZFH_INX:
> -      return "('d' and 'zfh') or 'zhinx";
> +      return _("('d' and 'zfh') or 'zhinx");
>      case INSN_CLASS_Q_AND_ZFH_INX:
> -      return "('q' and 'zfh') or 'zhinx";
> +      return _("('q' and 'zfh') or 'zhinx");
>      default:
>        rps->error_handler
>          (_("internal: unreachable INSN_CLASS_*"));
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-22 10:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10  9:52 [PATCH 0/1] RISC-V: i18n enablement on error messages Tsukasa OI
2022-06-10  9:52 ` [PATCH 1/1] RISC-V: Prepare i18n for required ISA extensions Tsukasa OI
2022-06-22 10:35   ` Nelson Chu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).