Allow localised warning/error messages
Due to the development of language servers for Vala it makes sense to have localised warning/error messages. Of course it helps too seeing them translated on the commandline.
The following branch will contain some fundamental steps and changes to accomplish this:
https://gitlab.gnome.org/GNOME/vala/tree/wip/gettext
Vala reports errors and warnings to the programmer using the Vala.Report class. This class has static methods Report.error()
and Report.warning()
. Both take a source reference argument and a message argument. It is the text of the message that should be localized. This would be done using gettext when the static method is called, e.g. Report.error (source_reference, _("Extern methods cannot have bodies"));
This uses the gettext _()
function to identify the string as translatable and lookup an alternative at runtime.
The Report
class also has Report.notice()
, Report.deprecated()
and Report.experimental()
static methods. Should these calls have translatable messages?
The parse classes, Vala.Parser
and Vala.Genie.Parser
, have an errordomain
Vala.ParseError
that should also have translatable messages when the error is thrown.
The message should follow a style guide. For example keywords should be highlighted, so "Extern methods cannot have bodies" would become "`extern' methods cannot have bodies".
The Report
class has code that identifies parts of a message enclosed in `', `` or '' as capable of being highlighted and will generate the relevant terminal codes for this if the coloured_output
parameter is ALWAYS
or AUTO
.
These are some initial points for a style guide:
- Prefer specifics to generalities, e.g. use the keyword `extern' instead of the word Extern that will then need translating, the full identifier helps the programmer identify the problem
- Should we wrap all vala keywords in `...' and distinguish between keywords and e.g. filenames? - it might be nice to have keywords in a different colour to identifiers. This could be done with different
Report
highlight delimiters, e.g. `` for keyword and '' for identifiers - Fix inconsistencies between `%s` , `%s' , '%s' - there doesn't appear to be any use of forward ticks: ‘%s’
- Re-use similar strings by unifying them
- Don't translate "internal error: ..." these should probably be assertions
- Always use capitalized beginning?
- Apply spelling/gammar guide lines, e.g. "cannot" -> "can not", "can't"?
TODO
- Add manpages and OptionContext's aka --help
- Clean up POTFILES.* from superfluous entries
Follow https://wiki.gnome.org/TranslationProject/DevGuidelines
Request inclusion on l10n.gnome.org, https://gitlab.gnome.org/Infrastructure/damned-lies/issues
Also see https://mail.gnome.org/archives/vala-list/2018-August/msg00000.html