Thread overview
[Issue 19776] [internals] Support i18n in error messages
Mar 30, 2019
Iain Buclaw
Mar 30, 2019
Iain Buclaw
Mar 31, 2019
Iain Buclaw
Apr 01, 2019
anonymous4
Dec 17, 2022
Iain Buclaw
March 30, 2019
https://issues.dlang.org/show_bug.cgi?id=19776

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #1 from Iain Buclaw <ibuclaw@gdcproject.org> ---
As well as making sure the format string of errors are translation-friendly, there's also a couple of functions - verror and vdeprecation - that have optional parameters. Incidentally, they are only ever set as `kind()` and `toPrettyChars()`.

The former kind() function returns a string literal, such as declaration
(déclaration), template (patron), function (fonction), etc...

However these will never be translated unless the function kind() returns
calling gettext().

A bare minimal example being:

> // module dmd.errors;
> nothrow @nogc
> {
>     version (ENABLE_NLS)
>     {
>         extern (C) const(char)* gettext(scope const char* msgid);
>     }
>     else
>     {
>         const(char)* gettext(scope const char* msgid)
>         {
>             pragma(inline, true);
>             return msgid;
>         }
>     }
> }
> 
> alias _ = gettext;
> 
> // module dmd.func;
> extern (C++) class FuncDeclaration : Declaration
> {
>     override const(char)* kind() const
>     {
>         return generated ? _("generated function") : _("function");
>     }
> }

--
March 30, 2019
https://issues.dlang.org/show_bug.cgi?id=19776

--- Comment #2 from Iain Buclaw <ibuclaw@gdcproject.org> ---
For future reference, keyword flags used to extract strings from dmd front-end.

--keyword=
--keyword=_
--keyword=error
--flag=error:2:c-format
--keyword=errorSupplemental
--flag=errorSupplemental:2:c-format
--keyword=warning
--flag=warning:2:c-format
--keyword=warningSupplemental
--flag=warningSupplemental:2:c-format
--keyword=deprecation
--flag=deprecation:2:c-format
--keyword=deprecationSupplemental
--flag=deprecationSupplemental:2:c-format
--keyword=message
--keyword=verror
--flag=verror:2:c-format
--keyword=verrorSupplemental
--flag=verrorSupplemental:2:c-format
--keyword=vwarning
--flag=vwarning:2:c-format
--keyword=vwarningSupplemental
--flag=vwarningSupplemental:2:c-format
--keyword=vdeprecation
--flag=vdeprecation:2:c-format
--keyword=vdeprecationSupplemental
--flag=vdeprecationSupplemental:2:c-format
--keyword=vmessage

--
March 31, 2019
https://issues.dlang.org/show_bug.cgi?id=19776

--- Comment #3 from Iain Buclaw <ibuclaw@gdcproject.org> ---
Created attachment 1744
  --> https://issues.dlang.org/attachment.cgi?id=1744&action=edit
Swedish translation of expressionsem.d, and others.

--
April 01, 2019
https://issues.dlang.org/show_bug.cgi?id=19776

--- Comment #4 from anonymous4 <dfj1esp02@sneakemail.com> ---
Personal anecdote with translated error messages: in English is was like "decimal bytes are not valid decimal", English is succinct enough, so you can make sense of it. Translated was something like "les octets decimals ne sont pas decimals valables", now that was cryptic (how a byte can be decimal? and all other european languages except for english are quite nuanced). Also imagine people coming to the learn group with Chinese error messages.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=19776

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--