1111import type { TranslationCache } from "./cache" ;
1212import type { TranslatableEntry , Translator } from "./api" ;
1313import type { MetadataSchema } from "../types" ;
14- import { getLogger } from "../utils/logger" ;
15- import {
16- processPluralization ,
17- type PluralizationConfig ,
18- } from "./pluralization" ;
14+ import { processPluralization } from "./pluralization" ;
15+ import type { Logger } from "../utils/logger" ;
16+ import type { PartialPluralizationConfig } from "./pluralization/types" ;
17+ import type { LocaleCode } from "lingo.dev/spec" ;
1918
2019/**
2120 * Configuration for translation service
@@ -24,7 +23,8 @@ export interface TranslationServiceConfig {
2423 /**
2524 * Source locale (e.g., "en")
2625 */
27- sourceLocale : string ;
26+ // TODO (AleksandrSl 05/12/2025): Sort out these fields, they should most likely pick from the global config
27+ sourceLocale : LocaleCode ;
2828
2929 /**
3030 * Whether the translator is a pseudo translator
@@ -36,7 +36,7 @@ export interface TranslationServiceConfig {
3636 * Pluralization configuration
3737 * If provided, enables automatic pluralization of source messages
3838 */
39- pluralization ?: PluralizationConfig ;
39+ pluralization ?: Omit < PartialPluralizationConfig , "sourceLocale" > ;
4040}
4141
4242/**
@@ -79,12 +79,12 @@ export interface TranslationError {
7979export class TranslationService {
8080 private useCache = true ;
8181 private pluralizationProcessed = false ;
82- private logger = getLogger ( "translation-server" ) ;
8382
8483 constructor (
8584 private translator : Translator < any > ,
8685 private cache : TranslationCache ,
8786 private config : TranslationServiceConfig ,
87+ private logger : Logger ,
8888 ) {
8989 this . useCache = ! this . config . isPseudo ;
9090 }
@@ -116,7 +116,11 @@ export class TranslationService {
116116 ) ;
117117 const pluralStats = await processPluralization (
118118 metadata ,
119- this . config . pluralization || { enabled : true } ,
119+ {
120+ ...this . config . pluralization ,
121+ sourceLocale : this . config . sourceLocale ,
122+ } ,
123+ this . logger ,
120124 ) ;
121125 this . logger . info (
122126 `Pluralization stats: ${ pluralStats . pluralized } pluralized, ${ pluralStats . rejected } rejected, ${ pluralStats . failed } failed` ,
0 commit comments