diff options
| author | Pierre-Charles David | 2015-08-17 15:35:07 +0000 |
|---|---|---|
| committer | Maxime Porhel | 2015-08-20 12:18:16 +0000 |
| commit | 43def139748524c81aa4c58c5ab8d7f58b56bc0b (patch) | |
| tree | 15e61a14c801b2b74b686c01392010490f1193f9 | |
| parent | 20fa00cfb16730b09eec618502cb3781dbf1d6cf (diff) | |
| download | org.eclipse.sirius-43def139748524c81aa4c58c5ab8d7f58b56bc0b.tar.gz org.eclipse.sirius-43def139748524c81aa4c58c5ab8d7f58b56bc0b.tar.xz org.eclipse.sirius-43def139748524c81aa4c58c5ab8d7f58b56bc0b.zip | |
[472057] Externalize translatable strings from org.eclipse.sirius.ext.base
Externalize all translatable string literals from the source into
plugin.properties, and replace them with references to the corresponding
field in the new Messages class. The values of Messages' field are
initialized from the locale-specific properties file on
initialization (using the I18N helper class introduced earlier).
Bug: 472057
Change-Id: I5f46af745873134538c52525e32c2eb6dc4ab46b
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
9 files changed, 81 insertions, 23 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html index 02c35953bf..fb40895415 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html @@ -223,6 +223,15 @@ <li><span class="label label-success">Added</span> <code>org.eclipse.sirius.ext.base.I18N</code> has been added. It provides common utility code to support internationalization. </li> + <li><span class="label label-success">Added</span> The translation keys (and default values) have been added to all the concerned bundles, in their + <code>plugin.properties</code> file. These (translated) messages are available at runtime as static fields of new + <code>Messages</code> classes, added to all concerned bundles (always in the same package as their plug-in/activator class). The concerned bundles are: + <ul> + <li> + <code>org.eclipse.sirius.ext.base</code> + </li> + </ul> + </li> </ul> <h4 id="Changesinorg.eclipse.sirius.ext.gef">Changes in <code>org.eclipse.sirius.ext.gef</code> diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile index c632d392bb..5cbc18e912 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile @@ -48,6 +48,8 @@ Some API changes were required to enable this. While technically breaking change Additional non-breaking changes: * <span class="label label-success">Added</span> @org.eclipse.sirius.ext.base.I18N@ has been added. It provides common utility code to support internationalization. +* <span class="label label-success">Added</span> The translation keys (and default values) have been added to all the concerned bundles, in their @plugin.properties@ file. These (translated) messages are available at runtime as static fields of new @Messages@ classes, added to all concerned bundles (always in the same package as their plug-in/activator class). The concerned bundles are: +** @org.eclipse.sirius.ext.base@ h4. Changes in @org.eclipse.sirius.ext.gef@ diff --git a/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.html b/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.html index 7973aae608..5910fd4865 100644 --- a/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.html +++ b/plugins/org.eclipse.sirius.doc/doc/user/general/Modeling Project.html @@ -134,7 +134,7 @@ <em>dialect</em> is a kind of representation supported by Sirius. Out of the box, Sirius supports three dialects: diagrams, tables, and trees. Sequence diagrams and cross-tables, which are special kinds of diagrams (resp. tables) can also be considered of as dialects, although technically they are not. </li> <li>a - <em>representation</em> is a particular diagram, table, or tree which you created on your semantic model. It is simply a more general term than “diagram” which is also usable for other dialects. + <em>representation</em> is a particular diagram, table, or tree which you created on your semantic model. It is simply a more general term than «diagram» which is also usable for other dialects. </li> <li>a <em>representation file</em> is a file in which Sirius stores all informations related to which representations you created, what appears on them, the positions and colors of the elements, etc. This files have a @@ -161,7 +161,7 @@ <p>Representation files are now automatically migrated when opened. This migration is transparent for the end-user. While a representation file is not saved, the automatic migration will be replayed at the next opening.</p> <h3 id="UICHanges">User Interface Changes</h3> <p>You will notice some radical changes in the user interface. The most important change is the disappearance of the - <em>Model Content</em> view. It has been replaced with a streamlined UI which integrates directly into the Eclipse explorer view. The notion of “Local Session” has disappeared from the user interface; its management has been made as transparent as possible so you do not have to deal with it except in some very specific circumstances. + <em>Model Content</em> view. It has been replaced with a streamlined UI which integrates directly into the Eclipse explorer view. The notion of «Local Session» has disappeared from the user interface; its management has been made as transparent as possible so you do not have to deal with it except in some very specific circumstances. </p> <p>The recommended way to use Sirius is now to use the new notion of <em>Modeling Project</em> described below. If you already have existing Sirius representation files ( @@ -179,7 +179,7 @@ <li>A <a href="#ModelExplorer"> <em>Model Explorer</em> - </a>, which is the main UI to interact with your models. (For users of previous versions, this explorer includes directly all the features which were found in the “Model Content” view before). + </a>, which is the main UI to interact with your models. (For users of previous versions, this explorer includes directly all the features which were found in the «Model Content» view before). </li> <li>An <em>Outline</em> view, which provides a structural overview of the document or model currently opened. For diagrams, it shows a miniature view of the whole diagram on which you can easily navigate to other parts of the diagram for large ones. @@ -209,13 +209,13 @@ </p> <img border="0" src="images/model_explorer_view.png"/> <p>In the example above, the - <code>example</code> modeling project (note the blue “M” decorator on the project icon) contains a single semantic model, the + <code>example</code> modeling project (note the blue «M» decorator on the project icon) contains a single semantic model, the <code>example.ecore</code> file, and a single representation file <code>representations.aird</code>. Both can be expanded directly from inside the <em>Model Explorer</em> view, to discover the structure of the semantic model and the graphical representations which already exist. </p> <p>The - <em>Model Explorer</em> supports the “Link with Editor” feature, which can be enabled by pressing the icon in the top right corner of the view (the one with two horizontal arrows, pressed in the screenshot above). When this mode is enabled, if you have a representation opened, clicking anywhere on it will automatically select the corresponding semantic element(s) inside the + <em>Model Explorer</em> supports the «Link with Editor» feature, which can be enabled by pressing the icon in the top right corner of the view (the one with two horizontal arrows, pressed in the screenshot above). When this mode is enabled, if you have a representation opened, clicking anywhere on it will automatically select the corresponding semantic element(s) inside the <em>Model Explorer</em> (expanding the project and files if necessary). Conversely, if you select one or several semantic element(s) from one of your semantic models in the <em>Model Explorer</em> view and if these elements are represented somewhere on the opened editor, they will be automatically selected. This can be very useful when you have many projects and representation or large representations to avoid getting lost. </p> @@ -225,7 +225,7 @@ <code>Element</code> in the search box, only the model elements whose name starts with <code>Element</code> will be shown. You can use the <code>*</code> and - <code>?</code> special characters in your search string to mean respectively “any text” (including none) and “any single character”. For example the search string + <code>?</code> special characters in your search string to mean respectively «any text» (including none) and «any single character». For example the search string <code>*Element</code> will show all elements whose name <em>contains</em> the string <code>Element</code> anywhere. @@ -280,7 +280,7 @@ <em>New > Modeling Project</em>. </p> <img border="0" src="images/new_project1.png"/> - <p>A wizard opens, asking for a mandatory project name. Entering an invalid project name will result in an error message. By default, the modeling project will be created in the workspace’s location, but this can be changed: just uncheck “Use default location” and enter the path to the location where you want your modeling project to be created.</p> + <p>A wizard opens, asking for a mandatory project name. Entering an invalid project name will result in an error message. By default, the modeling project will be created in the workspace’s location, but this can be changed: just uncheck «Use default location» and enter the path to the location where you want your modeling project to be created.</p> <img border="0" src="images/new_project2.png"/> <p>When you are done, click <em>Finish</em> to actually create the modeling project. It will appear in the diff --git a/plugins/org.eclipse.sirius.ext.base/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.sirius.ext.base/.settings/org.eclipse.jdt.core.prefs index fc8c7f3ddc..08a3c7721c 100644 --- a/plugins/org.eclipse.sirius.ext.base/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/org.eclipse.sirius.ext.base/.settings/org.eclipse.jdt.core.prefs @@ -350,3 +350,4 @@ org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error diff --git a/plugins/org.eclipse.sirius.ext.base/plugin.properties b/plugins/org.eclipse.sirius.ext.base/plugin.properties index 951afe081a..638f851c4f 100644 --- a/plugins/org.eclipse.sirius.ext.base/plugin.properties +++ b/plugins/org.eclipse.sirius.ext.base/plugin.properties @@ -10,3 +10,8 @@ # ==================================================================== pluginName = Sirius Library Extensions - Base providerName = Eclipse Modeling Project + +DependencyTracker_error_untrackedElement=The specified element is not tracked: {0} +Option_absent=Option: none +Option_present=Option: {0} +TransitiveClosure_message=Transitive closure of {0} diff --git a/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/Messages.java b/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/Messages.java new file mode 100644 index 0000000000..02522db697 --- /dev/null +++ b/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/Messages.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2015 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.ext.base; + +import org.eclipse.sirius.ext.base.I18N.TranslatableMessage; + +/** + * Helper class to obtains translated strings. + * + * @author pcdavid + */ +public final class Messages { + + static { + I18N.initializeMessages(Messages.class, BasePlugin.INSTANCE); + } + + // CHECKSTYLE:OFF + @TranslatableMessage + public static String DependencyTracker_error_untrackedElement; + + @TranslatableMessage + public static String Option_absent; + + @TranslatableMessage + public static String Option_present; + + @TranslatableMessage + public static String TransitiveClosure_message; + + // CHECKSTYLE:ON + + private Messages() { + // Prevents instanciation. + } +} diff --git a/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/Option.java b/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/Option.java index 1192487ded..138bcd43d7 100644 --- a/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/Option.java +++ b/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/Option.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.sirius.ext.base; +import java.text.MessageFormat; + /** * This class means a value which might be here, or not depending on the "some" * method result. This class is useful to indicate to API's clients that a given @@ -71,9 +73,6 @@ public final class Option<T> { return result; } - /** - * {@inheritDoc} - */ @Override public int hashCode() { if (this.some()) { @@ -83,15 +82,12 @@ public final class Option<T> { } } - /** - * {@inheritDoc} - */ @Override public String toString() { if (this.some()) { - return "Option: " + String.valueOf(this.get()); + return MessageFormat.format(Messages.Option_present, String.valueOf(this.get())); } else { - return "Option: none"; + return Messages.Option_absent; } } } diff --git a/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/relations/DependencyTracker.java b/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/relations/DependencyTracker.java index 2ff49d339f..142650bac8 100644 --- a/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/relations/DependencyTracker.java +++ b/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/relations/DependencyTracker.java @@ -10,8 +10,11 @@ *******************************************************************************/ package org.eclipse.sirius.ext.base.relations; +import java.text.MessageFormat; import java.util.Set; +import org.eclipse.sirius.ext.base.Messages; + import com.google.common.base.Preconditions; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableSet; @@ -79,7 +82,7 @@ public class DependencyTracker<T> { */ public Set<T> getDependencies(T element) { Preconditions.checkNotNull(element); - Preconditions.checkArgument(trackedElements.contains(element), "The specified element is not tracked."); + Preconditions.checkArgument(trackedElements.contains(element), MessageFormat.format(Messages.DependencyTracker_error_untrackedElement, element)); return ImmutableSet.copyOf(dependencies.get(element)); } diff --git a/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/relations/TransitiveClosure.java b/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/relations/TransitiveClosure.java index 9d8137e4c0..ca6158fba6 100644 --- a/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/relations/TransitiveClosure.java +++ b/plugins/org.eclipse.sirius.ext.base/src/org/eclipse/sirius/ext/base/relations/TransitiveClosure.java @@ -10,9 +10,12 @@ *******************************************************************************/ package org.eclipse.sirius.ext.base.relations; +import java.text.MessageFormat; import java.util.Collections; import java.util.Set; +import org.eclipse.sirius.ext.base.Messages; + import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -35,9 +38,7 @@ public class TransitiveClosure<T> implements Relation<T> { this.relation = Preconditions.checkNotNull(relation); } - /** - * {@inheritDoc} - */ + @Override public Set<T> apply(T from) { Preconditions.checkNotNull(from); Set<T> result = Sets.newHashSet(relation.apply(from)); @@ -56,11 +57,8 @@ public class TransitiveClosure<T> implements Relation<T> { return Collections.unmodifiableSet(result); } - /** - * {@inheritDoc} - */ @Override public String toString() { - return "Transitive closure of " + relation; + return MessageFormat.format(Messages.TransitiveClosure_message, relation); } } |
