Google translate dropdown customize with country flag

Overview

Flag google trasnalte demo without google bar and logo

Screenshot

ScreenShot

How to use this

1. Create a country checklist containing languages from which you’ll select to translate your webpage.

<!-- jQuery Is Required -->
<script src="/path/to/cdn/jquery.slim.min.js"></script>

<!-- Bootstrap -->
<link rel="stylesheet" href="/path/to/cdn/bootstrap.min.css" />
<script src="/path/to/cdn/bootstrap.min.js"></script>

<!-- Bootstrap Select -->
<link rel="stylesheet" href="/path/to/cdn/bootstrap-select.min.css" />
<script src="/path/to/cdn/bootstrap-select.min.js"></script>

<!-- Flag Icon -->
<link rel="stylesheet" href="/path/to/cdn/flag-icon.min.css" />
<select class="selectpicker" data-width="fit" onchange="translateLanguage(this.value);">
  <option data-content='<span class="flag-icon flag-icon-af"></span> Afrikaans' value="Afrikaans">Afrikaans</option>
  <option  data-content='<span class="flag-icon flag-icon-al"></span> Albanian' value="Albanian">Albanian</option>
  <option  data-content='<span class="flag-icon flag-icon-ar"></span> Arabic' value="Arabic">Arabic</option>
  <option  data-content='<span class="flag-icon flag-icon-am"></span> Armenian' value="Armenian">Armenian</option>
  <option  data-content='<span class="flag-icon flag-icon-az"></span> Azerbaijani' value="Azerbaijani">Azerbaijani</option>
  ...
</select>

2. Load the needed Google Translate API.

<script src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit" type="text/javascript"></script>

3. Add the Google Translator Widget to the web page.

<div id="google_translate_element"></div>

4. The important script to allow the Google Translator on your webpage.

function googleTranslateElementInit() {
  new google.translate.TranslateElement({ pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false }, 'google_translate_element');
}

function translateLanguage(lang) {
  googleTranslateElementInit();
  var $frame = $('.goog-te-menu-frame:first');
  if (!$frame.size()) {
    alert("Error: Could not find Google translate frame.");
    return false;
  }
  $frame.contents().find('.goog-te-menu2-item span.text:contains(' + lang + ')').get(0).click();
  return false;
}

$(function(){
  $('.selectpicker').selectpicker();
});
You might also like...

Translate text in images using Vision API, Translation API and Jimp

translate-image-text Translate text in images using Vision API, Translation API Rendered using React and canvas Installation Create a Google Cloud pro

Oct 26, 2022

Translate text in images using Vision API, Translation API and React with Canvas

manga-translator Manga translator app using Vision API, Translation API Rendered using React and canvas Installation Create a Google Cloud project, en

Oct 26, 2022

Break the barrier of your country, language and distance...

Break the barrier of your country, language and distance...

HACK ON 2.0 PROJECT METAFRATIS Break the barrier of your country, language and distance... PROBLEM OUR PROJECT SOLVES With the onset of Covid-19 we ha

Jul 6, 2021

💻 Countries Web is a web application that lets you view data for all the countries in the world and filter them by country name and continent.

💻 Countries Web is a web application that lets you view data for all the countries in the world and filter them by country name and continent.

🌎 Countries Web View Demo This is the Countries Web, a web application that lets you view data for all the countries in the world and filter them by

Jun 23, 2022

A curated collection of all country flags in SVG — plus the CSS for easier integration

flag-icons A curated collection of all country flags in SVG — plus the CSS for easier integration. See the demo. Install You can either download the w

Jan 4, 2023

Weather Condition App is a mobile application that has a category of countries in the home age and the users can access to weather of each country.

World Weather This is a SPA react-app project that is built using two APIs. And users can select and choose countries and states and get their updated

Oct 10, 2022

A Meme generator website where you can change and customize images to create great memes😎.

A Meme generator website where you can change and customize images to create great memes😎.

App Screenshot: Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory,

Dec 21, 2022

Obsidian-Snippet-collection - A collection of snippet to customize obsidian

Obsidian-Snippet-collection - A collection of snippet to customize obsidian

This repo is a collection of CSS snippets for Obsidian.md. To install them on PC

Dec 22, 2022

Easily open daily notes and periodic notes in new pane; customize periodic notes background; quick append new line to daily notes.

Easily open daily notes and periodic notes in new pane; customize periodic notes background; quick append new line to daily notes.

Obsidian daily notes opener This plugin adds a command for opening daily notes in a new pane (so that a keyboard shortcut could be used!) and gives ex

Dec 26, 2022
Owner
Devdreamsolution
I’m not a great programmer, I’m just a good programmer with great habits.
Devdreamsolution
A script for defending the Canadian flag on r/place 2022

ca-place-script A script for defending the Canadian flag on r/place 2022. This script will automate your tile placements to defend the grey outline an

null 3 Apr 4, 2022
This work is an overnight with 84436, an overlay code forked from Osu! community but for ``flag of Vietnam`` in r/place 2022

flag-of-vietnam-rplace2022 This work is a overnight with 84436, an overlay code forked from Osu! community but for flag of Vietnam Installation Xài Ta

Đoàn Đình Toàn 10 Nov 2, 2022
Help Ukraine - add ribbon with Ukraine flag into the website you manage, show the anti-war message to Russian users, or block them from your service.

?? Stop war on Ukraine ?? Help Ukraine - add ribbon with Ukraine flag into the website you manage, show the anti-war message to Russian users, or bloc

Pavol Hejný 46 Jan 7, 2023
A package to enable feature-flag support on Next.js via cookies and environment variables

next-feature-flags Add support for feature flags on Next.js based on cookies + environment variables. How it works It reads from cookies and Next.js's

Alexandre Santos 10 Aug 10, 2022
CTF (Capture The Flag) is a type of information security competition that challenges contestants to find solutions or complete various tasks.

WHAT IS CTF? CTF (Capture The Flag) is a type of information security competition that challenges contestants to find solutions or complete various ta

Nicolas Saputra Gunawan 18 Dec 12, 2022
Google-Drive-Directory-Index | Combining the power of Cloudflare Workers and Google Drive API will allow you to index your Google Drive files on the browser.

?? Google-Drive-Directory-Index Combining the power of Cloudflare Workers and Google Drive will allow you to index your Google Drive files on the brow

Aicirou 127 Jan 2, 2023
DatoCMS plugin: Translate fields

DatoCMS plugin: Translate fields This DatoCMS plugin gives you the ability to translate structured-text, string and text fields. This plugin is an add

De Voorhoede 4 Nov 8, 2022
▶ A tool that helps developers to translate JSON to different languages with ease

JSON translator Link ?? : https://json-translator.vercel.app/ ?? The information you have entered will not be kept on this site. ?? Translation is usi

amine louni 6 Mar 6, 2022
This project is about building a web application to translate languages using language translator API.

Language Translator App A web application to translate multiple languages Want to see live preview » ✧ View Demo ✧ Report Bug ✧ Getting Started ✧ Inst

Mohit Sehrawat 15 Dec 19, 2022
Firefox plugin to automatically translate ° Fahrenheit and size measurements into european units

Eurofox ???? ?? ?? Firefox plugin to automatically translate ° Fahrenheit, weights, speed and size measurements into european units. To see the origin

Inga Feick 5 Oct 16, 2022