Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am trying to add Arabic language. I have configured package correctly but some labels are translated some are not #1466

Open
Yamesh1994 opened this issue Dec 28, 2023 · 0 comments

Comments

@Yamesh1994
Copy link

Here is my app initializer and App Factory

export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, environment.apiUrl + 'localizations/json/', '.json');
}

export function appInitializerFactory(translate: TranslateService, injector: Injector, http: HttpClient, authService: LmsAuthService) {
return () => new Promise((resolve: any) => {
const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
locationInitialized.then(() => {
http.get(environment.apiUrl + 'get-default-lang')
.subscribe(responseData => {

      const langToSet = responseData.code;
      translate.setDefaultLang('en-US');
      if (authService.getToken().length > 10) {
        http.get<any>(environment.apiUrl + 'user').subscribe((data: any) => {

          translate.use(data.data.language).subscribe(() => {
            console.info(`Successfully initializedd '${data.data.language}' language.'`);
            localStorage.setItem('language', data.data.language);
          })


        }, err => {
          // console.log(err);
          console.error(`Problem with '${langToSet}' language initialization.'`);
        }, () => {
          resolve(null);


        });
      }
      else {
        translate.use(langToSet).subscribe(() => {
          console.info(`Successfully initialized '${langToSet}' language.'`);
          localStorage.setItem('language', responseData.code);
        }, err => {
          // console.log(err);
          console.error(`Problem with '${langToSet}' language initialization.'`);
        }, () => {
          resolve(null);
        });
      }
    },

      err => {
        console.error('API error:', err);
        resolve(null);
      });
});

});
}

My translation are from Server side
Screenshot from 2023-12-28 14-38-20
Here is screen shot some label are in Arabic some are in English but translation for all are in both lan are available from server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant