1111import type { TranslationCache } from "./cache" ;
1212import type { TranslatableEntry , Translator } from "./api" ;
1313import type { MetadataSchema } from "../types" ;
14- import { PluralizationService } from "./pluralization" ;
14+ import {
15+ type PluralizationConfig ,
16+ PluralizationService ,
17+ } from "./pluralization" ;
1518import type { Logger } from "../utils/logger" ;
16- import type { PartialPluralizationConfig } from "./pluralization" ;
1719import type { LocaleCode } from "lingo.dev/spec" ;
1820
19- /**
20- * Configuration for translation service
21- */
2221export interface TranslationServiceConfig {
2322 /**
2423 * Source locale (e.g., "en")
2524 */
26- // TODO (AleksandrSl 05/12/2025): Sort out these fields, they should most likely pick from the global config
2725 sourceLocale : LocaleCode ;
2826
2927 /**
@@ -36,26 +34,17 @@ export interface TranslationServiceConfig {
3634 * Pluralization configuration
3735 * If provided, enables automatic pluralization of source messages
3836 */
39- pluralization ? : Omit < PartialPluralizationConfig , "sourceLocale" > ;
37+ pluralization : Omit < PluralizationConfig , "sourceLocale" > ;
4038}
4139
42- /**
43- * Result of a translation request
44- */
4540export interface TranslationResult {
4641 /**
4742 * Successfully translated entries (hash -> translated text)
4843 */
4944 translations : Record < string , string > ;
5045
51- /**
52- * Errors that occurred during translation
53- */
5446 errors : TranslationError [ ] ;
5547
56- /**
57- * Statistics about the operation
58- */
5948 stats : {
6049 total : number ;
6150 cached : number ;
@@ -64,18 +53,12 @@ export interface TranslationResult {
6453 } ;
6554}
6655
67- /**
68- * Translation error details
69- */
7056export interface TranslationError {
7157 hash : string ;
7258 sourceText : string ;
7359 error : string ;
7460}
7561
76- /**
77- * Translation service orchestrator
78- */
7962export class TranslationService {
8063 private useCache = true ;
8164 private pluralizationService ?: PluralizationService ;
@@ -94,9 +77,7 @@ export class TranslationService {
9477 this . logger . info ( "Initializing pluralization service..." ) ;
9578 this . pluralizationService = new PluralizationService (
9679 {
97- enabled : true ,
98- model :
99- this . config . pluralization ?. model || "groq:llama-3.1-8b-instant" ,
80+ ...this . config . pluralization ,
10081 sourceLocale : this . config . sourceLocale ,
10182 } ,
10283 this . logger ,
@@ -379,6 +360,7 @@ export class TranslationService {
379360 /**
380361 * Pick only requested translations from the full set
381362 */
363+ // TODO (AleksandrSl 14/12/2025): SHould I use this in the build somehow?
382364 private pickTranslations (
383365 allTranslations : Record < string , string > ,
384366 requestedHashes : string [ ] ,
0 commit comments