Skip to content

Instantly share code, notes, and snippets.

@rahulsom
Last active January 24, 2020 18:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulsom/9107297 to your computer and use it in GitHub Desktop.
Save rahulsom/9107297 to your computer and use it in GitHub Desktop.
Translate text to all languages

Run Translations with your Message.

groovy Translations.groovy "Welcome\!"

Then point your browser to http://localhost:8000/.

You get something like this: Image

Because Clip Art is for Marketing people. Engineers use Algorithms.

{
"query": {
"count": 15,
"created": "2013-05-30T03:47:44Z",
"lang": "en-US",
"results": {
"tr": [
{
"th": [
{
"p": "Rank"
},
{
"p": "Language"
},
{
"p": "Number of countries"
},
{
"p": "Countries"
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "1"
}
},
{
"strong": {
"a": {
"href": "/wiki/English_language",
"title": "English language",
"content": "English"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "60"
}
},
{
"a": {
"href": "/wiki/Antigua_and_Barbuda",
"title": "Antigua and Barbuda",
"content": "Antigua and Barbuda"
},
"p": {
"a": [
{
"href": "/wiki/Australia",
"title": "Australia",
"content": "Australia"
},
{
"href": "/wiki/The_Bahamas",
"title": "The Bahamas",
"content": "The Bahamas"
},
{
"href": "/wiki/Barbados",
"title": "Barbados",
"content": "Barbados"
},
{
"href": "/wiki/Belize",
"title": "Belize",
"content": "Belize"
},
{
"href": "/wiki/Botswana",
"title": "Botswana",
"content": "Botswana"
},
{
"href": "/wiki/Cameroon",
"title": "Cameroon",
"content": "Cameroon"
},
{
"href": "/wiki/Canada",
"title": "Canada",
"content": "Canada"
},
{
"href": "/wiki/Dominica",
"title": "Dominica",
"content": "Dominica"
},
{
"href": "/wiki/East_Timor",
"title": "East Timor",
"content": "East Timor"
},
{
"href": "/wiki/Eritrea",
"title": "Eritrea",
"content": "Eritrea"
},
{
"href": "/wiki/Fiji",
"title": "Fiji",
"content": "Fiji"
},
{
"class": "mw-redirect",
"href": "/wiki/Gambia",
"title": "Gambia",
"content": "Gambia"
},
{
"href": "/wiki/Ghana",
"title": "Ghana",
"content": "Ghana"
},
{
"href": "/wiki/Grenada",
"title": "Grenada",
"content": "Grenada"
},
{
"href": "/wiki/Guyana",
"title": "Guyana",
"content": "Guyana"
},
{
"href": "/wiki/Hong_Kong",
"title": "Hong Kong",
"content": "Hong Kong"
},
{
"href": "/wiki/China",
"title": "China",
"content": "China"
},
{
"href": "/wiki/India",
"title": "India",
"content": "India"
},
{
"href": "/wiki/Ireland",
"title": "Ireland",
"content": "Ireland"
},
{
"href": "/wiki/Jamaica",
"title": "Jamaica",
"content": "Jamaica"
},
{
"href": "/wiki/Kenya",
"title": "Kenya",
"content": "Kenya"
},
{
"href": "/wiki/Kiribati",
"title": "Kiribati",
"content": "Kiribati"
},
{
"href": "/wiki/Lesotho",
"title": "Lesotho",
"content": "Lesotho"
},
{
"href": "/wiki/Liberia",
"title": "Liberia",
"content": "Liberia"
},
{
"href": "/wiki/Malawi",
"title": "Malawi",
"content": "Malawi"
},
{
"href": "/wiki/Malta",
"title": "Malta",
"content": "Malta"
},
{
"href": "/wiki/Marshall_Islands",
"title": "Marshall Islands",
"content": "Marshall Islands"
},
{
"href": "/wiki/Mauritius",
"title": "Mauritius",
"content": "Mauritius"
},
{
"href": "/wiki/Federated_States_of_Micronesia",
"title": "Federated States of Micronesia",
"content": "Federated States of Micronesia"
},
{
"href": "/wiki/Namibia",
"title": "Namibia",
"content": "Namibia"
},
{
"href": "/wiki/Nauru",
"title": "Nauru",
"content": "Nauru"
},
{
"href": "/wiki/New_Zealand",
"title": "New Zealand",
"content": "New Zealand"
},
{
"href": "/wiki/Nigeria",
"title": "Nigeria",
"content": "Nigeria"
},
{
"href": "/wiki/Pakistan",
"title": "Pakistan",
"content": "Pakistan"
},
{
"href": "/wiki/Palau",
"title": "Palau",
"content": "Palau"
},
{
"href": "/wiki/Papua_New_Guinea",
"title": "Papua New Guinea",
"content": "Papua New Guinea"
},
{
"href": "/wiki/Philippines",
"title": "Philippines",
"content": "Philippines"
},
{
"href": "/wiki/Rwanda",
"title": "Rwanda",
"content": "Rwanda"
},
{
"href": "/wiki/Saint_Kitts_and_Nevis",
"title": "Saint Kitts and Nevis",
"content": "Saint Kitts and Nevis"
},
{
"href": "/wiki/Saint_Lucia",
"title": "Saint Lucia",
"content": "Saint Lucia"
},
{
"href": "/wiki/Saint_Vincent_and_the_Grenadines",
"title": "Saint Vincent and the Grenadines",
"content": "Saint Vincent and the Grenadines"
},
{
"href": "/wiki/Samoa",
"title": "Samoa",
"content": "Samoa"
},
{
"href": "/wiki/Seychelles",
"title": "Seychelles",
"content": "Seychelles"
},
{
"href": "/wiki/Sierra_Leone",
"title": "Sierra Leone",
"content": "Sierra Leone"
},
{
"href": "/wiki/Singapore",
"title": "Singapore",
"content": "Singapore"
},
{
"href": "/wiki/Solomon_Islands",
"title": "Solomon Islands",
"content": "Solomon Islands"
},
{
"href": "/wiki/South_Africa",
"title": "South Africa",
"content": "South Africa"
},
{
"href": "/wiki/South_Sudan",
"title": "South Sudan",
"content": "South Sudan"
},
{
"href": "/wiki/Sudan",
"title": "Sudan",
"content": "Sudan"
},
{
"href": "/wiki/Swaziland",
"title": "Swaziland",
"content": "Swaziland"
},
{
"href": "/wiki/Tanzania",
"title": "Tanzania",
"content": "Tanzania"
},
{
"href": "/wiki/Tonga",
"title": "Tonga",
"content": "Tonga"
},
{
"href": "/wiki/Trinidad_and_Tobago",
"title": "Trinidad and Tobago",
"content": "Trinidad and Tobago"
},
{
"href": "/wiki/Tuvalu",
"title": "Tuvalu",
"content": "Tuvalu"
},
{
"href": "/wiki/Uganda",
"title": "Uganda",
"content": "Uganda"
},
{
"href": "/wiki/United_Kingdom",
"title": "United Kingdom",
"content": "United Kingdom"
},
{
"href": "/wiki/United_States",
"title": "United States",
"content": "United States"
},
{
"href": "/wiki/Vanuatu",
"title": "Vanuatu",
"content": "Vanuatu"
},
{
"href": "/wiki/Zambia",
"title": "Zambia",
"content": "Zambia"
},
{
"href": "/wiki/Zimbabwe",
"title": "Zimbabwe",
"content": "Zimbabwe"
}
],
"content": ", \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n (\n ), \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n ."
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "2"
}
},
{
"strong": {
"a": {
"href": "/wiki/French_language",
"title": "French language",
"content": "French"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "29"
}
},
{
"a": {
"href": "/wiki/Belgium",
"title": "Belgium",
"content": "Belgium"
},
"p": {
"a": [
{
"href": "/wiki/Benin",
"title": "Benin",
"content": "Benin"
},
{
"href": "/wiki/Burkina_Faso",
"title": "Burkina Faso",
"content": "Burkina Faso"
},
{
"href": "/wiki/Burundi",
"title": "Burundi",
"content": "Burundi"
},
{
"href": "/wiki/Cameroon",
"title": "Cameroon",
"content": "Cameroon"
},
{
"href": "/wiki/Canada",
"title": "Canada",
"content": "Canada"
},
{
"href": "/wiki/Central_African_Republic",
"title": "Central African Republic",
"content": "Central African Republic"
},
{
"href": "/wiki/Chad",
"title": "Chad",
"content": "Chad"
},
{
"href": "/wiki/Comoros",
"title": "Comoros",
"content": "Comoros"
},
{
"href": "/wiki/Republic_of_the_Congo",
"title": "Republic of the Congo",
"content": "Republic of the Congo"
},
{
"class": "mw-redirect",
"href": "/wiki/Democratic_Republic_of_Congo",
"title": "Democratic Republic of Congo",
"content": "Democratic Republic of Congo"
},
{
"class": "mw-redirect",
"href": "/wiki/C%C3%B4te_d%27Ivoire",
"title": "Côte d'Ivoire",
"content": "Côte d'Ivoire"
},
{
"href": "/wiki/Djibouti",
"title": "Djibouti",
"content": "Djibouti"
},
{
"href": "/wiki/Equatorial_Guinea",
"title": "Equatorial Guinea",
"content": "Equatorial Guinea"
},
{
"href": "/wiki/France",
"title": "France",
"content": "France"
},
{
"href": "/wiki/Gabon",
"title": "Gabon",
"content": "Gabon"
},
{
"href": "/wiki/Guinea",
"title": "Guinea",
"content": "Guinea"
},
{
"href": "/wiki/Haiti",
"title": "Haiti",
"content": "Haiti"
},
{
"href": "/wiki/Luxembourg",
"title": "Luxembourg",
"content": "Luxembourg"
},
{
"href": "/wiki/Madagascar",
"title": "Madagascar",
"content": "Madagascar"
},
{
"href": "/wiki/Mali",
"title": "Mali",
"content": "Mali"
},
{
"href": "/wiki/Monaco",
"title": "Monaco",
"content": "Monaco"
},
{
"href": "/wiki/Niger",
"title": "Niger",
"content": "Niger"
},
{
"href": "/wiki/Rwanda",
"title": "Rwanda",
"content": "Rwanda"
},
{
"href": "/wiki/Senegal",
"title": "Senegal",
"content": "Senegal"
},
{
"href": "/wiki/Switzerland",
"title": "Switzerland",
"content": "Switzerland"
},
{
"href": "/wiki/Togo",
"title": "Togo",
"content": "Togo"
},
{
"href": "/wiki/Vanuatu",
"title": "Vanuatu",
"content": "Vanuatu"
}
],
"content": ", \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n ."
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "3"
}
},
{
"strong": {
"a": {
"href": "/wiki/Arabic_language",
"title": "Arabic language",
"content": "Arabic"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "25"
}
},
{
"a": {
"href": "/wiki/Algeria",
"title": "Algeria",
"content": "Algeria"
},
"p": {
"a": [
{
"href": "/wiki/Bahrain",
"title": "Bahrain",
"content": "Bahrain"
},
{
"href": "/wiki/Chad",
"title": "Chad",
"content": "Chad"
},
{
"href": "/wiki/Comoros",
"title": "Comoros",
"content": "Comoros"
},
{
"href": "/wiki/Djibouti",
"title": "Djibouti",
"content": "Djibouti"
},
{
"href": "/wiki/Egypt",
"title": "Egypt",
"content": "Egypt"
},
{
"href": "/wiki/Eritrea",
"title": "Eritrea",
"content": "Eritrea"
},
{
"href": "/wiki/Iraq",
"title": "Iraq",
"content": "Iraq"
},
{
"href": "/wiki/Israel",
"title": "Israel",
"content": "Israel"
},
{
"href": "/wiki/Jordan",
"title": "Jordan",
"content": "Jordan"
},
{
"href": "/wiki/Kuwait",
"title": "Kuwait",
"content": "Kuwait"
},
{
"href": "/wiki/Lebanon",
"title": "Lebanon",
"content": "Lebanon"
},
{
"href": "/wiki/Libya",
"title": "Libya",
"content": "Libya"
},
{
"href": "/wiki/Mauritania",
"title": "Mauritania",
"content": "Mauritania"
},
{
"href": "/wiki/Morocco",
"title": "Morocco",
"content": "Morocco"
},
{
"href": "/wiki/State_of_Palestine",
"title": "State of Palestine",
"content": "Palestine"
},
{
"href": "/wiki/Oman",
"title": "Oman",
"content": "Oman"
},
{
"href": "/wiki/Qatar",
"title": "Qatar",
"content": "Qatar"
},
{
"href": "/wiki/Saudi_Arabia",
"title": "Saudi Arabia",
"content": "Saudi Arabia"
},
{
"href": "/wiki/Somalia",
"title": "Somalia",
"content": "Somalia"
},
{
"href": "/wiki/Sudan",
"title": "Sudan",
"content": "Sudan"
},
{
"href": "/wiki/Syria",
"title": "Syria",
"content": "Syria"
},
{
"href": "/wiki/Tunisia",
"title": "Tunisia",
"content": "Tunisia"
},
{
"href": "/wiki/United_Arab_Emirates",
"title": "United Arab Emirates",
"content": "United Arab Emirates"
},
{
"href": "/wiki/Yemen",
"title": "Yemen",
"content": "Yemen"
}
],
"content": ", \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n ."
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "4"
}
},
{
"strong": {
"a": {
"href": "/wiki/Spanish_language",
"title": "Spanish language",
"content": "Spanish"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "21"
}
},
{
"a": {
"href": "/wiki/Argentina",
"title": "Argentina",
"content": "Argentina"
},
"p": {
"a": [
{
"href": "/wiki/Bolivia",
"title": "Bolivia",
"content": "Bolivia"
},
{
"href": "/wiki/Chile",
"title": "Chile",
"content": "Chile"
},
{
"href": "/wiki/Colombia",
"title": "Colombia",
"content": "Colombia"
},
{
"href": "/wiki/Costa_Rica",
"title": "Costa Rica",
"content": "Costa Rica"
},
{
"href": "/wiki/Cuba",
"title": "Cuba",
"content": "Cuba"
},
{
"href": "/wiki/Dominican_Republic",
"title": "Dominican Republic",
"content": "Dominican Republic"
},
{
"href": "/wiki/Ecuador",
"title": "Ecuador",
"content": "Ecuador"
},
{
"href": "/wiki/El_Salvador",
"title": "El Salvador",
"content": "El Salvador"
},
{
"href": "/wiki/Equatorial_Guinea",
"title": "Equatorial Guinea",
"content": "Equatorial Guinea"
},
{
"href": "/wiki/Guatemala",
"title": "Guatemala",
"content": "Guatemala"
},
{
"href": "/wiki/Honduras",
"title": "Honduras",
"content": "Honduras"
},
{
"href": "/wiki/Mexico",
"title": "Mexico",
"content": "Mexico"
},
{
"href": "/wiki/Nicaragua",
"title": "Nicaragua",
"content": "Nicaragua"
},
{
"href": "/wiki/Panama",
"title": "Panama",
"content": "Panama"
},
{
"href": "/wiki/Paraguay",
"title": "Paraguay",
"content": "Paraguay"
},
{
"href": "/wiki/Peru",
"title": "Peru",
"content": "Peru"
},
{
"href": "/wiki/Puerto_Rico",
"title": "Puerto Rico",
"content": "Puerto Rico"
},
{
"href": "/wiki/United_States",
"title": "United States",
"content": "United States"
},
{
"href": "/wiki/Spain",
"title": "Spain",
"content": "Spain"
},
{
"href": "/wiki/Uruguay",
"title": "Uruguay",
"content": "Uruguay"
},
{
"href": "/wiki/Venezuela",
"title": "Venezuela",
"content": "Venezuela"
}
],
"sup": [
{
"class": "reference",
"id": "cite_ref-1",
"a": {
"href": "#cite_note-1",
"span": [
"[",
"]"
],
"content": "\n 1\n "
}
},
{
"class": "reference",
"id": "cite_ref-2",
"a": {
"href": "#cite_note-2",
"span": [
"[",
"]"
],
"content": "\n 2\n "
}
}
],
"content": ", \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n , \n (\n ),\n \n \n , \n , \n ."
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "5"
}
},
{
"strong": {
"a": {
"href": "/wiki/Italian_language",
"title": "Italian language",
"content": "Italian"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "11"
}
},
{
"a": {
"href": "/wiki/Italy",
"title": "Italy",
"content": "Italy"
},
"p": {
"a": [
{
"href": "/wiki/Albania",
"title": "Albania",
"content": "Albania"
},
{
"href": "/wiki/Croatia",
"title": "Croatia",
"content": "Croatia"
},
{
"href": "/wiki/Eritrea",
"title": "Eritrea",
"content": "Eritrea"
},
{
"href": "/wiki/Malta",
"title": "Malta",
"content": "Malta"
},
{
"href": "/wiki/Monaco",
"title": "Monaco",
"content": "Monaco"
},
{
"href": "/wiki/San_Marino",
"title": "San Marino",
"content": "San Marino"
},
{
"href": "/wiki/Slovenia",
"title": "Slovenia",
"content": "Slovenia"
},
{
"href": "/wiki/Somalia",
"title": "Somalia",
"content": "Somalia"
},
{
"href": "/wiki/Switzerland",
"title": "Switzerland",
"content": "Switzerland"
},
{
"href": "/wiki/Vatican_City",
"title": "Vatican City",
"content": "Vatican City"
}
],
"content": ", \n , \n , \n , \n , \n , \n , \n , \n , \n , \n "
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "5"
}
},
{
"strong": {
"a": {
"href": "/wiki/Portuguese_language",
"title": "Portuguese language",
"content": "Portuguese"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "11"
}
},
{
"a": {
"href": "/wiki/Angola",
"title": "Angola",
"content": "Angola"
},
"p": {
"a": [
{
"href": "/wiki/Brazil",
"title": "Brazil",
"content": "Brazil"
},
{
"href": "/wiki/Cape_Verde",
"title": "Cape Verde",
"content": "Cape Verde"
},
{
"href": "/wiki/East_Timor",
"title": "East Timor",
"content": "East Timor"
},
{
"href": "/wiki/Equatorial_Guinea",
"title": "Equatorial Guinea",
"content": "Equatorial Guinea"
},
{
"href": "/wiki/Goa",
"title": "Goa",
"content": "Goa"
},
{
"href": "/wiki/Guinea-Bissau",
"title": "Guinea-Bissau",
"content": "Guinea-Bissau"
},
{
"href": "/wiki/Macau",
"title": "Macau",
"content": "Macau"
},
{
"href": "/wiki/China",
"title": "China",
"content": "China"
},
{
"href": "/wiki/Mozambique",
"title": "Mozambique",
"content": "Mozambique"
},
{
"href": "/wiki/Portugal",
"title": "Portugal",
"content": "Portugal"
},
{
"href": "/wiki/S%C3%A3o_Tom%C3%A9_and_Pr%C3%ADncipe",
"title": "São Tomé and Príncipe",
"content": "São Tomé and Príncipe"
}
],
"content": ", \n , \n , \n , \n , \n , \n , \n (\n ), \n , \n , \n "
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "6"
}
},
{
"strong": {
"a": {
"href": "/wiki/Russian_language",
"title": "Russian language",
"content": "Russian"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "8"
}
},
{
"a": {
"href": "/wiki/Belarus",
"title": "Belarus",
"content": "Belarus"
},
"p": {
"a": [
{
"href": "/wiki/Ukraine",
"title": "Ukraine",
"content": "Ukraine"
},
{
"href": "/wiki/Kazakhstan",
"title": "Kazakhstan",
"content": "Kazakhstan"
},
{
"href": "/wiki/Kyrgyzstan",
"title": "Kyrgyzstan",
"content": "Kyrgyzstan"
},
{
"href": "/wiki/Russia",
"title": "Russia",
"content": "Russia"
},
{
"href": "/wiki/Abkhazia",
"title": "Abkhazia",
"content": "Abkhazia"
},
{
"href": "/wiki/South_Ossetia",
"title": "South Ossetia",
"content": "South Ossetia"
},
{
"href": "/wiki/Transnistria",
"title": "Transnistria",
"content": "Transnistria"
}
],
"sup": [
{
"class": "reference",
"id": "cite_ref-disputed_3-0",
"a": {
"href": "#cite_note-disputed-3",
"span": [
"[",
"]"
],
"content": "\n 3\n "
}
},
{
"class": "reference",
"id": "cite_ref-disputed_3-1",
"a": {
"href": "#cite_note-disputed-3",
"span": [
"[",
"]"
],
"content": "\n 3\n "
}
},
{
"class": "reference",
"id": "cite_ref-disputed_3-2",
"a": {
"href": "#cite_note-disputed-3",
"span": [
"[",
"]"
],
"content": "\n 3\n "
}
}
],
"content": ", \n , \n , \n , \n , \n ,\n \n ,\n \n .\n "
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "7"
}
},
{
"strong": {
"a": {
"href": "/wiki/German_language",
"title": "German language",
"content": "German"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "7"
}
},
{
"a": {
"href": "/wiki/Austria",
"title": "Austria",
"content": "Austria"
},
"p": {
"a": [
{
"href": "/wiki/Belgium",
"title": "Belgium",
"content": "Belgium"
},
{
"href": "/wiki/Germany",
"title": "Germany",
"content": "Germany"
},
{
"href": "/wiki/Liechtenstein",
"title": "Liechtenstein",
"content": "Liechtenstein"
},
{
"href": "/wiki/Luxembourg",
"title": "Luxembourg",
"content": "Luxembourg"
},
{
"href": "/wiki/Switzerland",
"title": "Switzerland",
"content": "Switzerland"
},
{
"href": "/wiki/Italy",
"title": "Italy",
"content": "Italy"
}
],
"content": ", \n , \n , \n , \n , \n , \n "
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "8"
}
},
{
"strong": {
"a": {
"class": "mw-redirect",
"href": "/wiki/Malay_languages",
"title": "Malay languages",
"content": "Malay based"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "5"
}
},
{
"a": {
"href": "/wiki/Indonesia",
"title": "Indonesia",
"content": "Indonesia"
},
"p": {
"a": [
{
"href": "/wiki/Indonesian_language",
"title": "Indonesian language",
"content": "Indonesian"
},
{
"href": "/wiki/Brunei",
"title": "Brunei",
"content": "Brunei"
},
{
"href": "/wiki/Malaysia",
"title": "Malaysia",
"content": "Malaysia"
},
{
"href": "/wiki/Singapore",
"title": "Singapore",
"content": "Singapore"
},
{
"href": "/wiki/East_Timor",
"title": "East Timor",
"content": "East Timor"
},
{
"href": "/wiki/Working_language",
"title": "Working language",
"content": "working language"
}
],
"content": "(known as \n , and Malay is a separate regional language), \n , \n , \n , \n (in the form of Indonesian, as \n )"
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "9"
}
},
{
"strong": {
"a": {
"href": "/wiki/Romanian_language",
"title": "Romanian language",
"content": "Romanian"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "4"
}
},
{
"a": {
"href": "/wiki/Romania",
"title": "Romania",
"content": "Romania"
},
"p": {
"a": [
{
"href": "/wiki/Moldova",
"title": "Moldova",
"content": "Moldova"
},
{
"href": "/wiki/Serbia",
"title": "Serbia",
"content": "Serbia"
},
{
"href": "/wiki/Vojvodina",
"title": "Vojvodina",
"content": "Vojvodina"
},
{
"href": "/wiki/Transnistria",
"title": "Transnistria",
"content": "Transnistria"
}
],
"content": ", \n , \n (\n ), \n "
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "10"
}
},
{
"strong": {
"a": {
"href": "/wiki/Telugu_language",
"title": "Telugu language",
"content": "Tamil"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "3"
}
},
{
"a": {
"href": "/wiki/India",
"title": "India",
"content": "India"
},
"p": {
"a": [
{
"class": "mw-redirect",
"href": "/wiki/USA",
"title": "USA",
"content": "USA"
},
{
"href": "/wiki/Singapore",
"title": "Singapore",
"content": "Singapore"
}
],
"content": ", \n , \n "
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "10"
}
},
{
"strong": {
"a": {
"href": "/wiki/Standard_Chinese",
"title": "Standard Chinese",
"content": "Chinese"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "3"
}
},
{
"a": {
"href": "/wiki/China",
"title": "China",
"content": "China"
},
"p": {
"a": [
{
"href": "/wiki/Singapore",
"title": "Singapore",
"content": "Singapore"
},
{
"href": "/wiki/Taiwan",
"title": "Taiwan",
"content": "Taiwan"
}
],
"content": ", \n , \n "
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "10"
}
},
{
"strong": {
"a": {
"href": "/wiki/Dutch_language",
"title": "Dutch language",
"content": "Dutch"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "3"
}
},
{
"a": {
"href": "/wiki/Belgium",
"title": "Belgium",
"content": "Belgium"
},
"p": {
"a": [
{
"href": "/wiki/Netherlands",
"title": "Netherlands",
"content": "Netherlands"
},
{
"href": "/wiki/Suriname",
"title": "Suriname",
"content": "Suriname"
}
],
"content": ", \n , \n "
}
}
]
},
{
"td": [
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "10"
}
},
{
"strong": {
"a": {
"href": "/wiki/Persian_language",
"title": "Persian language",
"content": "Persian"
}
}
},
{
"div": {
"class": "center",
"style": "width:auto; margin-left:auto; margin-right:auto;",
"p": "3"
}
},
{
"a": {
"href": "/wiki/Iran",
"title": "Iran",
"content": "Iran"
},
"p": {
"a": [
{
"href": "/wiki/Afghanistan",
"title": "Afghanistan",
"content": "Afghanistan"
},
{
"href": "/wiki/Tajikistan",
"title": "Tajikistan",
"content": "Tajikistan"
}
],
"content": ", \n , \n "
}
}
]
}
]
}
}
}
{
"query": {
"count": 72,
"created": "2013-05-30T03:49:17Z",
"lang": "en-US",
"results": {
"option": [
{"value": "af", "content": "Afrikaans"},
{"value": "sq", "content": "Albanian"},
{"value": "ar", "content": "Arabic"},
{"value": "hy", "content": "Armenian"},
{"value": "az", "content": "Azerbaijani"},
{"value": "eu", "content": "Basque"},
{"value": "be", "content": "Belarusian"},
{"value": "bn", "content": "Bengali"},
{"value": "bs", "content": "Bosnian"},
{"value": "bg", "content": "Bulgarian"},
{"value": "ca", "content": "Catalan"},
{"value": "ceb", "content": "Cebuano"},
{"value": "zh-CN", "content": "Chinese (Simplified)"},
{"value": "zh-TW", "content": "Chinese (Traditional)"},
{"value": "hr", "content": "Croatian"},
{"value": "cs", "content": "Czech"},
{"value": "da", "content": "Danish"},
{"value": "nl", "content": "Dutch"},
{"selected": "selected", "value": "en", "content": "English"},
{"value": "eo", "content": "Esperanto"},
{"value": "et", "content": "Estonian"},
{"value": "tl", "content": "Filipino"},
{"value": "fi", "content": "Finnish"},
{"value": "fr", "content": "French"},
{"value": "gl", "content": "Galician"},
{"value": "ka", "content": "Georgian"},
{"value": "de", "content": "German"},
{"value": "el", "content": "Greek"},
{"value": "gu", "content": "Gujarati"},
{"value": "ht", "content": "Haitian Creole"},
{"value": "iw", "content": "Hebrew"},
{"value": "hi", "content": "Hindi"},
{"value": "hmn", "content": "Hmong"},
{"value": "hu", "content": "Hungarian"},
{"value": "is", "content": "Icelandic"},
{"value": "id", "content": "Indonesian"},
{"value": "ga", "content": "Irish"},
{"value": "it", "content": "Italian"},
{"value": "ja", "content": "Japanese"},
{"value": "jw", "content": "Javanese"},
{"value": "kn", "content": "Kannada"},
{"value": "km", "content": "Khmer"},
{"value": "ko", "content": "Korean"},
{"value": "lo", "content": "Lao"},
{"value": "la", "content": "Latin"},
{"value": "lv", "content": "Latvian"},
{"value": "lt", "content": "Lithuanian"},
{"value": "mk", "content": "Macedonian"},
{"value": "ms", "content": "Malay"},
{"value": "mt", "content": "Maltese"},
{"value": "mr", "content": "Marathi"},
{"value": "no", "content": "Norwegian"},
{"value": "fa", "content": "Persian"},
{"value": "pl", "content": "Polish"},
{"value": "pt", "content": "Portuguese"},
{"value": "ro", "content": "Romanian"},
{"value": "ru", "content": "Russian"},
{"value": "sr", "content": "Serbian"},
{"value": "sk", "content": "Slovak"},
{"value": "sl", "content": "Slovenian"},
{"value": "es", "content": "Spanish"},
{"value": "sw", "content": "Swahili"},
{"value": "sv", "content": "Swedish"},
{"value": "ta", "content": "Tamil"},
{"value": "te", "content": "Telugu"},
{"value": "th", "content": "Thai"},
{"value": "tr", "content": "Turkish"},
{"value": "uk", "content": "Ukrainian"},
{"value": "ur", "content": "Urdu"},
{"value": "vi", "content": "Vietnamese"},
{"value": "cy", "content": "Welsh"},
{"value": "yi", "content": "Yiddish"}
]
}
}
}
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>i18n renderer</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.1/d3.min.js"></script>
<script src="http://www.jasondavies.com/wordcloud/d3.layout.cloud.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
</head>
<body>
<div id="foo" style="dvisibility: hidden;"></div>
<script type="text/javascript">
var height = 700;
var width = 1300;
var maxSize = 0;
Data = function(lan, inf, txt, tlit) {
var self = this;
self.language = lan;
self.influence = inf;
self.size = Math.log(inf+1)*height/60+10;
if (self.size > maxSize) {
maxSize = self.size;
}
self.transliteration = tlit;
self.text = txt;
}
$.getJSON("/data", function(json) {
var rawResults = $.map(json, function(data) {
var translation = eval(data.translation);
return new Data(data.language, data.influence, translation[0][0][0],translation[0][0][2] );
});
var results = _.sortBy(rawResults, function(data){
return data.influence;
});
$.each(results, function(i,d){
console.log(d);
});
var fill = d3.scale.ordinal().range([
"#ccc", "#bbb", "#aaa", "#999", "#888",
"#777", "#666", "#555", "#444", "#333"
]);
d3.layout.
cloud().
size([width, height]).
words(results).
rotate(function(d) {
var span = $('<span style="font-size: ' + d.size + 'px; white-space: nowrap;">' + d.text + '</span>');
$('#foo').append(span);
var len = span.width();
console.log(d.text + ' --> ' + len);
if (d.size == maxSize || len > height/2) {
return 0;
} else {
return (~~(Math.random() * 3) - 1) * 90;
}
}).
font("Impact").
fontSize(function(d) { return d.size ; }).
on("end", draw).
start();
function draw(words) {
d3.select("body").
append("center").
append("svg").
attr("width", width).
attr("height", height).
append("g").
attr("transform", "translate(" + (width/2) + "," + (height/2) + ")").
selectAll("text").
data(words).
enter().append("text").
on("mouseover", hover).
style("font-size", function(d) { return d.size + "px"; }).
style("font-family", "Sans Serif").
style("fill", function(d, i) { return fill(d.size); }).
attr("text-anchor", "middle").
attr("transform", function(d) {
return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")";
}).
text(function(d) { return d.text; });
}
function hover(d) {
var num = 0, color = 'black';
if (d.change > 0) {
color = 'green';
num = "+" + d.change;
} else if (d.change < 0) {
color = 'red';
num = d.change;
}
d3.select("#tooltip").
html(d.item + "<br/><span style='color:" + color + "'>" + num + "</span>");
}
$('#foo').hide();
});
</script>
</body>
</html>
{
"query": {
"count": 13,
"created": "2013-05-30T03:41:51Z",
"lang": "en-US",
"results": {
"tr": [
{"th": [{"p": "Language"}, {"p": "Percent of World Population"}]},
{"td": [{"p": "Mandarin"}, {"p": "12.44%"}]},
{"td": [{"p": "Spanish"}, {"p": "4.85%"}]},
{"td": [{"p": "English"}, {"p": "4.83%"}]},
{"td": [{"p": "Arabic"}, {"p": "3.25%"}]},
{"td": [{"p": "Hindi"}, {"p": "2.68%"}]},
{"td": [{"p": "Bengali"}, {"p": "2.66%"}]},
{"td": [{"p": "Portuguese"}, {"p": "2.62%"}]},
{"td": [{"p": "Russian"}, {"p": "2.12%"}]},
{"td": [{"p": "Japanese"}, {"p": "1.80%"}]},
{"td": [{"p": "German"}, {"p": "1.33%"}]},
{"td": [{"p": "Javanese"}, {"p": "1.25%"}]},
{"td": [{"p": "Others"}, {"p": "61.17%"}]}
]
}
}
}
@Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.6')
@Grab('org.eclipse.jetty:jetty-server:9.1.2.v20140210')
@Grab('org.eclipse.jetty:jetty-servlet:9.1.2.v20140210')
@Grab('javax.servlet:javax.servlet-api:3.0.1')
@GrabExclude('org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016')
import groovy.json.*
import groovyx.net.http.ContentType
import groovyx.net.http.RESTClient
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.servlet.ServletContextHandler
import org.eclipse.jetty.servlet.ServletHolder
import javax.servlet.http.HttpServlet
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
assert args.length > 0
assert args[0]
def transforms = [
'Chinese (Simplified)': 'Mandarin',
'Chinese (Traditional)': 'Cantonese',
]
def googleLanguages = new JsonSlurper().parseText(new File('google.json').text).query.results.option.collect {
[language: transforms[it.content] ?: it.content, code: it.value]
}
def countries = new JsonSlurper().parseText(new File('countries.json').text).query.results.tr[1..-1].collect {
[language: it.td[1].strong.a.content.split(' ')[0], countries: Integer.parseInt(it.td[2].div.p)]
}
def speakers = new JsonSlurper().parseText(new File('speakers.json').text).query.results.tr[1..-2].collect {
[language: it.td[0].p, speakers: Double.parseDouble(it.td[1].p.replace('%', ''))]
}
def goog = new RESTClient('http://translate.google.com/translate_a/')
def mychart = googleLanguages
mychart.each { map ->
map.influence = (countries.find { c -> c.language == map.language }?.countries ?: 1) *
(speakers.find { c -> c.language == map.language }?.speakers ?: 0.5)
map.translation = goog.get(
path: 'single',
contentType: ContentType.TEXT,
query: [
client: 't',
q: args[0],
sl: 'en', tl: map.code, hl: map.code,
dt: ['bd', 'ex', 'ld', 'md', 'qca', 'rw', 'rm', 'ss', 't', 'at'],
ie: 'UTF-8', oe: 'UTF-8',
ssel: '3', tsel: '6',
kc: '1',
]
).data.text
}
def jettyServer = new Server(8000)
jettyServer.with {
setHandler(new ServletContextHandler(ServletContextHandler.NO_SESSIONS).with {
resourceBase = '/'
addServlet(new ServletHolder(new HttpServlet(){
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
resp.writer << new File('index.html').text
}
}), '/')
addServlet(new ServletHolder(new HttpServlet(){
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
resp.writer << new JsonBuilder(mychart).toPrettyString()
}
}), '/data')
it
})
start()
}
@chrizfasa424
Copy link

Please I can I make use of this code?
Also I want my website to be translating automatic to Chinese language or any other language as the case may be.

@rahulsom
Copy link
Author

@chrizfasa424 I don't know if this still runs, but if it does, do whatever you please with it.

@chrizfasa424
Copy link

chrizfasa424 commented Jan 24, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment