Toolbar Item Internationalization Issue

I am not exactly sure if I am missing something obvious here,

But in trying to add in a toolbar menu item, I have found that the internationalization for it is acting a bit funny.

I have a bundle I am adding in during my designer hook startup:

BundleUtil.get().addBundle("projectscan", this.getClass(), "designer");

To pull values out of it for the UI in general I am using the following syntax:

BundleUtil.get().getString("projectscan.Action.ScanProject.Description")

That is working great for that description being used as a tooltip:

Here is the action that was used in:

 public ProjectScanAction(DesignerContext context, Icon icon) {
        super(BundleUtil.get().getString("projectscan.Action.ScanProject.Name"), icon);
        this.context = context;
        putValue(SHORT_DESCRIPTION, BundleUtil.get().getString("projectscan.Action.ScanProject.Description"));
        logger.info("Project Scan Action initialized");
    }

However on the actual toolbar name itself, it seems that maybe some double localization is attempting to happen here? because the text comes through localized by whatever I put in the .properties file, but always has the ?s around it. Then if I set it to something not in the properties file, I get double ??s around it? Which makes it feel like it's trying to localize what I have already localized.

So if I remove the BundleUtil.get().getString( call in the toolbar title, everything is totally normal and no ?s?

I mean, I figured it out eventually, but how could I have known that this piece of text would attempt to localize without having to use BundleUtils, and am I doing localization in a weird way? or is this what's expected?

This is the one that double-localizes

DesignerToolbar toolbar = new DesignerToolbar(
            "ProjectScan",
            BundleUtil.get().getString("projectscan.Toolbar.Name")
        ); 

This one only localizes one time:

DesignerToolbar toolbar = new DesignerToolbar(
            "ProjectScan",
            "projectscan.Toolbar.Name"
        ); 

The constructor args are named name and titleKey:

That's...basically all you get, since strings are strings are strings. If we name a parameter "key", we're going to rinse it through localization for you. There's no consistent standard on whether a component will do its own localization or expect you to pass localized strings.

Actually found this in the docs too, for anyone in the future

1 Like