@@ -193,6 +193,7 @@ export class I18nPlugin extends RuntimePlugin<LocalizationPluginOptions> {
193
193
194
194
private async scanLocaleDirectory ( ) {
195
195
const endPattern = / { { lng} } ( \/ | \\ ) { { n s } } .j s o n $ / ;
196
+ const eventFilePattern = / \. e v e n t \. j s o n $ / ;
196
197
const localesPath = I18nPlugin . getLoadPath ( ) ;
197
198
const scanDirTarget = localesPath . replace ( endPattern , '' ) ;
198
199
@@ -211,6 +212,7 @@ export class I18nPlugin extends RuntimePlugin<LocalizationPluginOptions> {
211
212
212
213
for ( const file of files ) {
213
214
const isValidLocale = DISCORD_LOCALES . has ( file . name as Locale ) ;
215
+
214
216
if ( file . isDirectory ( ) ) {
215
217
if ( ! isValidLocale ) {
216
218
Logger . warn ( `I18nPlugin: Invalid locale directory ${ file . name } ` ) ;
@@ -229,29 +231,49 @@ export class I18nPlugin extends RuntimePlugin<LocalizationPluginOptions> {
229
231
230
232
if ( ! / \. j s o n $ / . test ( ext ) ) continue ;
231
233
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 } ` ) ;
234
243
235
244
const locale = basename ( file . parentPath ) ;
236
245
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
+ ) ;
242
252
}
243
253
}
244
254
} else if ( file . isFile ( ) ) {
245
255
const ext = extname ( file . name ) ;
246
256
247
257
if ( ! / \. j s o n $ / . test ( ext ) ) continue ;
248
258
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 } ` ) ;
251
268
252
269
const locale = basename ( file . parentPath ) ;
253
270
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
+ ) ;
255
277
}
256
278
}
257
279
0 commit comments