Skip to content

Commit

Permalink
Support for other languages.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptonerdcn committed Dec 12, 2023
1 parent 21663e2 commit 52d9ee6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion theme/js/index.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const maxWorkers = 1;
let workerPath = '';

// supported languages
const supportedLanguages = ['zh-cn', 'fr', 'es'];

// path to mjs. This is the path to the current script, which is the last script in the document.
const scripts = document.getElementsByTagName('script');
const currentScript = scripts[scripts.length - 1];
const scriptUrl = currentScript.src;

if (window.location.pathname.startsWith('/zh-cn')) {
if (supportedLanguages.some(lang => window.location.pathname.startsWith('/' + lang))) {
workerPath = new URL('../js/worker.cjs', scriptUrl).toString();
} else {
workerPath = new URL('./worker.cjs', scriptUrl).toString();
Expand Down

0 comments on commit 52d9ee6

Please sign in to comment.