OrekitMessages.java

  1. /* Copyright 2002-2018 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.errors;

  18. import java.io.IOException;
  19. import java.io.InputStream;
  20. import java.io.InputStreamReader;
  21. import java.net.URL;
  22. import java.net.URLConnection;
  23. import java.util.Locale;
  24. import java.util.MissingResourceException;
  25. import java.util.PropertyResourceBundle;
  26. import java.util.ResourceBundle;

  27. import org.hipparchus.exception.Localizable;

  28. /**
  29.  * Enumeration for localized messages formats.
  30.  * <p>
  31.  * The constants in this enumeration represent the available
  32.  * formats as localized strings. These formats are intended to be
  33.  * localized using simple properties files, using the constant
  34.  * name as the key and the property value as the message format.
  35.  * The source English format is provided in the constants themselves
  36.  * to serve both as a reminder for developers to understand the parameters
  37.  * needed by each format, as a basis for translators to create
  38.  * localized properties files, and as a default format if some
  39.  * translation is missing.
  40.  * </p>
  41.  * @since 2.1
  42.  */
  43. public enum OrekitMessages implements Localizable {

  44.     // CHECKSTYLE: stop JavadocVariable check

  45.     INTERNAL_ERROR("internal error, contact maintenance at {0}"),
  46.     ALTITUDE_BELOW_ALLOWED_THRESHOLD("altitude ({0} m) is below the {1} m allowed threshold"),
  47.     POINT_INSIDE_ELLIPSOID("point is inside ellipsoid"),
  48.     TRAJECTORY_INSIDE_BRILLOUIN_SPHERE("trajectory inside the Brillouin sphere (r = {0})"),
  49.     ALMOST_EQUATORIAL_ORBIT("almost equatorial orbit (i = {0} degrees)"),
  50.     ALMOST_CRITICALLY_INCLINED_ORBIT("almost critically inclined orbit (i = {0} degrees)"),
  51.     UNABLE_TO_COMPUTE_ECKSTEIN_HECHLER_MEAN_PARAMETERS("unable to compute Eckstein-Hechler mean parameters after {0} iterations"),
  52.     NULL_PARENT_FOR_FRAME("null parent for frame {0}"),
  53.     FRAME_ALREADY_ATTACHED("frame {0} is already attached to frame {1}"),
  54.     FRAME_NOT_ATTACHED("frame {0} is not attached to the main frames tree"),
  55.     FRAME_ANCESTOR_OF_BOTH_FRAMES("frame {0} is an ancestor of both frames {1} and {2}"),
  56.     FRAME_ANCESTOR_OF_NEITHER_FRAME("frame {0} is an ancestor of neither frame {1} nor {2}"),
  57.     FRAME_NO_NTH_ANCESTOR("frame {0} has depth {1}, it cannot have an ancestor {2} levels above"),
  58.     NO_SUCH_ITRF_FRAME("ITRF frame {0} not found"),
  59.     UNSUPPORTED_LOCAL_ORBITAL_FRAME("unsupported local orbital frame, supported types: {0} and {1}"),
  60.     NON_PSEUDO_INERTIAL_FRAME("non pseudo-inertial frame \"{0}\""),
  61.     DATA_ROOT_DIRECTORY_DOES_NOT_EXIST("data root directory {0} does not exist"),
  62.     NOT_A_DIRECTORY("{0} is not a directory"),
  63.     NEITHER_DIRECTORY_NOR_ZIP_OR_JAR("{0} is neither a directory nor a zip/jar archive file"),
  64.     UNABLE_TO_FIND_RESOURCE("unable to find resource {0} in classpath"),
  65.     NO_EARTH_ORIENTATION_PARAMETERS_LOADED("no Earth Orientation Parameters loaded"),
  66.     MISSING_EARTH_ORIENTATION_PARAMETERS_BETWEEN_DATES("missing Earth Orientation Parameters between {0} and {1}"),
  67.     NO_EARTH_ORIENTATION_PARAMETERS("missing Earth Orientation Parameters"),
  68.     NOT_A_SUPPORTED_IERS_DATA_FILE("file {0} is not a supported IERS data file"),
  69.     INCONSISTENT_DATES_IN_IERS_FILE("inconsistent dates in IERS file {0}: {1}-{2}-{3} and MJD {4}"),
  70.     UNEXPECTED_DATA_AFTER_LINE_IN_FILE("unexpected data after line {0} in file {1}: {2}"),
  71.     NON_CHRONOLOGICAL_DATES_IN_FILE("non-chronological dates in file {0}, line {1}"),
  72.     NO_IERS_UTC_TAI_HISTORY_DATA_LOADED("no IERS UTC-TAI history data loaded"),
  73.     NO_ENTRIES_IN_IERS_UTC_TAI_HISTORY_FILE("no entries found in IERS UTC-TAI history file {0}"),
  74.     MISSING_SERIE_J_IN_FILE("missing serie j = {0} in file {1} (line {2})"),
  75.     CANNOT_PARSE_BOTH_TAU_AND_GAMMA("cannot parse both τ and γ from the same Poissons series file"),
  76.     UNEXPECTED_END_OF_FILE_AFTER_LINE("unexpected end of file {0} (after line {1})"),
  77.     UNABLE_TO_PARSE_LINE_IN_FILE("unable to parse line {0} of file {1}:\n{2}"),
  78.     UNABLE_TO_FIND_FILE("unable to find file {0}"),
  79.     SPACECRAFT_MASS_BECOMES_NEGATIVE("spacecraft mass becomes negative: {0} kg"),
  80.     POSITIVE_FLOW_RATE("positive flow rate (q: {0})"),
  81.     NO_GRAVITY_FIELD_DATA_LOADED("no gravity field data loaded"),
  82.     GRAVITY_FIELD_NORMALIZATION_UNDERFLOW("gravity field normalization underflow for degree {0} and order {1}"),
  83.     NO_OCEAN_TIDE_DATA_LOADED("no ocean tide data loaded"),
  84.     OCEAN_TIDE_DATA_DEGREE_ORDER_LIMITS("ocean tide data file {0} limited to degree {1} and order {2}"),
  85.     OCEAN_TIDE_LOAD_DEFORMATION_LIMITS("load deformation coefficients limited to degree {0}, cannot parse degree {1} term from file {2}"),
  86.     POLAR_TRAJECTORY("polar trajectory (distance to polar axis: {0})"),
  87.     UNEXPECTED_FILE_FORMAT_ERROR_FOR_LOADER("unexpected format error for file {0} with loader {1}"),
  88.     DUPLICATED_GRAVITY_FIELD_COEFFICIENT_IN_FILE("duplicated gravity field coefficient {0}({1}, {2}) in file {3}"),
  89.     MISSING_GRAVITY_FIELD_COEFFICIENT_IN_FILE("missing gravity field coefficient {0}({1}, {2}) in file {3}"),
  90.     TOO_LARGE_DEGREE_FOR_GRAVITY_FIELD("too large degree (n = {0}, potential maximal degree is {1})"),
  91.     TOO_LARGE_ORDER_FOR_GRAVITY_FIELD("too large order (m = {0}, potential maximal order is {1})"),
  92.     SEVERAL_REFERENCE_DATES_IN_GRAVITY_FIELD("several reference dates ({0} and {1}) found in gravity field file {2}"),
  93.     NO_TLE_FOR_OBJECT("no TLE data available for object {0}"),
  94.     NO_TLE_FOR_LAUNCH_YEAR_NUMBER_PIECE("no TLE data available for launch year {0}, launch number {1}, launch piece {2}"),
  95.     NOT_TLE_LINES("lines {0} and {1} are not TLE lines:\n{0}: \"{2}\"\n{1}: \"{3}\""),
  96.     MISSING_SECOND_TLE_LINE("expected a second TLE line after line {0}:\n{0}: \"{1}\""),
  97.     TLE_LINES_DO_NOT_REFER_TO_SAME_OBJECT("TLE lines do not refer to the same object:\n{0}\n{1}"),
  98.     TLE_INVALID_PARAMETER("invalid TLE parameter for object {0}: {1} = {2}"),
  99.     TLE_CHECKSUM_ERROR("wrong checksum of TLE line {0}, expected {1} but got {2} ({3})"),
  100.     NO_TLE_DATA_AVAILABLE("no TLE data available"),
  101.     NOT_POSITIVE_SPACECRAFT_MASS("spacecraft mass is not positive: {0} kg"),
  102.     TOO_LARGE_ECCENTRICITY_FOR_PROPAGATION_MODEL("too large eccentricity for propagation model: e = {0}"),
  103.     NO_SOLAR_ACTIVITY_AT_DATE("no solar activity available at {0}, data available only in range [{1}, {2}]"),
  104.     NON_EXISTENT_MONTH("non-existent month {0}"),
  105.     NON_EXISTENT_YEAR_MONTH_DAY("non-existent date {0}-{1}-{2}"),
  106.     NON_EXISTENT_WEEK_DATE("non-existent week date {0}-W{1}-{2}"),
  107.     NON_EXISTENT_DATE("non-existent date {0}"),
  108.     NON_EXISTENT_DAY_NUMBER_IN_YEAR("no day number {0} in year {1}"),
  109.     NON_EXISTENT_HMS_TIME("non-existent time {0}:{1}:{2}"),
  110.     NON_EXISTENT_TIME("non-existent time {0}"),
  111.     OUT_OF_RANGE_SECONDS_NUMBER("out of range seconds number: {0}"),
  112.     ANGLE_TYPE_NOT_SUPPORTED("angle type not supported, supported angles: {0}, {1} and {2}"),
  113.     SATELLITE_COLLIDED_WITH_TARGET("satellite collided with target"),
  114.     ATTITUDE_POINTING_LAW_DOES_NOT_POINT_TO_GROUND("attitude pointing law misses ground"),
  115.     TOO_SHORT_TRANSITION_TIME_FOR_ATTITUDES_SWITCH("{0} seconds transition time for attitudes switch is too short, should be longer than {1} seconds"),
  116.     ORBIT_AND_ATTITUDE_DATES_MISMATCH("orbit date ({0}) does not match attitude date ({1})"),
  117.     FRAMES_MISMATCH("frame {0} does not match frame {1}"),
  118.     INITIAL_STATE_NOT_SPECIFIED_FOR_ORBIT_PROPAGATION("initial state not specified for orbit propagation"),
  119.     PROPAGATOR_NOT_IN_EPHEMERIS_GENERATION_MODE("propagator is not in ephemeris generation mode"),
  120.     EVENT_DATE_TOO_CLOSE("event date {0}, greater than {1} minus {3} seconds and smaller than {2} plus {3} seconds, cannot be added"),
  121.     UNABLE_TO_READ_JPL_HEADER("unable to read header record from JPL ephemerides binary file {0}"),
  122.     INCONSISTENT_ASTRONOMICAL_UNIT_IN_FILES("inconsistent values of astronomical unit in JPL ephemerides files: ({0} and {1})"),
  123.     INCONSISTENT_EARTH_MOON_RATIO_IN_FILES("inconsistent values of Earth/Moon mass ratio in JPL ephemerides files: ({0} and {1})"),
  124.     NO_DATA_LOADED_FOR_CELESTIAL_BODY("no data loaded for celestial body {0}"),
  125.     NOT_A_JPL_EPHEMERIDES_BINARY_FILE("file {0} is not a JPL ephemerides binary file"),
  126.     NOT_A_MARSHALL_SOLAR_ACTIVITY_FUTURE_ESTIMATION_FILE("file {0} is not a Marshall Solar Activity Future Estimation (MSAFE) file"),
  127.     NO_JPL_EPHEMERIDES_BINARY_FILES_FOUND("no JPL ephemerides binary files found"),
  128.     OUT_OF_RANGE_BODY_EPHEMERIDES_DATE("out of range date for {0} ephemerides: {1}"),
  129.     OUT_OF_RANGE_EPHEMERIDES_DATE("out of range date for ephemerides: {0}, [{1}, {2}]"),
  130.     UNEXPECTED_TWO_ELEVATION_VALUES_FOR_ONE_AZIMUTH("unexpected two elevation values: {0} and {1}, for one azimuth: {2}"),
  131.     UNSUPPORTED_PARAMETER_NAME("unsupported parameter name {0}, supported names: {1}"),
  132.     TOO_SMALL_SCALE_FOR_PARAMETER("scale factor for parameter {0} is too small: {1}"),
  133.     UNKNOWN_ADDITIONAL_STATE("unknown additional state \"{0}\""),
  134.     UNKNOWN_MONTH("unknown month \"{0}\""),
  135.     SINGULAR_JACOBIAN_FOR_ORBIT_TYPE("Jacobian matrix for type {0} is singular with current orbit"),
  136.     STATE_JACOBIAN_NOT_INITIALIZED("state Jacobian has not been initialized yet"),
  137.     STATE_JACOBIAN_NOT_6X6("state Jacobian is a {0}x{1} matrix, it should be a 6x6 matrix"),
  138.     STATE_AND_PARAMETERS_JACOBIANS_ROWS_MISMATCH("state Jacobian has {0} rows but parameters Jacobian has {1} rows"),
  139.     INITIAL_MATRIX_AND_PARAMETERS_NUMBER_MISMATCH("initial Jacobian matrix has {0} columns, but {1} parameters have been selected"),
  140.     ORBIT_A_E_MISMATCH_WITH_CONIC_TYPE("orbit should be either elliptic with a > 0 and e < 1 or hyperbolic with a < 0 and e > 1, a = {0}, e = {1}"),
  141.     ORBIT_ANOMALY_OUT_OF_HYPERBOLIC_RANGE("true anomaly {0} out of hyperbolic range (e = {1}, {2} < v < {3})"),
  142.     HYPERBOLIC_ORBIT_NOT_HANDLED_AS("hyperbolic orbits cannot be handled as {0} instances"),
  143.     CCSDS_DATE_INVALID_PREAMBLE_FIELD("invalid preamble field in CCSDS date: {0}"),
  144.     CCSDS_DATE_INVALID_LENGTH_TIME_FIELD("invalid time field length in CCSDS date: {0}, expected {1}"),
  145.     CCSDS_DATE_MISSING_AGENCY_EPOCH("missing agency epoch in CCSDS date"),
  146.     CCSDS_UNEXPECTED_KEYWORD("unexpected keyword in CCSDS line number {0} of file {1}:\n{2}"),
  147.     CCSDS_UNKNOWN_GM("the central body gravitational coefficient cannot be retrieved from the ODM"),
  148.     CCSDS_UNKNOWN_SPACECRAFT_MASS("there is no spacecraft mass associated with this ODM file"),
  149.     CCSDS_UNKNOWN_CONVENTIONS("no IERS conventions have been set before parsing"),
  150.     CCSDS_INVALID_FRAME("frame {0} is not valid in this ODM file context"),
  151.     CCSDS_OEM_INCONSISTENT_TIME_SYSTEMS("inconsistent time systems in the ephemeris blocks: {0} ≠ {1}"),
  152.     CCSDS_TIME_SYSTEM_NOT_IMPLEMENTED("use of time system {0} in CCSDS files requires an additional ICD and is not implemented in Orekit"),
  153.     CCSDS_NO_CORRESPONDING_TIME_SCALE("the CCSDS time system {0} has no corresponding Orekit TimeScale."),
  154.     CCSDS_TDM_INCONSISTENT_TIME_SYSTEMS("Inconsistent time systems in the observations blocks: {0} ≠ {1}"),
  155.     CCSDS_TDM_INCONSISTENT_DATA_LINE("Inconsistent data line in TDM file at line {0} of file {1}.\n" +
  156.                                      "A TDM data line should be as follows \"keyword = epoch value\".\n" +
  157.                                      "Whereas read data line is: {2}"),
  158.     CCSDS_TDM_XML_INCONSISTENT_DATA_BLOCK("Inconsistent XML observation block at line {0} of TDM file {1}.\n" +
  159.                                          "A TDM observation block should be as follows\n\t<observation>\n\t\t<EPOCH>epoch</EPOCH>\n" +
  160.                                          "\t\t<KEYWORD>value</KEYWORD>\n\t</observation>"),
  161.     CCSDS_TDM_KEYWORD_NOT_FOUND("No CCSDS TDM keyword was found at line {0} of file {1}:\n{2}"),
  162.     CCSDS_TIME_SYSTEM_NOT_READ_YET("Parameter {0} needs a time system to be interpreted"),
  163.     CCSDS_TDM_UNKNOWN_FORMAT("TDM file {0} format is unknown. Please specify a file format: KEYVALUE or XML"),
  164.     ADDITIONAL_STATE_NAME_ALREADY_IN_USE("name \"{0}\" is already used for an additional state"),
  165.     NON_RESETABLE_STATE("reset state not allowed"),
  166.     DSST_NEWCOMB_OPERATORS_COMPUTATION("Cannot compute Newcomb operators for sigma > rho ({0} > {1})"),
  167.     DSST_VMNS_COEFFICIENT_ERROR_MS("Cannot compute the Vmns coefficient with m > n ({0} > {1})"),
  168.     DSST_SPR_SHADOW_INCONSISTENT("inconsistent shadow computation: entry = {0} whereas exit = {1}"),
  169.     DSST_ECC_NO_NUMERICAL_AVERAGING_METHOD("The current orbit has an eccentricity ({0} > 0.5). DSST needs an unimplemented time dependent numerical method to compute the averaged rates"),
  170.     SP3_UNSUPPORTED_VERSION("unsupported sp3 file version {0}"),
  171.     SP3_NUMBER_OF_EPOCH_MISMATCH("found {0} epochs in file {1}, expected {2}"),
  172.     SP3_UNEXPECTED_END_OF_FILE("unexpected end of sp3 file (after line {0})"),
  173.     NON_EXISTENT_GEOMAGNETIC_MODEL("non-existent geomagnetic model {0} for year {1}"),
  174.     UNSUPPORTED_TIME_TRANSFORM("geomagnetic model {0} with epoch {1} does not support time transformation, no secular variation coefficients defined"),
  175.     OUT_OF_RANGE_TIME_TRANSFORM("time transformation of geomagnetic model {0} with epoch {1} is outside its validity range: {2} != [{3}, {4}]"),
  176.     NOT_ENOUGH_DATA_FOR_INTERPOLATION("not enough data for interpolation (sample size = {0})"),
  177.     NOT_ENOUGH_CACHED_NEIGHBORS("too small number of cached neighbors: {0} (must be at least {1})"),
  178.     NO_CACHED_ENTRIES("no cached entries"),
  179.     NON_CHRONOLOGICALLY_SORTED_ENTRIES("generated entries not sorted: {0} > {1}"),
  180.     NO_DATA_GENERATED("no data generated around date: {0}"),
  181.     UNABLE_TO_GENERATE_NEW_DATA_BEFORE("unable to generate new data before {0}"),
  182.     UNABLE_TO_GENERATE_NEW_DATA_AFTER("unable to generate new data after {0}"),
  183.     UNABLE_TO_COMPUTE_HYPERBOLIC_ECCENTRIC_ANOMALY("unable to compute hyperbolic eccentric anomaly from the mean anomaly after {0} iterations"),
  184.     UNABLE_TO_COMPUTE_DSST_MEAN_PARAMETERS("unable to compute mean orbit from osculating orbit after {0} iterations"),
  185.     OUT_OF_RANGE_DERIVATION_ORDER("derivation order {0} is out of range"),
  186.     OUT_OF_RANGE_LATITUDE("out of range latitude: {0}, [{1}, {2}]"),
  187.     ORBIT_TYPE_NOT_ALLOWED("orbit type {0} not allowed here, allowed types: {1}"),
  188.     NO_SEM_ALMANAC_AVAILABLE("no SEM almanac file found"),
  189.     NOT_A_SUPPORTED_SEM_ALMANAC_FILE("file {0} is not a supported SEM almanac file"),
  190.     NO_YUMA_ALMANAC_AVAILABLE("no Yuma almanac file found"),
  191.     NOT_A_SUPPORTED_YUMA_ALMANAC_FILE("file {0} is not a supported Yuma almanac file"),
  192.     NOT_ENOUGH_GNSS_FOR_DOP("only {0} GNSS orbits are provided while {1} are needed to compute the DOP"),
  193.     NOT_ENOUGH_PROPAGATORS("Creating an aggregate propagator requires at least one constituent propagator, but none were provided."),
  194.     NULL_ARGUMENT("argument {0} cannot be null"),
  195.     VALUE_NOT_FOUND("value {0} not found in {1}"),
  196.     EPHEMERIS_FILE_NO_MULTI_SUPPORT("Ephemeris file format does not support multiple space objects"),
  197.     KLOBUCHAR_ALPHA_BETA_NOT_LOADED("Klobuchar coefficients α or β could not be loaded from {0}"),
  198.     KLOBUCHAR_ALPHA_BETA_NOT_AVAILABLE_FOR_DATE("Klobuchar coefficients α or β not available for date {0}"),
  199.     NO_KLOBUCHAR_ALPHA_BETA_IN_FILE("file {0} does not contain Klobuchar coefficients α or β"),
  200.     NO_REFERENCE_DATE_FOR_PARAMETER("no reference date set for parameter {0}"),
  201.     STATION_NOT_FOUND("station {0} not found, known stations: {1}"),
  202.     UNKNOWN_SATELLITE_SYSTEM("unknown satellite system {0}"),
  203.     UNKNOWN_SATELLITE_ANTENNA_CODE("unknown satellite antenna code {0}"),
  204.     CANNOT_FIND_SATELLITE_IN_SYSTEM("cannot find satellite {0} in satellite system {1}"),
  205.     UNKNOWN_RINEX_FREQUENCY("unknown RINEX frequency {0} in file {1}, line {2}"),
  206.     MISMATCHED_FREQUENCIES("mismatched frequencies in file {0}, line {1} (expected {2}, got {3})"),
  207.     WRONG_COLUMNS_NUMBER("wrong number of columns in file {0}, line {1} (expected {2} columns, got {3} columns)"),
  208.     UNSUPPORTED_FILE_FORMAT("unsupported format for file {0}"),
  209.     INCOMPLETE_HEADER("incomplete header in file {0}"),
  210.     INCONSISTENT_NUMBER_OF_SATS("inconsistent number of satellites in line {0}, file {1}: observation with {2} satellites and number of max satellites is {3}"),
  211.     INCONSISTENT_SATELLITE_SYSTEM("the satellite system {3} from line {0}, file {1} is not consistent with the Rinex Satellite System {2} in header"),
  212.     NO_PROPAGATOR_CONFIGURED("no propagator configured"),
  213.     DIMENSION_INCONSISTENT_WITH_PARAMETERS("dimension {0} is inconsistent with parameters list: {1}"),
  214.     NOT_A_SUPPORTED_UNIX_COMPRESSED_FILE("file {0} is not a supported Unix-compressed file"),
  215.     UNEXPECTED_END_OF_FILE("unexpected end of file {0}"),
  216.     CORRUPTED_FILE("file {0} is corrupted");


  217.     // CHECKSTYLE: resume JavadocVariable check

  218.     /** Base name of the resource bundle in classpath. */
  219.     private static final String RESOURCE_BASE_NAME = "assets/org/orekit/localization/OrekitMessages";

  220.     /** Source English format. */
  221.     private final String sourceFormat;

  222.     /** Simple constructor.
  223.      * @param sourceFormat source English format to use when no
  224.      * localized version is available
  225.      */
  226.     OrekitMessages(final String sourceFormat) {
  227.         this.sourceFormat = sourceFormat;
  228.     }

  229.     /** {@inheritDoc} */
  230.     public String getSourceString() {
  231.         return sourceFormat;
  232.     }

  233.     /** {@inheritDoc} */
  234.     public String getLocalizedString(final Locale locale) {
  235.         try {
  236.             final ResourceBundle bundle =
  237.                     ResourceBundle.getBundle(RESOURCE_BASE_NAME, locale, new UTF8Control());
  238.             if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) {
  239.                 final String translated = bundle.getString(name());
  240.                 if ((translated != null) &&
  241.                     (translated.length() > 0) &&
  242.                     (!translated.toLowerCase().contains("missing translation"))) {
  243.                     // the value of the resource is the translated format
  244.                     return translated;
  245.                 }
  246.             }

  247.         } catch (MissingResourceException mre) {
  248.             // do nothing here
  249.         }

  250.         // either the locale is not supported or the resource is not translated or
  251.         // it is unknown: don't translate and fall back to using the source format
  252.         return sourceFormat;

  253.     }

  254.     /** Control class loading properties in UTF-8 encoding.
  255.      * <p>
  256.      * This class has been very slightly adapted from BalusC answer to question: <a
  257.      * href="http://stackoverflow.com/questions/4659929/how-to-use-utf-8-in-resource-properties-with-resourcebundle">
  258.      * How to use UTF-8 in resource properties with ResourceBundle</a>.
  259.      * </p>
  260.      * @since 6.0
  261.      */
  262.     public static class UTF8Control extends ResourceBundle.Control {

  263.         /** {@inheritDoc} */
  264.         @Override
  265.         public ResourceBundle newBundle(final String baseName, final Locale locale, final String format,
  266.                                         final ClassLoader loader, final boolean reload)
  267.             throws IllegalAccessException, InstantiationException, IOException {
  268.             // The below is a copy of the default implementation.
  269.             final String bundleName = toBundleName(baseName, locale);
  270.             final String resourceName = toResourceName(bundleName, "utf8");
  271.             ResourceBundle bundle = null;
  272.             InputStream stream = null;
  273.             if (reload) {
  274.                 final URL url = loader.getResource(resourceName);
  275.                 if (url != null) {
  276.                     final URLConnection connection = url.openConnection();
  277.                     if (connection != null) {
  278.                         connection.setUseCaches(false);
  279.                         stream = connection.getInputStream();
  280.                     }
  281.                 }
  282.             } else {
  283.                 stream = loader.getResourceAsStream(resourceName);
  284.             }
  285.             if (stream != null) {
  286.                 try {
  287.                     // Only this line is changed to make it to read properties files as UTF-8.
  288.                     bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
  289.                 } finally {
  290.                     stream.close();
  291.                 }
  292.             }
  293.             return bundle;
  294.         }
  295.     }
  296. }