@@ -29,6 +29,7 @@ protected function configure(): void {
29
29
->addOption ('force ' , null , InputOption::VALUE_NONE , 'Force re-translate including translated sentences ' )
30
30
->addOption ('ignore ' , null , InputOption::VALUE_REQUIRED , 'Regular expression to ignore parts of the text ' , null )
31
31
->addOption ('only ' , null , InputOption::VALUE_NONE , 'Create only PO file, no MO file ' )
32
+ ->addOption ('pot ' , null , InputOption::VALUE_REQUIRED , 'POT file path for mapping translations ' , null )
32
33
->addOption ('wait ' , null , InputOption::VALUE_REQUIRED , 'Wait between translations in milliseconds ' , false )
33
34
->addOption ('apikey ' , null , InputOption::VALUE_REQUIRED , 'Deepl API Key ' )
34
35
->addOption ('translator ' , null , InputOption::VALUE_OPTIONAL , 'Path to custom translator instance ' , null )
@@ -65,6 +66,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
65
66
throw new InvalidOptionException ('Invalid directory path: ' . $ outputDir );
66
67
}
67
68
69
+ // Input POT file
70
+ $ potTrans = null ;
71
+ if ($ potFile = $ input ->getOption ('pot ' )) {
72
+ if ($ potFile [0 ] !== '/ ' ) {
73
+ $ potFile = $ dir . '/ ' . $ potFile ;
74
+ }
75
+
76
+ $ potTrans = (new \Gettext \Loader \PoLoader ())->loadFile ($ potFile );
77
+ }
78
+
68
79
// Get API key from .env or command line
69
80
$ apikey = $ _ENV ['DEEPL_API_KEY ' ] ?? $ input ->getOption ('apikey ' );
70
81
@@ -83,6 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
83
94
} else {
84
95
$ translator = new DeepLTranslator (
85
96
new Translator ($ apikey ),
97
+ $ potTrans ,
86
98
$ input ->getOption ('ignore ' )
87
99
);
88
100
}
0 commit comments