-
-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[internals] Support i18n in error messages #17900
Labels
Comments
ibuclaw (@ibuclaw) commented on 2019-03-30T22:48:21ZAs 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");
> }
> } |
ibuclaw (@ibuclaw) commented on 2019-03-30T23:05:27ZFor 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 |
ibuclaw (@ibuclaw) commented on 2019-03-31T21:43:04ZCreated attachment 1744
Swedish translation of expressionsem.d, and others. |
dfj1esp02 commented on 2019-04-01T09:38:30ZPersonal 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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Iain Buclaw (@ibuclaw) reported this on 2019-03-30T11:03:49Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=19776
CC List
Description
!!!There are attachements in the bugzilla issue that have not been copied over!!!
The text was updated successfully, but these errors were encountered: