LoginSignup
0
0

More than 3 years have passed since last update.

memberpressのユーザーカスタムフィールドを翻訳可能にする。

Posted at

memberpressではカスタムフィールドでユーザーに属性をつけることができますが、このカスタムフィールドの名前、フォームで入力するときに表示されるのですがこれがpotファイルを使ったりで翻訳することができません。

管理上良い方法ではないかもしれませんが、プラグインファイルを編集することで翻訳できるようになります。というメモ。

翻訳できる文字列にする方法

/wp-content/plugins/memberpress/app/views/checkout/signup_row.phpを編集します。

signup_row.php
<?php if(!defined('ABSPATH')) {die('You are not allowed to call this page directly.');} ?>

<div class="mp-form-row mepr_custom_field mepr_<?php echo $line->field_key; ?>">
  <?php if($line->field_type != 'checkbox'): ?>
    <div class="mp-form-label">
      <label for="<?php echo $line->field_key . $unique_suffix; ?>"><?php printf( '%1$s:%2$s', _x(stripslashes($line->field_name), 'ui', 'memberpress'), $required ); ?></label>
      <?php //↓この行だけ編集する ?>
      <span class="cc-error"><?php ($line->required) /*here for email custom fields that are not required*/ ? printf(_x('%s is Required', 'ui', 'memberpress'),  _x(stripslashes($line->field_name), 'ui', 'memberpress')) : printf(_x('%s is not valid', 'ui', 'memberpress'), _x(stripslashes($line->field_name),'ui', 'memberpress')); ?></span>
    <?php //↑この行だけ編集する ?>
    </div>
  <?php endif; ?>
  <?php echo MeprUsersHelper::render_custom_field($line,$value,array(),$unique_suffix); ?>
</div>

やってること

Wordpressでは関数_x()で翻訳可能な単語を示してあげることができるのでこれを利用します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0