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

Avoiding recursive behaviour at locale errors #23

Merged
merged 1 commit into from
Oct 13, 2023
Merged
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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ Html
### Features
- Multi adapter/storage (see https://github.com/thephpleague/flysystem)
- File and folder operations
- Create a new file
- Create a new folder
- Rename
- Delete
- Create a new file
- Create a new folder
- Rename
- Delete
- Archive (zip)
- Unarchive (unzip)
- Text editing
- Image Crop Tool
- Upload / Download files
- Search (deep based on current folder)
- Search (deep based on current folder)
- Nice UI
- Context Menu
- Breadcrumb links
Expand Down
13 changes: 9 additions & 4 deletions src/composables/useI18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@ export function useI18n(id, locale, emitter) {
const {getStore, setStore} = useStorage(id);
const translations = ref({});

const changeLocale = (locale) => {
const changeLocale = (locale, defaultLocale = "en") => {
loadLocale(locale).then((i18n) => {
translations.value = i18n;
setStore('locale', locale);
setStore('translations', i18n);
emitter.emit('vf-toast-push', {label: 'The language is set to ' + locale});
}).catch(e => {
emitter.emit('vf-toast-push', {label: 'The selected locale is not yet supported!', type:'error'});
changeLocale('en');
});
.catch((e) => {
if (defaultLocale) {
emitter.emit('vf-toast-push', {label: 'The selected locale is not yet supported!', type:'error'});
changeLocale(defaultLocale, null);
} else {
emitter.emit("vf-toast-push", {label: "Locale cannot be loaded!", type: "error"});
}
});
};

if (!getStore('locale')) {
Expand Down