# How to configure global Aurelia DI container?

**URL:** <https://discourse.aurelia.io/t/how-to-configure-global-aurelia-di-container/5458>\
**Category:** vNext\
**Created:** [June 14, 2024, 12:40pm UTC](https://discourse.aurelia.io/t/how-to-configure-global-aurelia-di-container/5458 "2024-06-14T12:40:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mreiche](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/mreiche/32/1912_2.png) [@mreiche](https://discourse.aurelia.io/u/mreiche)\
**Post date:** [June 14, 2024, 12:40pm UTC](https://discourse.aurelia.io/t/how-to-configure-global-aurelia-di-container/5458/1 "2024-06-14T12:40:05Z")

</div>

The documentation says ([Dependency injection (DI) | The Aurelia 2 Docs](https://docs.aurelia.io/getting-to-know-aurelia/overview#resolving-services))

> Services are usually resolved automatically via constructor injection. However, you can also resolve them manually:

```typescript
const profileService: ProfileService = container.get(ProfileService);

```

But where does `container` get from? It looks like that

```typescript
const container = DI.createContainer()

```

creates a new container. How to get an instance from the Aurelia container before application starts?

```typescript
const container = DI.createContainer()
const numberValueConverter = container.get(NumberValueConverter)
numberValueConverter.setLocale("de")

Aurelia
    .register(NumberValueConverter)
    .app(MyApp)
    .start();

```

---

<div class="post-metadata">

**Author:** ![mreiche](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/mreiche/32/1912_2.png) [@mreiche](https://discourse.aurelia.io/u/mreiche)\
**Post date:** [June 14, 2024, 1:02pm UTC](https://discourse.aurelia.io/t/how-to-configure-global-aurelia-di-container/5458/2 "2024-06-14T13:02:50Z")

</div>

You don’t do this in the configuration step of `main.ts` anymore, but in the constructor of `myApp` like:

```typescript
@inject(NumberValueConverter)
export class MyApp {
    constructor(
        numberValueConverter: NumberValueConverter
    ) {
        numberValueConverter.setLocale("en")
    }

```

---

<div class="post-metadata">

**Author:** ![Sayan751](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/sayan751/32/1861_2.png) [@Sayan751](https://discourse.aurelia.io/u/Sayan751)\
**Post date:** [June 22, 2024, 7:26pm UTC](https://discourse.aurelia.io/t/how-to-configure-global-aurelia-di-container/5458/3 "2024-06-22T19:26:29Z")

</div>

Hi @mreiche, note that there is no global container, as it is for Au1. There is certainly a root container associated with an Aurelia app instance, but that’s about it.

Also noted that you are setting the locale in a value converter directly. Is there any reason, you aren’t injecting the i18n directly into your value converter to get current locale?
