# Dynamic load not allowed installing i18n

**URL:** <https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945>\
**Category:** Help Requests\
**Created:** [November 23, 2018, 1:57pm UTC](https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945 "2018-11-23T13:57:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![SNO](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/sno/32/650_2.png) [@SNO](https://discourse.aurelia.io/u/SNO)\
**Post date:** [November 23, 2018, 1:57pm UTC](https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945/1 "2018-11-23T13:57:09Z")

</div>

Today I tried to install i18n-translation in my aurelia-cli project. I did the steps described in the [aurelia i18n guide](https://aurelia.io/docs/plugins/i18n#installing-the-plugin).

But now I’m getting an error in chrome browser `vendor-bundle.js:34158 Uncaught Error: Dynamic load not allowed: locales/de/translation.json`.

Does anyone now why this error occurs and how I can fix that?

I don’t use webpack (only requirejs).  
Follownig the plugin configuration (didn’t change anything):

```auto
 .plugin('aurelia-i18n', (instance) => {
      let aliases = ['t', 'i18n'];
      // add aliases for 't' attribute
      TCustomAttribute.configureAliases(aliases);

      // register backend plugin
      instance.i18next.use(Backend.with(aurelia.loader));

      // adapt options to your needs (see http://i18next.com/docs/options/)
      // make sure to return the promise of the setup method, in order to guarantee proper loading
      return instance.setup({
        backend: { // <-- configure backend settings
          loadPath: './locales/{{lng}}/{{ns}}.json', // <-- XHR settings for where to get the files from
        },
        attributes: aliases,
        lng: 'de',
        fallbackLng: 'en',
        debug: false
      });
    })

```

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [November 24, 2018, 2:52am UTC](https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945/2 "2018-11-24T02:52:28Z")

</div>

The i18n doc has additional info on how to bundle json files with cli requirejs.

However latest cli 1.0.0.beta.6 had implemented bundling json files by default. Pls start a new requirejs app, it should all work now.

We will update i18n doc.

---

<div class="post-metadata">

**Author:** ![SNO](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/sno/32/650_2.png) [@SNO](https://discourse.aurelia.io/u/SNO)\
**Post date:** [November 25, 2018, 3:30pm UTC](https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945/3 "2018-11-25T15:30:47Z")

</div>

Thank you for the response. I checked my setup. The app is already created with aurelia 1.0.0-beta.6 ☹

What can I check so figure out why this problem appears?

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [November 25, 2018, 6:31pm UTC](https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945/4 "2018-11-25T18:31:29Z")

</div>

You can upgrade cli version, then copy over two files from a new app generated by `au new`:

```auto

aurelia_project/tasks/process-json.js

aurelia_project/tasks/build.js

```

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [November 25, 2018, 6:35pm UTC](https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945/5 "2018-11-25T18:35:00Z")

</div>

Can you check do you have local process-json task?

---

<div class="post-metadata">

**Author:** ![SNO](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/sno/32/650_2.png) [@SNO](https://discourse.aurelia.io/u/SNO)\
**Post date:** [November 25, 2018, 7:12pm UTC](https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945/6 "2018-11-25T19:12:29Z")

</div>

Hey, again many thanks for your help. I got it working. The trick for me was to change

```auto
import Backend from 'i18next-xhr-backend';

```

to

```auto
import * as Backend from 'i18next-xhr-backend';

```

Then the following main.ts config works:

```auto
.plugin('aurelia-i18n', (instance) => {
      let aliases = ['t', 'i18n'];
      // add aliases for 't' attribute
      TCustomAttribute.configureAliases(aliases);

      // register backend plugin
      instance.i18next.use(Backend);

      // adapt options to your needs (see http://i18next.com/docs/options/)
      // make sure to return the promise of the setup method, in order to guarantee proper loading
      return instance.setup({
        backend: { // <-- configure backend settings
          loadPath: './locales/{{lng}}/{{ns}}.json', // <-- XHR settings for where to get the files from
        },
        attributes: aliases,
        lng: 'de',
        fallbackLng: 'en',
        debug: false
      });
    });

```

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [November 25, 2018, 8:40pm UTC](https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945/7 "2018-11-25T20:40:30Z")

</div>

The xhr backend uses ajax to dynamically load json files (not through requirejs), instead of bundling them. You have to make sure those json files were copied to right places when deploy to production site.

---

<div class="post-metadata">

**Author:** ![SNO](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/sno/32/650_2.png) [@SNO](https://discourse.aurelia.io/u/SNO)\
**Post date:** [November 26, 2018, 6:53am UTC](https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945/8 "2018-11-26T06:53:02Z")

</div>

Ok. Thank you for that hint 🙂  
I’ll keep that in mind

---

<div class="post-metadata">

**Author:** ![SNO](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/sno/32/650_2.png) [@SNO](https://discourse.aurelia.io/u/SNO)\
**Post date:** [November 26, 2018, 6:57am UTC](https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945/9 "2018-11-26T06:57:12Z")

</div>

> [@huochunpeng](#):
>
> Can you check do you have local process-json task?

Yes I have a “Process-json” task.  
Having a look into the aurelia.json I see that maybe the default path doesn’t fit to the i18n description:

```auto
 "jsonProcessor": {
    "id": "none",
    "displayName": "None",
    "fileExtension": ".json",
    "source": "src/**/*.json"
  },

```

The json-processor would look into the src folder. But according to i18n guide, the json files are saved in root (same level as src).  
Maybe this could be a reason. But now I’m using the xhr-backend what works for me.

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [November 27, 2018, 7:13pm UTC](https://discourse.aurelia.io/t/dynamic-load-not-allowed-installing-i18n/1945/10 "2018-11-27T19:13:45Z")

</div>

🙂

> Second, create a folder named `locales` in your project’s root.

This is where the doc is confusing, it means project root as defined in aurelia.json which is src folder in your repo.

If you further look down the doc, you will see mention of `src/locales` files.

I remember early version of i18n indeed talked about translation files outside of src folder and dynamically loading them. To me, dynamical loading fit the nature of i18n, who wants to load all possible lanaguages upfront while user is gonna use just one of them.

The current default setup with default loader and default json bundling is biased to easiness than technical best choice.

Since you are using dynamic loading now, there is no reason to go back to default setup.
