How to reference barrel resources from app xml

I have some settings/properties and fit contributions that I have used in a workout app, but now I would like to use some of those in a data field as well.  I'm hoping to keep all the shared string resources (and code) in a barrel that each project will reference.

I'm able to successfully load my barrel string resources from my app code like this:

var emailStr = WatchUi.loadResource(MyBarrel.Rez.Strings.lbl_user_email);

but I'm not having the same luck with my xml.

I've tried this:

<setting propertyKey="@Properties.user_email_prop" title="@MyBarrel.Strings.lbl_user_email">
    <settingConfig type="email" />
</setting>

and this:

<setting propertyKey="@Properties.user_email_prop" title="@MyBarrel.Rez.Strings.lbl_user_email">
    <settingConfig type="email" />
</setting>

I'm not even sure what else to try.

As a workaround, I'm defining my shared string resources in three places: the app, the data field, and the barrel (this is necessary because my barrel also references the strings).  For me this isn't a big deal right now (I only have a half a dozen shared strings), but I can see this easily becoming a bigger deal for me in the future.

  • I just ran into exactly the same issue.  Did you find a way to fix it without duplicating the strings in the barrel and the app?

  • I never found what I would consider a great solution.  Eventually, I stopped using Monkey barrels entirely.  Instead, I just have folders of shared code, and I include the folders I need for a project by setting the resourcePath and sourcePath appropriately.  Its not ideal, but I think it's better than what I was doing before.

  • Thanks for the reply.  I came to the same conclusion and solution.  The only problem with including folders is that I haven't figured out how to get it to see my per-locale/language resources.  Is there a way?

  • It's been a been minutes since I last looked at my code, but I don't remember needing to do anything all that tricky.  I just put a strings.xml in each folder.  If I remember correctly, the compiler combines them all together.
    So I'll have

    GarminFolder
    -Project1
    --resources
    ---strings.xml
    -Project2
    --resources
    ---strings.xml
    -Libraries
    --Library1
    ---resources
    ----strings.xml

    Then in the jungle I have this

    base.resourcePath = resources;..\Libraries\Library1\resources;

  • Yes, that is how I have it structured as well.  The problem is that I can't add ...\resources-due and other language resources because the compiler always only picks up the last resources folder in the path.  There needs to be a root project path, not direct sources and resources.  Is there a 'base' path?

  • When I call multiple libraries, I've been setting the resources in one go like this:

    base.resourcePath = resources;..\Libraries\Library1\resources;..\Libraries\Library2\resources;

    If you can't add all of your libraries at the same time, I'm pretty sure you can reference base.resourcePath like

    base.resourcePath = base.resourcePath;..\Libraries\Library2\resources;

    But, I'm not sure what the syntax is. I'm almost certain I've seen examples of that somewhere, but I can't recall off the top of my head.

  • Thx.

    What I need is to be able to specify something like ces.resourcePath for the languages much like you can for devices and families:  fenix7.resourcePath, venu.resourcePath, etc.

    But it seems the jungle does not support language qualifiers, only device and family.  Oh well.  I'll have to go back to using a barrel after all and work around the original issue that you posted that I ran into.

  • Syntax is base.path = $(base.path);/path/to/otherthings, similar to the annotations expansions, base.BARRELNAME.annotation = $(base.BARRELNAME.annotations);otherannotation and base.barrelPath = $(base.barrelPath);$(BARRELNAME)

  • You should file a bug for it.From how I read the docs it should be supported. https://developer.garmin.com/connect-iq/core-topics/shareable-libraries/ states it should be accessable via @IconLibrary.Drawables.myIcon notation. If not, it is a bug. The only thing that might be an issue is that you don't have annotations or you do have annotations but you don't import those in your project.

  • I think I might finally be seeing what you're talking about. Is this what your looking for? 

    base.lang.deu = $(base.lang.deu);..\Libraries\Library1\resources-deu