Sanasol Posted January 11, 2014 Group: Members Topic Count: 11 Topics Per Day: 0.00 Content Count: 185 Reputation: 53 Joined: 01/04/12 Last Seen: February 28 Share Posted January 11, 2014 Hello Unfortunately, can't do it as addon.So we have to work a little FIrstly need open FluxCP/lib/Flux.php Find this if ($lang=self::config('DefaultLanguage')) { $current = $addonName ? FLUX_ADDON_DIR."/$addonName/lang/$lang.php" : FLUX_LANG_DIR."/$lang.php"; } And add few lines after // [Sanasol] LangSwitcher $dictionary = array("en" => "en_us", "ru" => "ru_ru"); // keeping bad guys from use ../../../../ if(!empty($_COOKIE["language"]) && array_key_exists($_COOKIE["language"], $dictionary)) { $lang = $dictionary[$_COOKIE["language"]]; $current = $addonName ? FLUX_ADDON_DIR."/$addonName/lang/$lang.php" : FLUX_LANG_DIR."/$lang.php"; } // [Sanasol] LangSwitcher Here you should change $dictionary to your own lang list. For example: "lang_key" => "lang_file" and create translation file in FluxCP/lang/ named lang_file.php And now output switcherOpen FluxCP/themes/your_theme/footer.php or other theme part where you want to place it. For default theme I added to footer.php some magic code before this line <?php if (Flux::config('ShowCopyright')): ?> add this <tr> <td colspan="3"></td> <td> <script> function setCookie(key, value) { var expires = new Date(); expires.setTime(expires.getTime() + expires.getTime()); // never expires document.cookie = key + '=' + value + ';expires=' + expires.toUTCString(); } function getCookie(key) { var keyValue = document.cookie.match('(^| ?' + key + '=([^;]*)(;|$)'); return keyValue ? keyValue[2] : null; } $(document).ready(function(){ $("a[data-lang]").click(function(e){ e.preventDefault(); if(getCookie('language') != $(this).data("lang")) { setCookie('language', $(this).data("lang")); reload(); } }); $("a[data-lang]").each(function(i){ if(getCookie('language') == $(this).data("lang")) { $(this).css("font-weight","700"); } }); }); </script> <p> <a href="#" data-lang="en">English</a>/<a href="#" data-lang="ru">Russian</a> </p> </td> <td></td> </tr> Very simple code.You see lang links where data-lang = lang_key Thats all! When you save it and visit your site you will see something like this Now you can switch language in your FluxCP. Demo available here: http://ro.sanasol.ws/demo/fluxcp/?module=woeOnly this page have differences in langs Interesting fact: drawing logo (two flags with poring(from DeviantArt)) took more time than writing code 1 Link to comment Share on other sites More sharing options...
pr3p Posted January 11, 2014 Group: Members Topic Count: 4 Topics Per Day: 0.00 Content Count: 197 Reputation: 13 Joined: 05/14/12 Last Seen: October 29, 2024 Share Posted January 11, 2014 Awesome addons Sano thanks for sharing Link to comment Share on other sites More sharing options...
Innos Posted August 31, 2017 Group: Members Topic Count: 18 Topics Per Day: 0.01 Content Count: 62 Reputation: 5 Joined: 08/23/17 Last Seen: March 11, 2019 Share Posted August 31, 2017 After 3 Years i have test it, but din't work for me. Any other Codes for language switch on one flux cp? i found nothing in www. Link to comment Share on other sites More sharing options...
Diana Posted January 12, 2018 Group: Members Topic Count: 85 Topics Per Day: 0.03 Content Count: 194 Reputation: 3 Joined: 12/17/16 Last Seen: April 1 Share Posted January 12, 2018 Not working with FluxCP 2017 Versions Link to comment Share on other sites More sharing options...
CyberDevil Posted March 8, 2018 Group: Members Topic Count: 40 Topics Per Day: 0.02 Content Count: 242 Reputation: 37 Joined: 02/25/18 Last Seen: December 2, 2024 Share Posted March 8, 2018 On 12/1/2018 at 10:58 AM, Diana said: Not working with FluxCP 2017 Versions same form me... any update @Sanasol ??? Link to comment Share on other sites More sharing options...
Azael-Dev Posted March 5, 2019 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 1 Reputation: 1 Joined: 02/05/16 Last Seen: April 5 Share Posted March 5, 2019 Language switcher Fluxcp rA by S-anasol support 2017+ Link : https://github.com/rathena/FluxCP/pull/226 1 Link to comment Share on other sites More sharing options...
Recommended Posts