}
}
- public String message(final Locale locale, final String key, final String defaultText, final Object... objects) {
+ public String message(final Locale locale, final String key, final String defaultText, final Object... objects)
+ {
String result = defaultText;
try {
String bundleBaseName = keys.get(key);
if (bundleBaseName == null) {
+ if (result == null)
+ throw new MissingResourceException("UNKNOWN KEY : Key '" + key + "' not found in any bundle.", bundleBaseName, key);
LOG.warn("UNKNOWN KEY : Key '{}' not found in any bundle. Default value '{}' is returned.", key, defaultText);
unknownKeys.put(key, defaultText);
} else {
String value = bundle.getString(key);
if ("".equals(value)) {
+ if (result == null)
+ throw new MissingResourceException("VOID KEY : Key '" + key + "' (from bundle '" + bundleBaseName + "') returns a void value.", bundleBaseName, key);
LOG.warn("VOID KEY : Key '{}' (from bundle '{}') returns a void value. Default value '{}' is returned.", new Object[]{key,
bundleBaseName, defaultText});
} else {
result = value;
}
} catch (MissingResourceException e) {
+ if (result == null)
+ throw e;
LOG.warn("BUNDLE NOT LOADED : Failed loading bundle {} from classloader {}. Default value '{}' is returned.", new Object[]{
bundleBaseName, bundleClassLoader, defaultText});
}
}
} catch (Exception e) {
LOG.error("Exception when retrieving I18n string.", e);
+ if (result == null)
+ throw new SonarException("Exception when retrieving I18n string.", e);
}
if (objects.length > 0) {
end
# i18n
- def message(key, default, *parameters)
- Java::OrgSonarServerUi::JRubyFacade.getInstance().getI18nMessage(I18n.locale, key, default, parameters.to_java)
+ def message(key, options={})
+ default = options[:default]
+ params = options[:params]
+ if params.nil?
+ params=[]
+ end
+ Java::OrgSonarServerUi::JRubyFacade.getInstance().getI18nMessage(I18n.locale, key, default, params.to_java)
end
# deprecated since 2.5. Use trend_icon() instead
» <a href="<%= ApplicationController.root_context -%>/sessions/logout">Log out</a>
</li>
<% else %>
- <li><a href="<%= ApplicationController.root_context -%>/sessions/new"><%= message('app.view.layouts.layout.login', 'Log in') -%></a></li>
+ <li><a href="<%= ApplicationController.root_context -%>/sessions/new"><%= message('web.layouts.login', :default => 'Log {0}', :params => ['in']) -%></a></li>
<% end %>
<li><a href="<%= ApplicationController.root_context -%>/profiles">Configuration</a></li>
</ol>