Playcanvas API function Not Working

Hi
I have tried calling findAvailableLocale in localization:
console.log(this.app.i18n.findAvailableLocale(“de”, this.app.i18n._availableLangs));

But console throughs an error:

Please check

looking at the source code, the function is static

so should be called as I18n.findAvailableLocale(...

I’m not sure why it’s not marked as static in the documentation though … we’ll need to fix this @yaustar
https://developer.playcanvas.com/en/api/pc.I18n.html#findAvailableLocale

Even if I call it as I18n.findAvailableLocale:
console.log(I18n.findAvailableLocale(“de”, this.app.i18n._availableLangs));

It says I18n is not defined.

Usage:

pc.I18n.findAvailableLocale('en-US', {});

Odd, it’s marked as static: engine/i18n.js at 01cddc1ca983628d023ff5c9920955001eda3104 · playcanvas/engine · GitHub

Edit: fixed: Fixed static method API docs for i18n.findAvailableLocale by yaustar · Pull Request #3243 · playcanvas/engine · GitHub

Thanks for the quick response, it worked as you mentioned. :slight_smile:

I recommend adding a single line of “usage” in front of all functions.

1 Like