Skip to content

Commit

Permalink
fix: i18n basePath for github pages (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitij-k-osmosys authored Apr 2, 2024
1 parent df87ac0 commit 10ffe80
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/assets/i18n/loader.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { HttpClient } from '@angular/common/http';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

let basePath = '';
const baseElements = document.getElementsByTagName('base');

if (baseElements.length > 0 && baseElements[0].href) {
basePath = baseElements[0].href;
} else {
basePath = '../';
// eslint-disable-next-line no-console
console.error('No <base> tag found or missing href attribute.');
}

function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, '../assets/i18n/', '.json');
return new TranslateHttpLoader(http, `${basePath}assets/i18n/`, '.json');
}

export default HttpLoaderFactory;

0 comments on commit 10ffe80

Please sign in to comment.