@@ -66,13 +66,13 @@ class GTranslator{
6666 * Hold additional link class name for language selector options
6767 * @var string
6868 */
69- private string $ linkClass ;
69+ private string $ linkClass = '' ;
7070
7171 /**
7272 * Hold button boggle custom class
7373 * @var string
7474 */
75- private string $ toggleClass ;
75+ private string $ toggleClass = '' ;
7676
7777 /**
7878 * Hold button type
@@ -98,14 +98,14 @@ class GTranslator{
9898 *
9999 * @var string
100100 */
101- private string $ iconPath ;
101+ private string $ iconPath = '' ;
102102
103103 /**
104104 * Hold selected icon type
105105 *
106106 * @var string
107107 */
108- private string $ iconType ;
108+ private string $ iconType = '' ;
109109
110110 /**
111111 * Hold ui design provider type
@@ -119,7 +119,7 @@ class GTranslator{
119119 *
120120 * @var string
121121 */
122- private string $ bootstrapVersion ;
122+ private string $ bootstrapVersion = '' ;
123123
124124 /**
125125 * Hold list of languages to build
@@ -311,8 +311,12 @@ private function buildLinks(bool $li = false): string{
311311 * Builds language selector select options
312312 * @return html|string $html select
313313 */
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 );
316320 $ links = '<select onchange="GTranslator.trigger(this)" class="notranslate php-language-select ' . $ this ->linkClass . '"> ' ;
317321 foreach ($ this ->getLanguages () as $ key => $ value ){
318322 $ links .= '<option value=" ' .$ key .'" lang=" ' .$ key .'" title=" ' .$ value .'"> ' . $ value . '</option> ' ;
@@ -329,7 +333,11 @@ private function selectOptions(): string{
329333 */
330334 private function selectorCustom (bool $ jsTrigger = false ): string {
331335 $ 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 );
333341 if ($ jsTrigger ){
334342 $ html = '<div class="language-selector g-translator-custom g-custom-js"> ' ;
335343 $ html .= '<a class="open-language-selector" href="#"> ' ;
@@ -361,7 +369,11 @@ private function selectorCustom(bool $jsTrigger = false): string{
361369 * @return html|string $html
362370 */
363371 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 );
365377 $ html = '<div class="language-selector"> ' ;
366378 $ html .= '<div class="dropdown notranslate"> ' ;
367379 $ 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{
661673 });
662674 }
663675 }
664- }; " ;
676+ " ;
665677 }else if ($ this ->provider == self ::BOOTSTRAP ){
666678 $ JSScript .= "
667679 Init: function(){
@@ -674,9 +686,9 @@ public function addScript(): string{
674686 });
675687 }
676688 }
677- }; " ;
689+ " ;
678690 }else if ($ this ->provider == self ::SELECT ){
679- $ JSScript .= "}},
691+ $ JSScript .= "
680692 trigger: function(self){
681693 GTranslator.Translate(null, ' {$ this ->siteLang }|' + self.value);
682694 return false;
@@ -691,11 +703,12 @@ public function addScript(): string{
691703 }
692704 }
693705 }
694- }
695- }; " ;
706+ }
707+ " ;
696708 }
697709
698710 $ JSScript .= "
711+ };
699712 (function(){
700713 window.onload = function() {
701714 GTranslator.Init();
0 commit comments