Wednesday, April 22, 2026
HomeiOS DevelopmentGoogle Translator Javascript not working in ios

Google Translator Javascript not working in ios

[ad_1]

I’ve one net viewer in react-native for my app, and the perform of translate with google works completely within the Safari browser, in my Android App, and on the desktop, however not within the IOS app

That is my Google Translate code

perform googleTranslateElementInit() {
    new google.translate.TranslateElement({
        pageLanguage: 'pt',
        includedLanguages: 'pt,en,es',
        structure: google.translate.TranslateElement.InlineLayout.HORIZONTAL
    }, 'google_translate_element');

    comboTranslate = doc.querySelector("#google_translate_element .goog-te-combo");
}

perform changeEvent(el) {
    if (el.fireEvent) {
        el.fireEvent('onchange');
    } else {
        // var evObj = doc.createEvent("HTMLEvents");

        var occasion = new Occasion('change');
        comboTranslate.dispatchEvent(occasion);
        // evObj.initEvent("change", false, true);
        // el.dispatchEvent(evObj);
    }

}

perform changeLang(lang) {
    if (comboTranslate) {
        comboTranslate.worth = lang;
        changeEvent(comboTranslate);
    }
}

perform clickChange(){
    btn_translate = doc.querySelectorAll('.language');
   
    // o que faz os menus acender;
    btn_translate.forEach(btn => {
        btn.addEventListener('click on', perform (e) {

            var lang = e.srcElement.getAttribute('data-language');

            changeLang(lang) 
        })
    })
}
clickChange();
setTimeout(() => {
    googleTranslateElementInit()
    
    // comboTranslate.addEventListener('change', perform (e) {alert('a');})
}, 500);

and on the app.json I’ve that

{
  "expo": {
    "title": "MyApp ",
    "slug": "MyApp",
    "model": "1.2.0",
    "orientation": "portrait",
    "icon": "./belongings/icon.png",
    "locales": {
      "en": "./locales/ios/en.json",
      "pt": "./locales/ios/pt.json",
      "es": "./locales/ios/es.json"
    },
    "platforms": [
      "ios",
      "android"
    ],
    "splash": {
      "picture": "./belongings/splash.png",
      "resizeMode": "comprise",
      "backgroundColor": "#ffffff"
    },
    "plugins": [
      [
        "expo-notifications",
        {
          "icon": "./assets/icon.png",
          "color": "#ffffff"
        }
      ]
    ],

    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "buildNumber": "8",
      "supportsTablet": true,
      "bundleIdentifier": "com.myapp",

      "infoPlist": {

        "CFBundleAllowMixedLocalizations": true

      }
    },

    "android": {
      "package deal": "com.myapp",
      "versionCode": 9,
      "googleServicesFile": "./google-services.json",
      "config": {
        "googleMaps": {
          "apiKey": "AIzaSyDQjE4F3chI8Jy4FA8h45LqA7bMfngoH7Y"
        }
      },
      "permissions": ["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION", "CAMERA", "RECORD_AUDIO"],
      "blockedPermissions": ["ACCESS_BACKGROUND_LOCATION"],
      "adaptiveIcon": {
        "foregroundImage": "./belongings/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      }
    },
    "notification": {
      "icon": "./belongings/icon.png"
    }
  }
}

I put console.log and alerts to see if the change within the choose component of languages is being triggered by the js and it is all okay, I actually do not know why’s not translating

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments