"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var LocaleService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocaleService = void 0;
const common_1 = require("@nestjs/common");
const core_1 = require("@nestjs/core");
const typeorm_1 = require("@nestjs/typeorm");
const typeorm_2 = require("typeorm");
const solid_registry_1 = require("../helpers/solid-registry");
const locale_repository_1 = require("../repository/locale.repository");
const crud_service_1 = require("./crud.service");
const request_context_service_1 = require("./request-context.service");
let LocaleService = LocaleService_1 = class LocaleService extends crud_service_1.CRUDService {
    constructor(entityManager, repo, moduleRef, requestContextService, solidRegistry) {
        super(entityManager, repo, 'locale', 'solid-core', moduleRef);
        this.entityManager = entityManager;
        this.repo = repo;
        this.moduleRef = moduleRef;
        this.requestContextService = requestContextService;
        this.solidRegistry = solidRegistry;
        this.logger = new common_1.Logger(LocaleService_1.name);
    }
    onApplicationBootstrap() {
        this.loadLocales();
    }
    async loadLocales() {
        const locales = await this.repo.find();
        this.logger.debug(`Loaded ${locales.length} locales into registry`);
        this.solidRegistry.registerlocales(locales);
    }
};
exports.LocaleService = LocaleService;
exports.LocaleService = LocaleService = LocaleService_1 = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectEntityManager)()),
    __metadata("design:paramtypes", [typeorm_2.EntityManager,
        locale_repository_1.LocaleRepository,
        core_1.ModuleRef,
        request_context_service_1.RequestContextService,
        solid_registry_1.SolidRegistry])
], LocaleService);
//# sourceMappingURL=locale.service.js.map