Google Search की अनुवाद से जुड़ी सुविधाओं को अपनी विज्ञापन नेटवर्क कंपनी के लिए चालू करना

Google Search में अनुवाद से जुड़ी कई सुविधाएं मिलती हैं, ताकि उपयोगकर्ता अनुवाद किया गया कॉन्टेंट ऐक्सेस कर सकें. अगर आपकी कोई विज्ञापन नेटवर्क कंपनी है और आपके विज्ञापन, अनुवाद किए गए वेब पेजों पर ठीक से काम नहीं कर रहे हैं, तो आपको इस गाइड में दिए गए तरीके अपनाने होंगे. ऐसा इसलिए, ताकि आप यह पक्का कर सकें कि आपके विज्ञापन सही तरीके से रेंडर या एट्रिब्यूट हो रहे हैं.

हमारा काम करने का तरीका

जब उपयोगकर्ता, खोज के नतीजों में Google Translate से मिले अनुवाद वाले कॉन्टेंट को ऐक्सेस करते हैं, तो Google, पब्लिशर के पेज को फिर से लोड करता है. साथ ही, स्रोत के यूआरएल को फिर से लिखता है और अनुवाद किए गए नतीजे पर उपयोगकर्ता के क्लिक करने के बाद, वेब पेज का अनुवाद करता है.

Google Translate के यूआरएल को मूल यूआरएल में बदलना

अगर आपकी कोई ऐसी विज्ञापन नेटवर्क कंपनी है जो पब्लिशर के स्रोत के यूआरएल पर निर्भर है, तो आपको Google Translate के यूआरएल को बदलना होगा. ऐसा इसलिए, ताकि यह पक्का हो सके कि आपके विज्ञापन ठीक से काम कर रहे हैं. पब्लिशर के होस्टनेम को डिकोड करने के लिए, यह तरीका अपनाएं:

  1. होस्टनेम से डोमेन का प्रीफ़िक्स निकालें. इसके लिए, आपको .translate.goog सफ़िक्स को हटाना होगा.
  2. _x_tr_enc पैरामीटर को , (कॉमा) वर्ण से अलग करें और इसे encoding_list के तौर पर सेव करें.
  3. अगर डोमेन पैरामीटर के लिए _x_tr_hp पैरामीटर मौजूद है, तो उसे पहले जोड़ें.
  4. अगर encoding_list में 1 है और आउटपुट 1- से शुरू होता है, तो दूसरे चरण के आउटपुट से 1- प्रीफ़िक्स हटा दें.
  5. अगर encoding_list में 0 है और आउटपुट 0- से शुरू होता है, तो तीसरे चरण के आउटपुट से 0- प्रीफ़िक्स हटा दें. अगर आपने प्रीफ़िक्स हटाया है, तो is_idn को true पर सेट करें. या फिर is_idn को false पर सेट करें.
  6. /\b-\b/ (रेगुलर एक्सप्रेशन) को . (बिंदु) वर्ण से बदलें.
  7. -- (डबल हाइफ़न) की जगह - (हाइफ़न) वर्ण का इस्तेमाल करें.
  8. अगर is_idn को true पर सेट किया गया है, तो प्यूनीकोड प्रीफ़िक्स xn-- जोड़ें.
  9. ज़रूरी नहीं: यूनिकोड में बदलें.

Google Translate के यूआरएल से होस्टनेम को डिकोड करने के लिए, JavaScript कोड का सैंपल

function decodeHostname(proxyUrl) {
  const parsedProxyUrl = new URL(proxyUrl);
  const fullHost = parsedProxyUrl.hostname;
  // 1. Extract the domain prefix from the hostname, by removing the
        ".translate.goog" suffix
  let domainPrefix = fullHost.substring(0, fullHost.indexOf('.'));

  // 2. Split _x_tr_enc parameter by "," (comma), save as encodingList
  const encodingList = parsedProxyUrl.searchParams.has('_x_tr_enc') ?
      parsedProxyUrl.searchParams.get('_x_tr_enc').split(',') :
      [];

  // 3. Prepend value of _x_tr_hp parameter to the domain prefix, if it exists
  if (parsedProxyUrl.searchParams.has('_x_tr_hp')) {
    domainPrefix = parsedProxyUrl.searchParams.get('_x_tr_hp') + domainPrefix;
  }

  // 4. Remove '1-' prefix from the output of step 2 if encodingList contains
  //    '1' and the output begins with '1-'.
  if (encodingList.includes('1') && domainPrefix.startsWith('1-')) {
    domainPrefix = domainPrefix.substring(2);
  }

  // 5. Remove '0-' prefix from the output of step 3 if encodingList contains
  //    '0' and the output begins with '0-'.
  //    Set isIdn to true if removed, false otherwise.
  let isIdn = false;
  if (encodingList.includes('0') && domainPrefix.startsWith('0-')) {
    isIdn = true;
    domainPrefix = domainPrefix.substring(2);
  }

  // 6. Replace /\b-\b/ (regex) with '.' (dot) character.
  // 7. Replace '--' (double hyphen) with '-' (hyphen).
  let decodedSegment =
      domainPrefix.replaceAll(/\b-\b/g, '.').replaceAll('--', '-');

  // 8. If isIdn equals true, add the punycode prefix 'xn--'.
  if (isIdn) {
    decodedSegment = 'xn--' + decodedSegment;
  }
  return decodedSegment;
}

यूआरएल को फिर से बनाएं

  1. मूल पेज के यूआरएल का इस्तेमाल करके, होस्टनेम को डिकोड किए गए होस्टनेम से बदलें.
  2. सभी _x_tr_* पैरामीटर हटाएं.

अपने कोड की जांच करें

नीचे दी गई टेबल का इस्तेमाल करके, अपने कोड के लिए यूनिट की जांच की जा सकती है. proxyUrl दिए जाने पर, decodeHostname को अनुमानित वैल्यू से मेल खाना चाहिए.

इस टेबल का इस्तेमाल, सिर्फ़ होस्टनेम को डीकोड करने की जांच करने के लिए किया जा सकता है. आपको यह पक्का करना होगा कि यूआरएल का पाथ, फ़्रैगमेंट, और ओरिजनल पैरामीटर पहले जैसे ही हैं.

proxyUrl decodeHostname
https://example-com.translate.goog example.com
https://foo-example-com.translate.goog foo.example.com
https://foo--example-com.translate.goog foo-example.com
https://0-57hw060o-com.translate.goog/?_x_tr_enc=0 xn--57hw060o.com (⚡😊.com)
https://1-en--us-example-com/?_x_tr_enc=1 en-us.example.com
https://0-en----w45as309w-com.translate.goog/?_x_tr_enc=0 xn--en--w45as309w.com (en-⚡😊.com)
https://1-0-----16pw588q-com.translate.goog/?_x_tr_enc=0,1 xn----16pw588q.com (⚡-😊.com)
https://lanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch-co-uk.translate.goog/?_x_tr_hp=l llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch.co.uk
https://lanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch-co-uk.translate.goog/?_x_tr_hp=www-l www.llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch.co.uk
https://a--aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-com.translate.goog/?_x_tr_hp=a--xn--xn--xn--xn--xn--------------------------a a-xn-xn-xn-xn-xn-------------aa-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com
https://g5h3969ntadg44juhyah3c9aza87iiar4i410avdl8d3f1fuq3nz05dg5b-com.translate.goog/?_x_tr_enc=0&_x_tr_hp=0- xn--g5h3969ntadg44juhyah3c9aza87iiar4i410avdl8d3f1fuq3nz05dg5b.com (💖🌲😊💞🤷‍♂️💗🌹😍🌸🌺😂😩😉😒😘💕🐶🐱🐭🐹🐰🐻🦊🐇😺.com)