Support Forum 日本語の編集について

translate このフォーラムは日本語でも利用できます。ログインして、言語設定を変更してください。

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #379
    @nagashimaryo
    Participant

    Gianism いつも使っております。

    カスタマイズしているうちに何点か質問したいことがあり、こちらに記述しにきました。

    まずは、「コネクト」「切断」などの文言を他の文言に変更したい場合、どちらを編集すればよろしいですか?
    (wp-gianism-ja.poにはありましたが、ここを変更しても反応されず)
    また、ファイルではなくアクションフックで変更可能ならそちらもご教授いただけると嬉しいです。

    #383
    Fumiki
    Keymaster

    お返事遅れてすみません。後ほどコードをお送りいたします。

    #385
    Fumiki
    Keymaster
    /**
     * 翻訳文字列にフィルターを追加
     * 
     * @param string $translation 翻訳文
     * @param string $text        オリジナル(英語)の文字列
     * @param string $domain      ドメイン名。この場合、wp-gianism
     */
    add_filter( 'gettext', function( $translation, $text, $domain  ) {
    	// 該当しなければ元のまま.
    	if ( 'wp-gianism' !== $domain ) {
    		return $translation;
    	}
    	// 該当する文言を変更する
    	switch ( $text ) {
    		case 'Disconnect':
    			return '解除';
    		case 'Connect':
    			return '連携';
    		default:
    			return $translation;
    	}
    }, 10, 3 );
    

    おそらく上記のような感じで文字列を変更することができます。

    #386
    @nagashimaryo
    Participant

    お返事ありがとうございます。

    上記を使い、変更できました。
    gettextフィルタ、便利ですね!

    これからもよろしくお願いします。

    • This reply was modified 5 years, 11 months ago by @nagashimaryo.
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
SPONSORED LINK
SPONSORED LINK