Bug 429882 - [nls tooling] Externalize Strings dialog should create more meaningful keys
Summary: [nls tooling] Externalize Strings dialog should create more meaningful keys
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-07 09:58 EST by Dmitry Spiridenok CLA
Modified: 2014-05-08 04:49 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Spiridenok CLA 2014-03-07 09:58:41 EST
Currently JDT Externalize Strings dialog creates keys in the format <CommonPrefix><separator><counter> where:
<CommonPrefix> is specified in the wizard.
<separator> is either dot or underscore depending upon the externalization mechanism selected in the wizard.
<counter> is just an integer increasing from 0.

It would be nice to have more meaningful keys created by the wizard that are based on the values of the strings to be internalized. Examples:
value: "Summary" -> key: "prefix_SUMMARY"
value: "Postconstructor is called" -> key: "prefix_POSTCONSTRUCTOR_IS_CALLED"
value: "veeeeeeeeeeeeeeery long string" -> key: "prefix_VEEEEEERY_LONG"

To keep the feature backwards compatible with the current way-of-working, the new mechanism can be put behind an extra check box (like "Derive keys from string values") and deselect/uncheck the check box by default. Only after explicitly selecting the check box the new mechanism will be applied in the wizard.

For the rest the existing behavior of the wizards should not be changed.
Comment 1 Dmitry Spiridenok CLA 2014-03-07 10:03:03 EST
I'm willing to solve this bug with some assistance on what classes to change and how to unit-test.
My speed of change will be not high but I can deliver the implementation is small deliveries (step by step).
Comment 2 Martin Mathew CLA 2014-03-16 20:55:52 EDT
See bug 75065 comment 1. We can set a limit for the maximum allowed characters to avoid very long keys.
org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage is handling the Externalize Strings functionality.
Comment 3 Dmitry Spiridenok CLA 2014-03-17 05:15:44 EDT
(In reply to Manju Mathew from comment #2)
> See bug 75065 comment 1. We can set a limit for the maximum allowed
> characters to avoid very long keys.
> org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage is
> handling the Externalize Strings functionality.

OK, I'll have a look at the ExternalizeWizargPage class to see how i can add the new functionality there. 

Do you want the max chars limit to be modifiable by the user or better hardcoded in the class? If the limit has to be modifiable - how to do that - via the same wizard window or via the workspace preferences?
Comment 4 Martin Mathew CLA 2014-03-18 20:11:40 EDT
No need to make it complex by adding the character limit configurable. Consider the first 10 characters, the field is anyway editable, so if user wants he can add/remove as per his need.
Also this feature was available earlier and was removed, hence will be considered as a low priority task.
Comment 5 Dmitry Spiridenok CLA 2014-03-19 16:15:58 EDT
(In reply to Manju Mathew from comment #4)
> No need to make it complex by adding the character limit configurable.
> Consider the first 10 characters, the field is anyway editable, so if user
> wants he can add/remove as per his need.
> Also this feature was available earlier and was removed, hence will be
> considered as a low priority task.

OK, thanks for reply! I'll choose some predefined value for max string length.

Another question: do you know why this feature was removed? I would like to learn from the past experience and do not want to make the same mistake twice.
Comment 6 Martin Mathew CLA 2014-03-19 20:30:07 EDT
(In reply to Dmitry Spiridenok from comment #5)
> Another question: do you know why this feature was removed? I would like to
> learn from the past experience and do not want to make the same mistake
> twice.
As mentioned in bug 75065 comment 1 : "We want to encourage shorter names as all these keys will be loaded at runtime and take considerable amount of memory."
I did not find the original bug which removed this feature.
Comment 7 Dmitry Spiridenok CLA 2014-03-20 03:31:06 EDT
OK, It's clear. I'll make sure that the default length will be pretty short so that we discourage people to use long strings.

Now the last questions: where can I get org.eclipse.jdt.internal? 

I've cloned the master branch of git://git.eclipse.org/gitroot/jdt/eclipse.jdt.git repository but it seems contain no java packages/classes at all. Do I need to use some other git repository or is it still in SVN?
Comment 8 Martin Mathew CLA 2014-03-20 03:33:28 EDT
(In reply to Dmitry Spiridenok from comment #7)
> I've cloned the master branch of
> git://git.eclipse.org/gitroot/jdt/eclipse.jdt.git repository but it seems
> contain no java packages/classes at all. Do I need to use some other git
> repository or is it still in SVN?
see http://wiki.eclipse.org/JDT_UI/How_to_Contribute#Getting_the_code_into_your_workspace
The JDT code is in git.