@@ -66,13 +66,13 @@ class GTranslator{
66
66
* Hold additional link class name for language selector options
67
67
* @var string
68
68
*/
69
- private string $ linkClass ;
69
+ private string $ linkClass = '' ;
70
70
71
71
/**
72
72
* Hold button boggle custom class
73
73
* @var string
74
74
*/
75
- private string $ toggleClass ;
75
+ private string $ toggleClass = '' ;
76
76
77
77
/**
78
78
* Hold button type
@@ -98,14 +98,14 @@ class GTranslator{
98
98
*
99
99
* @var string
100
100
*/
101
- private string $ iconPath ;
101
+ private string $ iconPath = '' ;
102
102
103
103
/**
104
104
* Hold selected icon type
105
105
*
106
106
* @var string
107
107
*/
108
- private string $ iconType ;
108
+ private string $ iconType = '' ;
109
109
110
110
/**
111
111
* Hold ui design provider type
@@ -119,7 +119,7 @@ class GTranslator{
119
119
*
120
120
* @var string
121
121
*/
122
- private string $ bootstrapVersion ;
122
+ private string $ bootstrapVersion = '' ;
123
123
124
124
/**
125
125
* Hold list of languages to build
@@ -311,8 +311,12 @@ private function buildLinks(bool $li = false): string{
311
311
* Builds language selector select options
312
312
* @return html|string $html select
313
313
*/
314
- private function selectOptions (): string {
315
- $ this ->setLinkClass ("select-language-item " );
314
+ private function selectOptions (): string {
315
+ $ class = 'select-language-item ' ;
316
+ if ($ this ->linkClass !== '' ){
317
+ $ class .= ' ' . $ this ->linkClass ;
318
+ }
319
+ $ this ->setLinkClass ($ class );
316
320
$ links = '<select onchange="GTranslator.trigger(this)" class="notranslate php-language-select ' . $ this ->linkClass . '"> ' ;
317
321
foreach ($ this ->getLanguages () as $ key => $ value ){
318
322
$ links .= '<option value=" ' .$ key .'" lang=" ' .$ key .'" title=" ' .$ value .'"> ' . $ value . '</option> ' ;
@@ -329,7 +333,11 @@ private function selectOptions(): string{
329
333
*/
330
334
private function selectorCustom (bool $ jsTrigger = false ): string {
331
335
$ this ->jsTrigger = $ jsTrigger ;
332
- $ this ->setLinkClass ("selected-language-item " );
336
+ $ class = 'select-language-item ' ;
337
+ if ($ this ->linkClass !== '' ){
338
+ $ class .= ' ' . $ this ->linkClass ;
339
+ }
340
+ $ this ->setLinkClass ($ class );
333
341
if ($ jsTrigger ){
334
342
$ html = '<div class="language-selector g-translator-custom g-custom-js"> ' ;
335
343
$ html .= '<a class="open-language-selector" href="#"> ' ;
@@ -361,7 +369,11 @@ private function selectorCustom(bool $jsTrigger = false): string{
361
369
* @return html|string $html
362
370
*/
363
371
private function selectorBootstrap (): string {
364
- $ this ->setLinkClass ("dropdown-item " );
372
+ $ class = 'dropdown-item ' ;
373
+ if ($ this ->linkClass !== '' ){
374
+ $ class .= ' ' . $ this ->linkClass ;
375
+ }
376
+ $ this ->setLinkClass ($ class );
365
377
$ html = '<div class="language-selector"> ' ;
366
378
$ html .= '<div class="dropdown notranslate"> ' ;
367
379
$ html .= '<button class="btn btn-outline-light btn-sm dropdown-toggle" type="button" id="php-g-translator" data- ' . $ this ->getBootstrapAttr () . 'toggle="dropdown" aria-expanded="false"> ' ;
@@ -661,7 +673,7 @@ public function addScript(): string{
661
673
});
662
674
}
663
675
}
664
- }; " ;
676
+ " ;
665
677
}else if ($ this ->provider == self ::BOOTSTRAP ){
666
678
$ JSScript .= "
667
679
Init: function(){
@@ -674,9 +686,9 @@ public function addScript(): string{
674
686
});
675
687
}
676
688
}
677
- }; " ;
689
+ " ;
678
690
}else if ($ this ->provider == self ::SELECT ){
679
- $ JSScript .= "}},
691
+ $ JSScript .= "
680
692
trigger: function(self){
681
693
GTranslator.Translate(null, ' {$ this ->siteLang }|' + self.value);
682
694
return false;
@@ -691,11 +703,12 @@ public function addScript(): string{
691
703
}
692
704
}
693
705
}
694
- }
695
- }; " ;
706
+ }
707
+ " ;
696
708
}
697
709
698
710
$ JSScript .= "
711
+ };
699
712
(function(){
700
713
window.onload = function() {
701
714
GTranslator.Init();
0 commit comments