'google translate js some troubles on iphone

google translate always working without click translate button only iphone

how can fix it? or useful document, or other way

-check

win10 : chrome lastest ver, IE11 is fine.

android : chrome, samsung internet browser is fine.

macOS(check ver. Catalina 10.15) : safari is fine.

-script

<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<script type="text/javascript">
function googleTranslateElementInit()
{
    var d_width = $(window).width();

    if (d_width > 1024)
    {
        new google.translate.TranslateElement({
            pageLanguage: 'en',
            includedLanguages: 'ne,ru,...', 
            layout: google.translate.TranslateElement.InlineLayout.SIMPLE, 
            multilanguagePage: true
        }, 'google_translate_element');
    }
    else
    {
        new google.translate.TranslateElement({
            pageLanguage: 'en', 
            includedLanguages: 'ne,ru,...', 
            multilanguagePage: true 
        }, 'google_translate_element');
    }
}

setTimeout(function() {
    document.getElementById('google_translate_element').addEventListener('click', function() {
        const langArr = {
            "en": "English", 
            "hi": "Hindi",
            //...
        }
        var d_width = $(window).width();
        if (d_width > 1024)
        {
            const langItems = document.querySelector('.goog-te-menu-frame').contentWindow.document.querySelectorAll('.goog-te-menu2 a');
            
            for(let i = 0; i < langItems.length; i++) {
                langItems[i].children[0].children[1].innerText = langArr[langItems[i].value];
            }
        }else{
            const langSelect = document.querySelector('.goog-te-combo');

            for(let i = 0; i < langSelect.options.length; i++) {
                if(langSelect.options[i].value != ""){
                    langSelect.options[i].innerText = langArr[langSelect.options[i].value];
                }
            }
        }
    });
}, 100);

</script>

html

<div class="googtranslate_wrap">
    <div class="container">
        <div class="googtrans_txtbox">
            <p class="tlt">title</p>
            <p class="eng_txt">text</p>
        </div>
        <div class="google_box">
            <div id="google_translate_element"></div>
            <p>Choose your Language</p>
        </div>
    </div>
</div>


Solution 1:[1]

if you want to add 12 Hours and 30 minutes to your Server time to get equavalent localtime(assuming you have server time), you can use AddHours() and AddMinutes() functions to add the 12:30 hours

Try This:

DateTime dt= /*your server time*/;
dt=dt.AddHours(12);
dt=dt.AddMinutes(30);

Solution 2:[2]

If your server's clock is set correctly (regardless of time zone), then the first three lines of your own code are exactly correct. The result variable contains the local time in the India time zone.

Simply omit the last two lines.

Solution 3:[3]

So you have the server's time, and you know the server's time zone? Then you can get the local time like this:

//Server: 09-Mar-2014 11:00:00 AM:
var serverTime = new DateTime(2014, 3, 9, 11, 00, 00);

var serverZone = TimeZoneInfo.FindSystemTimeZoneById("US Mountain Standard Time");
var localZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");

var localTime = TimeZoneInfo.ConvertTime(serverTime, serverZone, localZone);
// => 09-Mar-2014 11:30:00 PM

Solution 4:[4]

 DateTime serverTime = DateTime.Now;

 DateTime utcTime = serverTime.ToUniversalTime(); 

// convert it to Utc using timezone setting of server computer

 TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");

 DateTime localTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, tzi); 

// convert from utc to local

Solution 5:[5]

The simplest way to get the UTC date and time of the server is (SELECT GETUTCDATE();). Try it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sudhakar Tillapudi
Solution 2 Matt Johnson-Pint
Solution 3 Sphinxxx
Solution 4 Parvaz Bhaskar
Solution 5 Hashim Shubber