Open Closed

Locale file not found after migrate abp #9620


User avatar
0
cmonzon created

I’m migrating an existing Angular application from 7.4.0 to ABP 9.2.1 (from angular 16.2..8 to Angular 19. After completing the upgrade, I'm encountering issues related to localization)

On application startup, I see these runtime errors in the browser console: • Cannot find the en locale file.

• Cannot find the es locale file

• And when switching the UI language to Spanish: NG0701: Missing locale data for the locale "es". (usually triggered by DatePipe)

As a workaround, I tried manually registering the Spanish locale using registerLocaleData, which prevents the DatePipe error — but the console warnings like Cannot find the en locale file and Cannot find the es locale file still appear, so it doesn’t feel like a proper fix.

Current package.json file:

I create a new abp project and compare with my project and I can't find any differences..


3 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    To resolve the "Cannot find the en/es locale file" errors after migrating your ABP Angular application, you need to ensure that the Angular localization system is properly configured for the new ABP version (9.2.1). The error and the console message point to a missing locale file registration, which is required in ABP Angular v9+.

    Here’s how to fix it:

    1. Register Locales in CoreModule
      In ABP Angular 4.x and above, you must explicitly register supported locales using the registerLocale function in your app.module.ts:

    import { registerLocale } from '@abp/ng.core/locale'; // or for commercial: import { registerLocale } from '@volo/abp.ng.language-management/locale';

    @NgModule({ imports: [ // ... CoreModule.forRoot({ // ...other options, registerLocaleFn: registerLocale() }), // ... ], // ... }) export class AppModule {}

    
    2. **Do Not Manually Register Angular Locales for ABP**  
       The manual `registerLocaleData(localeEs, 'es')` is only needed for Angular’s built-in pipes (like DatePipe), not for ABP’s localization system. For ABP, use the `registerLocale` function as shown above.
    
    3. **Ensure Locale Files Exist**  
       Make sure you have the locale files (e.g., `en.json`, `es.json`) in the correct location (`src/assets/abp/locales/` by default). If you are missing these files, you can copy them from a fresh ABP template or generate them as described in the documentation.
    
    4. **Reference**  
       - Official documentation: [ABP Angular Localization - Adding a New Culture](https://abp.io/docs/latest/framework/ui/angular/localization#adding-a-new-culture)
    
    By following these steps, the "Cannot find the en/es locale file" errors should be resolved, and your localization will work as expected in ABP 9.2.1.
    
    Sources:
    - https://abp.io/docs/latest/framework/ui/angular/localization#adding-a-new-culture
    
    ---
    _This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon._
    
  • User Avatar
    0
    cmonzon created

    We tried this options after migrate but the error persist on our local environment. We have a commercial license

  • User Avatar
    0
    sumeyye.kurtulus created
    Support Team Angular Expert

    Hello,

    After adding this registerLocale function to your module file

    let localeMap = {} as { [key: string]: string };
    
    export function registerLocale(
      {
        cultureNameLocaleFileMap = {},
        errorHandlerFn = defaultLocalErrorHandlerFn,
      } = {} as RegisterLocaleData
    ) {
      return (locale: string): Promise<any> => {
        localeMap = { ...differentLocales, ...cultureNameLocaleFileMap };
        const localePath = `/locales/${localeMap[locale] || locale}`;
        return new Promise((resolve, reject) => {
          return import(
            /* webpackMode: "lazy-once" */
            /* webpackChunkName: "locales"*/
            /* webpackInclude: /[/\\](ar|cs|en|en-GB|es|de|fi|fr|hi|hu|is|it|pt|tr|ru|ro|sk|sl|zh-Hans|zh-Hant)\.(mjs|js)$/ */
            /* webpackExclude: /[/\\]global|extra/ */
            /* @vite-ignore */
            `@angular/common${localePath}`
          )
            .then(val => {
              let module = val;
              while (module.default) {
                module = module.default;
              }
              resolve({ default: module });
            })
            .catch(error => {
              errorHandlerFn({
                resolve,
                reject,
                error,
                locale,
              });
            });
        });
      };
    }
    

    Checking these points may be helpful:

    1. Verify the webpack include pattern in the function

      */* webpackInclude: /[/\\](ar|cs|en|en-GB|es|de|fi|fr|hi|hu|is|it|pt|tr|ru|ro|sk|sl|zh-Hans|zh-Hant)\.(mjs|js)$/ */*
      

    The pattern includes en but might not be matching the actual file structure.

    1. Check if en.mjs exists in @angular/common/locales/

      `ls angular/node_modules/@angular/common/locales/en*`
      

    The core issue is that the locale files are not being found by the dynamic import, likely due to a path or webpack configuration mismatch.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 18, 2025, 07:10