Skip to content

Commit

Permalink
Fix error when changing language
Browse files Browse the repository at this point in the history
  • Loading branch information
msantang78 committed Oct 21, 2024
1 parent d553378 commit 127183e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/common/services/i18n.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { action, observable } from 'mobx';
import enLocale from '../../../locales/en.json';
import i18next from 'utils/locales';
import type { Storages } from './storage/storages.service';
import type { ApiService } from './api.service';

// get all possible key paths
type DeepKeys<T> = T extends object
Expand Down Expand Up @@ -122,7 +123,7 @@ export class I18nService {
bestLocale = 'en';
dateFormat?: DateFormat;

constructor(private storages: Storages) {
constructor(private storages: Storages, private api: ApiService) {
if (process.env.JEST_WORKER_ID === undefined) {
this.init();
}
Expand Down Expand Up @@ -349,9 +350,7 @@ export class I18nService {
* Send locale to the backend
*/
setLocaleBackend() {
// test fails if we use import
const api = require('./api.service').default;
api.post('api/v1/settings', {
this.api.post('api/v1/settings', {
language: this.locale,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/servicesRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ sp.register(
() => {
const Service = require('~/common/services/i18n.service')
.I18nService as typeof I18nService;
return new Service(sp.resolve('storages'));
return new Service(sp.resolve('storages'), sp.resolveLazy('api'));
},
Lifetime.Singleton,
);
Expand Down

0 comments on commit 127183e

Please sign in to comment.