import { TranslationContainerModel } from '../translation-container-model';
import { LocaleDescriptor, Localization, TranslationResponse } from '../services';
import { KosContext, KosParentAware } from '../../../../core';


// ---------------  Translation ---------------

export interface TranslationOptions extends KosParentAware {
  namespace: string;
  currentLocale: string;
  defaultLocale: string;
  rootUrl?: string;
  descriptor: Record<string, LocaleDescriptor>;
  resolver?: (namespace: string, locale: string) => string;
  bundleResolver?: (
    namespace: string,
    locale: string,
    context?: KosContext
  ) => Promise<TranslationResponse>;
}

// ---------------  TranslationContainer ---------------
export interface TranslationContainerOptions {
  lang: string;
  descriptor: Localization;
  defaultNamespace?: string;
  rootUrl?: string;
  descriptorUrl?: string;
  resolver?: (
    this: TranslationContainerModel,
    namespace: string,
    locale: string
  ) => string;
}

declare global {
  interface AbstractModelFactory {
    createTranslation: (id: string, options: TranslationOptions) => Translation;
    createTranslationContainer: (
      options: TranslationContainerOptions
    ) => TranslationContainer;
  }
}
