Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-2158

Localization of plugin titles

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • webconsole-3.0.0
    • Web Console
    • None

    Description

      We have added localization support, but there is one thing missing - the titles of the plugins, that are rendered on top.

      So now, even though the plugins are completely localized, the navigation between the plugins is not. However, we need to keep the web console compatible with the old API, so the change should be transparent.

      I've been thinking about the problem and came to the following solution:

      when request is made, the webconsole will:
      1. obtain the resource bundle for plugins
      2. for each plugin
      3. get the localized title, which is a resource key <pluginLabel>.pluginTitle
      4. if the localized title doesn't exist - then use the default title
      5. fill in the labelMap table

      the reason for using <pluginLabel>.pluginTitle instead of some other constant name is that a bundle can provide more than one plugins, as example webconsole itself. In this case we need to provide titles for all plugins and this involves the label.

      This can be achieved easily by adding the following method in OsgiManager:
      private final Map localizedLabelMap(final Locale locale)
      {
      Map map = new HashMap();
      ResourceBundle resourceBundle;
      AbstractWebConsolePlugin plugin;
      String label;
      String title;
      for (Iterator pi = plugins.values().iterator(); pi.hasNext()
      {
      plugin = (AbstractWebConsolePlugin) pi.next();
      resourceBundle = resourceBundleManager.getResourceBundle(plugin.getBundle(),
      locale);
      label = plugin.getLabel();
      title = plugin.getTitle();
      try
      {
      final String res = plugin.getLabel() + ".pluginTitle";
      title = resourceBundle.getString(res);
      // our Resource Bundle doesn't throw exception, so if
      // the value is same as the property key - revert to
      // the original title
      if (title.equals(res))

      { title = plugin.getTitle(); }

      }
      catch (Throwable e)

      { /* ignore missing resource - use default title */ }

      map.put(label, title);
      }

      return map;
      }

      and modify the service() method as follows:
      Map labelMap = localizedLabelMap(request.getLocale());
      // the official request attributes
      req.setAttribute( WebConsoleConstants.ATTR_LABEL_MAP, labelMap );

      Attachments

        1. FELIX-2158.patch
          2 kB
          Felix Meschberger
        2. FELIX-2158-2.patch
          9 kB
          Felix Meschberger

        Activity

          People

            fmeschbe Felix Meschberger
            v_valchev Valentin Valchev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: