This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 422278 - [nls] orion.edit.validator should support translation of problems
Summary: [nls] orion.edit.validator should support translation of problems
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: Client (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 7.0   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 424391
  Show dependency tree
 
Reported: 2013-11-21 13:16 EST by Mark Macdonald CLA
Modified: 2014-07-03 10:30 EDT (History)
1 user (show)

See Also:


Attachments
proposed fix (2.72 KB, patch)
2014-07-02 21:37 EDT, Michael Rennie CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Macdonald CLA 2013-11-21 13:16:52 EST
The 'orion.edit.validator' extension point needs to support i18n.

Below is a sketch of the new API.

Service properties to be added to orion.edit.validator services:
 * nls : String   - Gives the the message bundle path to be uses for translating this validator's messages.

Fields to be added to the Problem object [2]
 * descriptionKey  : String   - Gives the message key used to look up translated description of this problem.
 * descriptionArgs : String[] - Arguments to be substituted into the translated message at display time.

[1] http://wiki.eclipse.org/Orion/Documentation/Developer_Guide/Plugging_into_the_editor#orion.edit.validator
[2] http://wiki.eclipse.org/Orion/Documentation/Developer_Guide/Plugging_into_the_editor#The_Problem_object
Comment 1 Michael Rennie CLA 2013-11-22 10:04:25 EST
Maybe I am misunderstanding what is being asked for here, but it feels to me that the Orion framework side should not have to care about NLS'ing anything, translations should be done by the plug-in that is providing the extension / problem objects. Then on the service side it only shows the message provided to it as-is (via the the problem.description property).
Comment 2 Mark Macdonald CLA 2013-11-22 16:14:16 EST
I'm proposing to stick with the i18n story for plugins outlined here, in which the framework manages translations:
https://wiki.eclipse.org/Orion/Internationalization#Plugins

It does complicate the service APIs a bit, but allows us to ship "language packs" that contain translations for all the Orion default plugins without each having to implement translation logic.

We will still support the old "description" field in the Problem API, for plugins that want to handle translation some other way (or not at all).
Comment 3 Michael Rennie CLA 2014-07-02 21:37:21 EDT
Created attachment 244760 [details]
proposed fix

This patch performs NLS'ing of problem messages. It makes use of the updated API on i18nUtil to accept an object for substitutions, and allows the nls property to be specified on the validator declaration, that way we are not resolving N nls bundle lookup promises for N validator problems.

Mark, please review the patch to make sure it does not run afoul of any of our NLS stories.
Comment 4 Mark Macdonald CLA 2014-07-03 09:37:38 EDT
(In reply to Michael Rennie from comment #3)

A few minor things

- I would name the fields "descriptionKey" and "descriptionArgs", since they're providing a translation of the problem description, not the problem itself. 

- The code as written doesn't allow a nls-supporting validator to return a simple Problem[] array instead of a { problems: Problem[] } wrapper object. You could just do this instead, which should cover it:

> var probs = extractProblems(results);
> if (probs.length > 0) { 
>     return i18nutil.getMessageBundle(nls).then(   ...
> }