Skip to content

Commit d1f0bc7

Browse files
committed
feat(strings): make error message customizable
1 parent e349dec commit d1f0bc7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/lg-settings.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export interface LightGalleryCoreStrings {
3838
nextSlide: string;
3939
download: string;
4040
playVideo: string;
41+
mediaLoadingFailed: string;
4142
}
4243

4344
export type LightGalleryAllSettings = LightGalleryCoreSettings &
@@ -534,10 +535,11 @@ export interface LightGalleryCoreSettings {
534535
mobileSettings: Partial<MobileSettings>;
535536

536537
/**
537-
* Aria label strings for lightGallery core modules.
538+
* Customize string.
538539
* @description This can be useful if you want to localize the lightGallery strings to other languages.
539540
* Use your own service to translate the strings and pass it via settings.strings
540541
* You can find dedicated strings option for all lightGallery modules in their respective documentation.
542+
* Note - You need to provide values for all the strings. For example, even if you just want to change the closeGallery string, you need to provide all the other strings as well.
541543
*/
542544
strings: LightGalleryCoreStrings;
543545

@@ -620,5 +622,6 @@ export const lightGalleryCoreSettings: LightGalleryCoreSettings = {
620622
nextSlide: 'Next slide',
621623
download: 'Download',
622624
playVideo: 'Play video',
625+
mediaLoadingFailed: 'Oops... Failed to load content...',
623626
} as LightGalleryCoreStrings,
624627
};

src/lightgallery.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,9 @@ export class LightGallery {
10561056
() => {
10571057
currentSlide.addClass('lg-complete lg-complete_');
10581058
currentSlide.html(
1059-
'<span class="lg-error-msg">Oops... Failed to load content...</span>',
1059+
'<span class="lg-error-msg">' +
1060+
this.settings.strings['mediaLoadingFailed'] +
1061+
'</span>',
10601062
);
10611063
},
10621064
);

0 commit comments

Comments
 (0)