フォーム内指定テキスト英語化

エラー文&確認画面内テキスト&送信後テキストを変更

追加可能パーツ 変更可能箇所 変更NG 同一ページ
に複数設置

ページ複製・
クリップボード使用可否

  • フォームの項目は
    どれでも可 ※1
  • フォームデザイン
  • 英文※2
× ◯ 
※留意事項  

※1:エラー文の先頭には必ずラベル名がつく仕様(こちら参照)です。
※2:英文はJS側で設定するため変更は不可とさせていただきます。
※ラベル名はフォーム編集機能からいつでも変更可能です。

英文一覧

※英文変更不可
※ラベル名はフォーム設定から適宜変更可

before▼

・Nameは必須です。
・Emailは、メールアドレス形式で入力してください。
・Phone Numberは、半角数字、プラス記号 (+)、ハイフン (-) のみを使用し、最大20桁までの長さで入力してください。
・氏名(カナ)は、全角カタカナで入力してください。
・郵便番号は、半角数字とハイフンで入力してください。
・ホームページのURLは、httpもしくはhttpsで始まる文字列を入力してください。
・年齢(入力式) は、正の整数を入力してください。

after▼

・Name is required field.
・Email : Please enter a valid email address.
・Phone Number : Letters must be less than 20 characters. (only "+" and "-" are available for symbols)
・氏名(カナ) : Please input using full-width katakana.
・郵便番号 : Please input using half-width numbers and hyphen.
・ホームページのURL : Please make sure that your URL starts with "http" or "https".
・年齢(入力式) : Please enter an integer.

▼全ての項目を下記フォームから確認できます。

設定方法

  • JavaScriptを使用したいパーツのセクション一番下に配置。複数ページ設置する場合は共通フッターに配置。
  • クラス名を見本とあわせる。
  1. フォームパーツにクラス名「en」を追加。
    ※旧CMSやフォームをカスタムする場合、必要に応じてクラス「form_custom form_btn_custom01」等を追加。
  2. 項目名の名称はフォーム設定から適宜変更してください。
  3. 必須ボタンはJS側でスタイル記述しています。
  4. フォームには基本フッターをつけないため、フッターを使用しない場合はフォームページ毎にJS埋め込みコードを設置する必要があります。
  • 新CMSの場合:基本デザインパーツを使用して問題ないです。

注意点

  • 選択リストの「ファイルを選択」とテキスト「選択されていません」については、ユーザーエージェントのためブラウザの言語設定に依存されます。
     
  • 以下の項目は日本基準のカレンダーになります。
    • 日付時刻
    • 日付

    • 生年月日
       
  • 以下のリスト部分の日本語は編集画面で変更可能です。
    • 都道府県
    • 年齢(年代別)
    • 性別
    • 職業

JavaScript

2024-09-10更新(v1.0.0)

<script>
/* ---------------------------
フォーム内指定テキスト英語化 v1.0.0​​​​​
--------------------------- */
'use strict';

document.addEventListener('DOMContentLoaded', function () {
/* ---------------------------
フォームエラー文を変更
--------------------------- */
/* 動的な要素を監視して実行する */
const observer = new MutationObserver( () => {
let errorMessage = document.querySelectorAll('.en .alert-danger');/* エラー文のクラス */
for (let i = 0; i < errorMessage.length; i++) {
/* 左に変更したいテキスト・右に変更後のテキストを入れる */
errorMessage[i].textContent = errorMessage[i].innerHTML
.replace('は必須です。', ' is required field.')
.replace('は必須です', ' is required field.')
.replace('は、半角数字、プラス記号 (+)、ハイフン (-) のみを使用し、最大20桁までの長さで入力してください。', ' : Letters must be less than 20 characters. (only "+" and "-" are available for symbols)')
.replace('は、httpもしくはhttpsで始まる文字列を入力してください。', ' : Please make sure that your URL starts with "http" or "https".')
.replace('は、全角カタカナで入力してください。', ' : Please input using full-width katakana.')
.replace('は、半角数字とハイフンで入力してください。', ' : Please input using half-width numbers and hyphen.')
.replace('は、メールアドレス形式で入力してください。', ' : Please enter a valid email address.')
.replace('は、正の整数を入力してください。', ' : Please enter an integer.');
/* DOM変化の監視を一時停止 */
observer.disconnect();
}
/* 処理再開 */
setTimeout(() => {
observer.observe(target, {
childList: true,/* 監視対象の要素の子要素を指定 */
subtree: true,/* 孫以降のノードの変化も検出 */
characterData: true,/* 文字列の変化を監視 */
});
}, 100);
});


const target = document.querySelectorAll('.en .show-notice')[0];/* エラー文の一覧を囲っているクラス */
/* 監視対象のものを設定 */
observer.observe(target, {
childList: true,/* 監視対象の要素の子要素を指定 */
subtree: true,/* 孫以降のノードの変化も検出 */
characterData: true,/* 文字列の変化を監視 */
});


/* ---------------------------
確認画面モーダル内のテキストを変更
--------------------------- */
/* 動的な要素を監視して実行する */
const observer02 = new MutationObserver( () => {
const sendText = document.querySelectorAll('.ReactModal__Content span')[0];/* 確認モーダル内リード文 */
const cancelBtn = document.querySelectorAll(`[class^='styles_contact-submit-cancel']`)[0];/* 確認モーダル内キャンセルボタン */
const sendBtn = document.querySelectorAll(`[class^='styles_contact-submit-confirm']`)[0];/* 確認モーダル内送信ボタン */
/* キャンセルボタンかつ送信ボタンがあれば実行 */
if (cancelBtn || sendBtn) {
/* 左に変更したいテキスト・右に変更後のテキストを入れる */
/* sendText.textContent = sendText.innerHTML.replace('この内容で送信します。よろしいですか?', 'Send with this content. Is it OK?');*/
sendText.textContent = "Please check the contents, then click 'send' button.";
cancelBtn.textContent = 'cancel';
sendBtn.textContent = 'send';
} else {
return
}
});

const target02 = document.querySelectorAll('.ReactModalPortal')[0];/* 確認画面モーダルのクラス */
/* 監視対象のものを設定 */
observer02.observe(target02, {
childList: true/* 監視対象の要素の子要素を指定 */
});

/* ---------------------------
送信後テキストを変更
--------------------------- */
/* 動的な要素を監視して実行する */
const observer03 = new MutationObserver( () => {
const sendingText = document.querySelectorAll('.form-submiting-message, .form-submitting-message',)[0];/* 送信後テキストを取得 */
if (sendingText) {
/* 左に変更したいテキスト・右に変更後のテキストを入れる */
sendingText.textContent = 'Sending.';
} else {
return
}
});

const target03 = document.querySelectorAll('.group:last-child')[0];/* 送信後のテキストが含まれる親要素 */
/* 監視対象のものを設定 */
observer03.observe(target03, {
childList: true/* 監視対象の要素の子要素を指定 */
});

});
</script>
<style>
.theme-fo-base .component.form.en .form-label.require:not(:root:root:root):after {
content: "Required";/* 必須ボタン英語化 */
}
</style>
<!-- フォーム内指定テキスト英語化 END -->

JSが必要な実装の注意点スプレッドシート(H列)は読みましたか?

※必ず注意点(H列)をご確認の上閲覧ください

ページトップへ戻る