11import UserConfig from "@11ty/eleventy" ;
22import { EleventyHtmlBasePlugin , I18nPlugin , IdAttributePlugin } from "@11ty/eleventy" ;
3- import i18next from 'i18next' ;
4- import Backend from 'i18next-fs-backend' ;
5- import { join } from 'path' ;
6- import { readdirSync , lstatSync } from 'fs' ;
7- import { fileURLToPath } from 'url' ;
8- import { dirname } from 'path' ;
3+ import i18next from "i18next" ;
4+ import Backend from "i18next-fs-backend" ;
5+ import { join , dirname } from "path" ;
6+ import { readdirSync , lstatSync } from "fs" ;
7+ import { fileURLToPath } from "url" ;
98import YAML from "yaml" ;
109import { DateTime } from "luxon" ;
1110import markdownIt from "markdown-it" ;
@@ -25,21 +24,18 @@ export default function (eleventyConfig) {
2524 // debug: true,
2625
2726 saveMissing : true ,
28-
29- // allow keys to be phrases having `:`, `.`
3027 nsSeparator : false ,
3128 keySeparator : false ,
32-
33- // do not load a fallback
29+ returnEmptyString : false ,
3430 fallbackLng : "en" ,
3531
3632 backend : {
37- loadPath : join ( __dirname , ' locales/{{lng}}/{{ns}}.json' ) ,
38- addPath : join ( __dirname , ' locales/{{lng}}/{{ns}}.json' ) ,
33+ loadPath : join ( __dirname , " locales/{{lng}}/{{ns}}.json" ) ,
34+ addPath : join ( __dirname , " locales/{{lng}}/{{ns}}.json" ) ,
3935 } ,
4036
41- preload : readdirSync ( join ( __dirname , ' locales' ) ) . filter ( ( fileName ) => {
42- const joinedPath = join ( join ( __dirname , ' locales' ) , fileName )
37+ preload : readdirSync ( join ( __dirname , " locales" ) ) . filter ( ( fileName ) => {
38+ const joinedPath = join ( join ( __dirname , " locales" ) , fileName )
4339 const isDirectory = lstatSync ( joinedPath ) . isDirectory ( )
4440 return isDirectory ;
4541 } ) ,
@@ -96,6 +92,7 @@ export default function (eleventyConfig) {
9692 } ) ;
9793
9894 eleventyConfig . addFilter ( "i18n" , function ( msg , ...args ) {
95+ msg = msg . trim ( ) . replaceAll ( / \s { 2 , } / g, " " ) ;
9996 const t = i18next . getFixedT ( this . page . lang ?? "en" ) ;
10097
10198 if ( args . length % 2 !== 0 ) {
0 commit comments