@@ -184,7 +184,7 @@ export default class Build extends Base {
184184 // rename *.ftl to addonRef-*.ftl
185185 if ( build . fluent . prefixLocaleFiles === true ) {
186186 await move ( ftlPath , `${ dirname ( ftlPath ) } /${ namespace } -${ basename ( ftlPath ) } ` ) ;
187- this . logger . debug ( `Prefix filename: ${ ftlPath } ` ) ;
187+ this . logger . debug ( `FTL file ' ${ ftlPath } ' is renamed to ' ${ namespace } - ${ basename ( ftlPath ) } '. ` ) ;
188188 }
189189 } ) ) ;
190190
@@ -205,25 +205,26 @@ export default class Build extends Base {
205205 const [ matched , attrKey , attrVal ] = match ;
206206
207207 if ( ! allMessages . has ( attrVal ) ) {
208- this . logger . debug ( `HTML data-i10n-id ${ attrVal } do not exist in any FTL message, skip to namespace` ) ;
208+ this . logger . warn ( `HTML data-i10n-id ' ${ chalk . blue ( attrVal ) } ' in ${ chalk . gray ( htmlPath ) } do not exist in any FTL message, skip to namespace it. ` ) ;
209209 continue ;
210210 }
211211
212212 messagesInHTML . add ( attrVal ) ;
213213 const namespacedAttr = `${ namespace } -${ attrVal } ` ;
214214 htmlContent = htmlContent . replace ( matched , `${ attrKey } ="${ namespacedAttr } "` ) ;
215+ this . logger . debug ( `HTML data-i10n-id '${ chalk . blue ( attrVal ) } ' in ${ chalk . gray ( htmlPath ) } is namespaced to ${ chalk . blue ( namespacedAttr ) } .` ) ;
215216 }
216217
217218 if ( build . fluent . prefixFluentMessages )
218219 await writeFile ( htmlPath , htmlContent ) ;
219220 } ) ) ;
220221
221222 // Check miss 1: Cross check in diff locale - seems no need
222- // messagesMap .forEach((messageInThisLang, lang) => {
223+ // messagesByLocale .forEach((messageInThisLang, lang) => {
223224 // // Needs Nodejs 22
224225 // const diff = allMessages.difference(messageInThisLang);
225226 // if (diff.size)
226- // this.logger.warn(`FTL messages " ${Array.from(diff).join(", ")} don't exist the locale ${lang}" `);
227+ // this.logger.warn(`FTL messages ' ${Array.from(diff).join(", ")}' don't exist the locale ' ${lang}' `);
227228 // });
228229
229230 // Check miss 2: Check ids in HTML but not in ftl
@@ -233,7 +234,7 @@ export default class Build extends Base {
233234 . map ( ( [ locale ] ) => locale ) ;
234235
235236 if ( missingLocales . length > 0 ) {
236- this . logger . warn ( `HTML data-l10n-id " ${ messageInHTML } " is missing in locales: ${ missingLocales . join ( ", " ) } ` ) ;
237+ this . logger . warn ( `HTML data-l10n-id ' ${ chalk . blue ( messageInHTML ) } ' is missing in locales: ${ missingLocales . join ( ", " ) } . ` ) ;
237238 }
238239 } ) ;
239240 }
@@ -272,27 +273,29 @@ export default class Build extends Base {
272273
273274 // Prefix pref keys in xhtml
274275 if ( prefixPrefKeys ) {
275- const HTML_PREFERENCE_PATTERN = new RegExp ( ` preference="((?! ${ prefix } )\\ S*)"` , "g" ) ;
276+ const HTML_PREFERENCE_PATTERN = / p r e f e r e n c e = " ( \ S* ) " / g ;
276277 const xhtmlPaths = await glob ( `${ dist } /addon/**/*.xhtml` ) ;
277278 await Promise . all ( xhtmlPaths . map ( async ( path ) => {
278279 let content = await readFile ( path , "utf-8" ) ;
279280 const matchs = [ ...content . matchAll ( HTML_PREFERENCE_PATTERN ) ] ;
280281 for ( const match of matchs ) {
281282 const [ matched , key ] = match ;
282- if ( ! ( key in prefsWithoutPrefix ) && ! ( key in prefsWithoutPrefix ) ) {
283- this . logger . warn ( `preference key '${ key } ' in ${ path . replace ( ` ${ dist } /` , "" ) } not init in prefs.js `) ;
283+ if ( key . startsWith ( prefix ) ) {
284+ this . logger . debug ( `Pref key '${ chalk . blue ( key ) } ' is already starts with ' ${ prefix } ', skip prefixing it. `) ;
284285 continue ;
285286 }
286- if ( key . startsWith ( prefix ) ) {
287+ else if ( key . startsWith ( "extensions." ) ) {
288+ this . logger . warn ( `Pref key '${ chalk . blue ( key ) } ' in ${ chalk . gray ( path ) } starts with 'extensions.' but not '${ chalk . blue ( prefix ) } ', skip prefixing it.` ) ;
289+ continue ;
290+ }
291+ else if ( ! ( key in prefsWithPrefix ) && ! ( key in prefsWithoutPrefix ) ) {
292+ this . logger . warn ( `Pref key '${ chalk . blue ( key ) } ' in ${ chalk . gray ( path ) } is not found in prefs.js, skip prefixing it.` ) ;
287293 continue ;
288294 }
289- // else if (key.startsWith("extensions.")) {
290- // this.logger.warn(`Pref key '${key}' in ${path} starts with 'extensions' but not ${prefix}.`);
291- // this.logger.debug(`Skip prefixing '${key}' since it starts with 'extensions'.`);
292- // continue;
293- // }
294295 else {
295- content = content . replace ( matched , `preference="${ prefix } .${ key } "` ) ;
296+ const prefixed = `${ prefix } .${ key } ` ;
297+ this . logger . debug ( `Pref key '${ chalk . blue ( key ) } ' in ${ chalk . gray ( path ) } is prefixed to ${ chalk . blue ( prefixed ) } .` ) ;
298+ content = content . replace ( matched , `preference="${ prefixed } "` ) ;
296299 }
297300 }
298301 await outputFile ( path , content , "utf-8" ) ;
0 commit comments