以前は「Google ウェブサイト翻訳ツール」でカンタンに多言語対応できたのだけれど、今は有料の「Cloud Translation API」となってしまいました。
しかし有料というのはクライアント的にはけっこう敷居が高くて、金額の多寡だけじゃなく、支払の口座をどうするかから地味に面倒。料金を払ってまで多言語したいわけじゃないしと、見送りになってしまうこともしばしばありますよね。
そんな場合に、とりあえずで使えるのがGoogle翻訳サイトに自ページURLを投げる方法。
-----
https://translate.google.com/translate?sl=ja&tl=en&u=https://hogehoge.com/
→ sl:原文の言語
→ tl:翻訳後の言語
→ u:ページURL
-----
例えば当ページを投げるならこんな感じ
https://translate.google.com/translate?sl=ja&tl=en&u=https://ef-techmemo.makeit2.co.jp/2026/03/translate.google.html
これをjsなどでリンク先を作ってボタンにすれば良い。
HTMLソース例
<a id="google-translate-link" href="#" target="_blank">
英語版(Google翻訳)
</a>
<script>
// 現在のページURLを取得
const currentUrl = window.location.href;
// Google翻訳のベースURL
const base = "https://translate.google.com/translate?sl=ja&tl=en&u=";
// エンコードして連結
const translatedUrl = base + encodeURIComponent(currentUrl);
// 例:リンク要素にセットする場合
const link = document.getElementById("google-translate-link");
if (link) {
link.href = translatedUrl;
}
</script>