@@ -193,6 +193,7 @@ export class I18nPlugin extends RuntimePlugin<LocalizationPluginOptions> {
193193
194194 private async scanLocaleDirectory ( ) {
195195 const endPattern = / { { lng} } ( \/ | \\ ) { { n s } } .j s o n $ / ;
196+ const eventFilePattern = / \. e v e n t \. j s o n $ / ;
196197 const localesPath = I18nPlugin . getLoadPath ( ) ;
197198 const scanDirTarget = localesPath . replace ( endPattern , '' ) ;
198199
@@ -211,6 +212,7 @@ export class I18nPlugin extends RuntimePlugin<LocalizationPluginOptions> {
211212
212213 for ( const file of files ) {
213214 const isValidLocale = DISCORD_LOCALES . has ( file . name as Locale ) ;
215+
214216 if ( file . isDirectory ( ) ) {
215217 if ( ! isValidLocale ) {
216218 Logger . warn ( `I18nPlugin: Invalid locale directory ${ file . name } ` ) ;
@@ -229,29 +231,49 @@ export class I18nPlugin extends RuntimePlugin<LocalizationPluginOptions> {
229231
230232 if ( ! / \. j s o n $ / . test ( ext ) ) continue ;
231233
232- const name = basename ( file . name , ext ) ;
233- namespaces . add ( name ) ;
234+ let name : string ;
235+ const isEvent = eventFilePattern . test ( file . name ) ;
236+ // Handle event files specially
237+ if ( isEvent ) {
238+ name = file . name . replace ( '.event.json' , '' ) ;
239+ } else {
240+ name = basename ( file . name , ext ) ;
241+ }
242+ namespaces . add ( `${ isEvent ? 'event_' : '' } ${ name } ` ) ;
234243
235244 const locale = basename ( file . parentPath ) ;
236245
237- await this . loadMetadata (
238- join ( file . parentPath , file . name ) ,
239- locale ,
240- name ,
241- ) ;
246+ if ( ! isEvent )
247+ await this . loadMetadata (
248+ join ( file . parentPath , file . name ) ,
249+ locale ,
250+ name ,
251+ ) ;
242252 }
243253 }
244254 } else if ( file . isFile ( ) ) {
245255 const ext = extname ( file . name ) ;
246256
247257 if ( ! / \. j s o n $ / . test ( ext ) ) continue ;
248258
249- const name = basename ( file . name , ext ) ;
250- namespaces . add ( name ) ;
259+ let name : string ;
260+ const isEvent = eventFilePattern . test ( file . name ) ;
261+ // Handle event files specially
262+ if ( isEvent ) {
263+ name = file . name . replace ( '.event.json' , '' ) ;
264+ } else {
265+ name = basename ( file . name , ext ) ;
266+ }
267+ namespaces . add ( `${ isEvent ? 'event_' : '' } ${ name } ` ) ;
251268
252269 const locale = basename ( file . parentPath ) ;
253270
254- await this . loadMetadata ( join ( file . parentPath , file . name ) , locale , name ) ;
271+ if ( ! isEvent )
272+ await this . loadMetadata (
273+ join ( file . parentPath , file . name ) ,
274+ locale ,
275+ name ,
276+ ) ;
255277 }
256278 }
257279
0 commit comments