String Handling Plug-in
Jonathan Gossage
Copyright Ó
Jonathan Gossage, 2002
Overview
This document examines the requirements for managing strings
in an international development environment. Based on these requirements it
then proposes an Eclipse based design that should significantly reduce the
effort required to deal effectively with strings, particularly when
internationalization is a requirement.
Why not use current Eclipse support
Eclipse already provides a tool to support string
internationalization. What are the reasons for developing another one? The reasons fall into two main areas:
Usability
On the Stellation sub-project of Eclipse,
the Eclipse tool was used as an experiment on one package and the results gave
the developers significant problems. They found the resulting code much harder
to read and understand and they felt that the effort required to create the
string environment was too high.
They also found that the amount of
context shown when strings were being batch internationalized was insufficient
to always be able to make good decisions about the handling of individual
strings.
Scope
The Eclipse package only addresses a part of the entire
string management picture. In particular, it does not address the problem of
string consolidation where it is desired to only have one string with a
particular semantic meaning and content. It also provides no assistance during
the language translation phase of string internationalization. Nor does it
optimize resource usage at runtime.
Requirements
Scope
General
This tool is intended to help manage text strings embedded
in program text. It is not intended to provide any form of general text
management capabilities.
Single language target
The basic service that can be provided in this scenario is
to permit identical strings to be referenced symbolically where the duplicate
copies have the same semantic meaning rather than just the same textual value.
This helps with program maintenance since a change to the text of the string
need only be made once.
Multi-language target
Services will be provided to create, maintain and access
language and cultural specific versions of text strings. Access facilities will
be provided for both development/editing stages and for program run-time. In
addition, specialized services will be provided to aid in the translation
process. These services will take full advantage of standard Java
internationalization support.
Multi-part strings
Services will be provided to create and view multi-part
strings that contain variable elements. Such strings pose particular problems
during internationalization and these services will allow multi-part strings to
be composed and will support the display of sample results while editing the
strings. These services will take full advantage of Java support for message
construction.
Usability
Entering strings into a program will simply require typing
the string in most cases. The tool will take care of all the bookkeeping behind
the scenes but will make the advanced capabilities available simply. Strings
will be displayed on the screen as strings. The backing code needed to actually
handle the string at run-time will be generated automatically and will only be
displayed on demand. All generated code will be user editable when required.
Functionality
Convert existing conventional code bases
Users need to be able to convert strings in existing code
bases into an internationalized and consolidated form. The specific
requirements include the following:
- Identify
the scope of the conversion effort. The conversion can be performed in one
or more steps as required. The scope can be specified as an entire
workspace, a set of projects or a set of files.
- Define
the rules to be followed during the conversion. These include the default language,
the location of the strings (i.e. the name and location of the string
storage container), whether string translation will be required, whether
duplicate strings will be automatically consolidated or whether strings
should not be managed by default.
Convert existing Eclipse/Java managed code bases
A tool will be provided to convert environments that use
variations on the basic Java strategy of using ResourceBundles, including code
managed by the current Eclipse facilities. In addition the current Eclipse
convention for marking strings that should not be tool-managed by adding a
marker comment will be used and honored.
Editing the string
Strings will be entered, view and modified as normal text
strings in the user’s normal language. The appearance will be of directly working
on the string in the program text. Visual indicators will be provided for the
string management rules in effect. These include string consolidation,
internationalization and “don’t handle”. There may be a need for more than one
method of indicating the current rules to ensure proper communication of state
to the visually impaired.
Overrides for the current string management rules will be
available via right click menus or via key chords that will be available while
the cursor is within the bounds of the string.
A mechanism will be provided to allow the entry and display
of long strings without the need for horizontal scrolling.
Advanced editing
Advanced editing comes into play when the user wants to
display formatted text. The following java.text based formats will be
supported.
- Number
format
- Decimal
format
- Choice
format
- Message
format (multi-part strings)
Both assisted and expert modes
will be provided with auto-recognition of the mode chosen. This feature will
include string preview that will show the result of the string formatting. The
exact presentation of this feature will be subject to experimentation do
determine the best human factors.
Editing the backing code
When string consolidation or internationalization is in
effect, actual access to the string will be via code generated by the tool.
Normally it should not be necessary to edit this code but the tool will provide
a means to allow this if necessary. The same basic mechanism will also permit
reading the backing code without editing when necessary.
Maintenance
Changes to the default language strings can be made at any
time by a developer. When changes are made to any of the strings in a
compilation unit that is internationalized, an Eclipse task will be generated
to indicate that there is translation work to do for the compilation unit. Only
one task per compilation unit will be outstanding for each target language for
each compilation unit.
Configuration
A user can configure the following aspects of string
management.
- Whether
duplicate strings can be consolidated.
- Whether
strings are to be internationalized.
- Which
languages and cultural environments are to be supported for string
internationalization? Languages and cultural environments may be added and
removed at any time.
- The
name of the resource file that will be used to store strings.
Configuration options can be
specified on a workspace or project basis. Project options override workspace
options.
Translation
The following services will be provided to support the
translation of strings into the various target environments. A basic assumption
will be that the translator will work in an Eclipse workspace, just as
developers do.
- Eclipse
tasks will be used to locate the units of work to be translated.
- Translators
can specify the source and target languages/locales they will be working in.
The default source language will be the default language for the workspace
or project.
- A
specialized translation editor will be provided that will provide the
following services.
- Display
of source and target strings.
- Display
of string context.
- Editing
of target strings.
- Evaluation
of multi-part strings so the translator can see the result of translation
decisions.
- The
ability to generate Eclipse tasks identifying problem areas that must be
worked on by a software developer before translation can continue. The
ability to fully describe the problem will be included.
Extendibility
In keeping with the spirit of Eclipse, this tool will be
designed as a framework with extension points that will permit the adaptation
of the framework to different target environments. The initial implementation
will target Java language development.
Deployment
Deployment can create special problems for string
management. Individual classes and packages may be deployed into a multitude of
environments and the same classes may be deployed into multiple environments at
the same time. Tools are needed to ensure that al the associated strings are
packaged and deployed with their associated classes.
Another problem is that the execution environment may vary
considerably. Applets may be deployed into a security-constrained environment
for example where there may be no access to the operating system environment.
EJBs’ have their own set of constraints that must be met.
These considerations lead to the conclusion that the string
data must be deployable in the same Jars as the application code that uses the
strings.
Export
It is necessary to be able to move code using the mechanisms
supported by this tool to other environments. Two facilities will be provided:
- Export
the code with the strings from a user selected language/locale embedded in
the source code.
- Export
the code converted to use standard Java ResourceBundle techniques and
property files.
Performance
String management is one of the areas that has been
identified by the Eclipse team as a performance problem area. Specifically the
techniques used by the Eclipse string internationalization tool have been cited
(see http://www.eclipse.org/eclipse/development/performance/bloopers.html
for details). This tool will use an optimized implementation for string storage
and retrieval including lazy string retrieval to minimize the overhead in
managing the string environment.
Design Overview