getPhrases returns empty object

Enonic version: 6.12.0
OS: macOS Sierra Version 10.12.6

I’m trying to use getPhrases in i18n (com.enonic.xp:lib-i18n:6.12.0). I can use i18n.localize('some.phrase') without any problems, but i18nLib.getPhrases() only returns an empty object. i18n.getPhrases('en', ['phrases']) also returns an empty object.

The method getPhrases in admin (com.enonic.xp:lib-admin:6.12.0) also returns an empty object.

Hi

As you said, i18n.getPhrases requires two arguments: locale and bundles, so i18n.getPhrases() will never work.

I believe your problem is caused by incorrect path to a bundle. Given that you have the following structure:

resources
--admin
----i18n
------Resource Bundle 'phrases'

the call should look like this:

i18n.getPhrases('en', ['admin/i18n/phrases'])

I’ve just tested it and it works fine.

You are completely correct. I’m sorry that I didn’t figure this out on my own, the documentation is a bit difficult to read sometimes =/

1 Like

Great that you got it to work. We’ll try to improve the docs :slight_smile:

1 Like