[Issue 19776] New: [internals] Support i18n in error messages

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 30 11:03:49 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19776

          Issue ID: 19776
           Summary: [internals] Support i18n in error messages
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ibuclaw at gdcproject.org

Created attachment 1743
  --> https://issues.dlang.org/attachment.cgi?id=1743&action=edit
French translation of expressionsem.d, and others.

Attaching a partial translation that was done by the French Translation team by
accident (I forgot to update the EXCLUDES for new files).


For brevity, posting a few random examples from that file:

---
> #: d/dmd/expressionsem.c:435
> #, gcc-internal-format, gfc-internal-format
> msgid "`%s` is not defined, perhaps `import %s;` is needed?"
> msgstr "« %s » n'est pas défini, peut-être que « import %s; » est nécessaire ?"
> 
> #. Because COM classes are deleted by IUnknown.Release()
> #.
> #: d/dmd/expressionsem.c:4014
> #, gcc-internal-format, gfc-internal-format
> msgid "cannot delete instance of COM interface %s"
> msgstr "impossible de supprimer l'instance de l'interface COM %s"
> 
> #: d/dmd/safe.c:75
> #, gcc-internal-format, gfc-internal-format
> msgid "field %s.%s cannot modify fields in @safe code that overlap fields with other storage classes"
> msgstr "le champs %s.%s ne peut pas modifier des champs dans du code @safe qui recouvre des champs avec d'autres classes de stockage"
> 
> #: d/dmd/staticcond.c:85
> #, gcc-internal-format, gfc-internal-format
> msgid "expression %s of type %s does not have a boolean value"
> msgstr "l'expression %s de type %s n'a pas une valeur booléenne"
---


This will be deleted, however I'm not opposed to this sort of work being done,
it would be great if the dmd front-end was more fit for purpose in order to
allow such work to be undertaken.


One example where i18n can be frustrated by the front-end, is by some cases
where errors are squashed into a programmatically computed message (to save a
couple of lines?)

For example, in expressionsem.d there is this piece of code:

> const(char)* s = exp.op == TOK.plusPlus ? "increment" : "decrement";
> exp.error("cannot post-%s array slice `%s`, use pre-%s instead", s, exp.e1.toChars(), s);


The string "cannot post-%s ..." will be extracted for translation, but the
inserted words, "increment" and "decrement", will not.

At a minimum, these words need to be marked for translation too, however the
better option is to make it two complete messages.  While for some languages it
would work to compose the sentence in the same way as the original format, it
would be safe to assume that languages further removed from English would have
more trouble.

--


More information about the Digitalmars-d-bugs mailing list