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

[2.0] fix: flatpicker localization. #1716

Open
wants to merge 3 commits into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions packages/Webkul/Admin/src/Resources/assets/js/plugins/flatpickr.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
import Flatpickr from "flatpickr";
import "flatpickr/dist/flatpickr.css";
import { Spanish } from "flatpickr/dist/l10n/es.js";
import { Arabic } from "flatpickr/dist/l10n/ar.js";
import { Persian } from "flatpickr/dist/l10n/fa.js";
import { Turkish } from "flatpickr/dist/l10n/tr.js";

export default {
install: (app) => {
window.Flatpickr = Flatpickr;

const setLocaleFromLang = () => {
const lang = document.documentElement.lang || "en";

const localeMap = {
es: Spanish,
ar: Arabic,
fa: Persian,
tr: Turkish
};

const locale = localeMap[lang] || null;

if (locale) {
window.Flatpickr.localize(locale);
}
};

setLocaleFromLang();

const changeTheme = (theme) => {
document.getElementById('flatpickr')?.remove();

Expand All @@ -13,7 +36,7 @@ export default {
}

const linkElement = document.createElement("link");

linkElement.rel = "stylesheet";
linkElement.type = "text/css";
linkElement.href = `https://npmcdn.com/flatpickr/dist/themes/${theme}.css`;
Expand All @@ -28,8 +51,6 @@ export default {

changeTheme(currentTheme);

app.config.globalProperties.$emitter.on("change-theme", (theme) => {
changeTheme(theme);
});
window.emitter.on("change-theme", (theme) => changeTheme(theme));
},
};
1 change: 1 addition & 0 deletions public/admin/build/assets/app-2ab2a07d.css

Large diffs are not rendered by default.

74 changes: 0 additions & 74 deletions public/admin/build/assets/app-5af6f62c.js

This file was deleted.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion public/admin/build/assets/app-80a30221.css

This file was deleted.

71 changes: 71 additions & 0 deletions public/admin/build/assets/app-ca52f87d.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions public/admin/build/assets/ar.es-1c5432ef.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions public/admin/build/assets/ar.es-2968a13f.js

This file was deleted.

5 changes: 5 additions & 0 deletions public/admin/build/assets/bg.es-133f1d79.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions public/admin/build/assets/bg.es-182cdcb3.js

This file was deleted.

5 changes: 0 additions & 5 deletions public/admin/build/assets/bn.es-3f8773a4.js

This file was deleted.

5 changes: 5 additions & 0 deletions public/admin/build/assets/bn.es-d6f1145b.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions public/admin/build/assets/bs.es-424f8392.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions public/admin/build/assets/bs.es-47a220af.js

This file was deleted.

5 changes: 5 additions & 0 deletions public/admin/build/assets/ca.es-10691e62.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions public/admin/build/assets/ca.es-47a49a5a.js

This file was deleted.

5 changes: 0 additions & 5 deletions public/admin/build/assets/cs.es-29e50c14.js

This file was deleted.

5 changes: 5 additions & 0 deletions public/admin/build/assets/cs.es-d467a362.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions public/admin/build/assets/da.es-5c82d648.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions public/admin/build/assets/da.es-eecb0b06.js

This file was deleted.

5 changes: 0 additions & 5 deletions public/admin/build/assets/de.es-83841cfd.js

This file was deleted.

5 changes: 5 additions & 0 deletions public/admin/build/assets/de.es-fc3d5977.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions public/admin/build/assets/drag-and-drop.es-0df93f71.js

This file was deleted.

Loading
Loading