@@ -1268,6 +1268,93 @@ describe('[SSG] i18n routing', () => {
12681268 } ) ;
12691269 } ) ;
12701270
1271+ describe ( 'when `build.format` is `file`, locales array contains objects, and locale indexes use getStaticPaths' , ( ) => {
1272+ /** @type {import('./test-utils').Fixture } */
1273+ let fixture ;
1274+
1275+ before ( async ( ) => {
1276+ fixture = await loadFixture ( {
1277+ root : './fixtures/i18n-locale-index-format-file/' ,
1278+ i18n : {
1279+ defaultLocale : 'en-us' ,
1280+ locales : [
1281+ {
1282+ path : 'en-us' ,
1283+ codes : [ 'en-US' ] ,
1284+ } ,
1285+ {
1286+ path : 'es-mx' ,
1287+ codes : [ 'es-MX' ] ,
1288+ } ,
1289+ {
1290+ path : 'fr-fr' ,
1291+ codes : [ 'fr-FR' ] ,
1292+ } ,
1293+ ] ,
1294+ routing : {
1295+ prefixDefaultLocale : true ,
1296+ redirectToDefaultLocale : false ,
1297+ } ,
1298+ } ,
1299+ } ) ;
1300+ await fixture . build ( ) ;
1301+ } ) ;
1302+
1303+ it ( 'should return the locale code of the current URL (en-US)' , async ( ) => {
1304+ const html = await fixture . readFile ( '/en-us.html' ) ;
1305+ assert . equal ( html . includes ( 'currentLocale: en-US' ) , true ) ;
1306+ } ) ;
1307+
1308+ it ( 'should return the locale code of the current URL (es-MX)' , async ( ) => {
1309+ const html = await fixture . readFile ( '/es-mx.html' ) ;
1310+ assert . equal ( html . includes ( 'currentLocale: es-MX' ) , true ) ;
1311+ } ) ;
1312+
1313+ it ( 'should return the locale code of the current URL (fr-FR)' , async ( ) => {
1314+ const html = await fixture . readFile ( '/fr-fr.html' ) ;
1315+ assert . equal ( html . includes ( 'currentLocale: fr-FR' ) , true ) ;
1316+ } ) ;
1317+ } ) ;
1318+
1319+ describe ( 'when `build.format` is `file`, locales array contains strings, and locale indexes use getStaticPaths' , ( ) => {
1320+ /** @type {import('./test-utils').Fixture } */
1321+ let fixture ;
1322+
1323+ before ( async ( ) => {
1324+ fixture = await loadFixture ( {
1325+ root : './fixtures/i18n-locale-index-format-file/' ,
1326+ i18n : {
1327+ defaultLocale : 'en-us' ,
1328+ locales : [
1329+ 'en-us' ,
1330+ 'es-mx' ,
1331+ 'fr-fr' ,
1332+ ] ,
1333+ routing : {
1334+ prefixDefaultLocale : true ,
1335+ redirectToDefaultLocale : false ,
1336+ } ,
1337+ }
1338+ } ) ;
1339+ await fixture . build ( ) ;
1340+ } ) ;
1341+
1342+ it ( 'should return the locale of the current URL (en-us)' , async ( ) => {
1343+ const html = await fixture . readFile ( '/en-us.html' ) ;
1344+ assert . equal ( html . includes ( 'currentLocale: en-us' ) , true ) ;
1345+ } ) ;
1346+
1347+ it ( 'should return the locale of the current URL (es-mx)' , async ( ) => {
1348+ const html = await fixture . readFile ( '/es-mx.html' ) ;
1349+ assert . equal ( html . includes ( 'currentLocale: es-mx' ) , true ) ;
1350+ } ) ;
1351+
1352+ it ( 'should return the locale of the current URL (fr-fr)' , async ( ) => {
1353+ const html = await fixture . readFile ( '/fr-fr.html' ) ;
1354+ assert . equal ( html . includes ( 'currentLocale: fr-fr' ) , true ) ;
1355+ } ) ;
1356+ } ) ;
1357+
12711358 describe ( 'with dynamic paths' , async ( ) => {
12721359 /** @type {import('./test-utils').Fixture } */
12731360 let fixture ;
0 commit comments