• Resolved leroar

    (@leroar)


    hi folks,

    i’m doing a german blog at http://www.losziehn.de using the theme oxygen and tried to change the language of the comment form in order to put in the german phrases, eg “leave a reply” changed to “kommentar abgeben”. i found those hints in the forum:

    http://wordpress.org/support/topic/how-to-change-wording-of-leave-a-reply

    so i changed my comment form in the comments_template.php of the wp-includes-folder. but it didn’t work out as you can see on the site.

    here is how the comment form now looks like:

    function comment_form( $args = array(), $post_id = null ) {
    	global $id;
    
    	if ( null === $post_id )
    		$post_id = $id;
    	else
    		$id = $post_id;
    
    	$commenter = wp_get_current_commenter();
    	$user = wp_get_current_user();
    	$user_identity = $user->exists() ? $user->display_name : '';
    
    	$req = get_option( 'require_name_email' );
    	$aria_req = ( $req ? " aria-required='true'" : '' );
    	$fields =  array(
    		'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
    		            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
    		'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
    		            '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
    		'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
    		            '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
    	);
    
    	$required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' );
    	$defaults = array(
    		'fields'               => apply_filters( 'comment_form_default_fields', $fields ),
    		'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
    		'must_log_in'          => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
    		'logged_in_as'         => '<p class="logged-in-as">' . sprintf( __( 'Eingeloggt als <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Ausloggen?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
    		'comment_notes_before' => '<p class="comment-notes">' . __( 'Deine E-Mail-Adresse wird nicht veröffentlicht!!!' ) . ( $req ? $required_text : '' ) . '</p>',
    		'comment_notes_after'  => '<p class="form-allowed-tags">' . sprintf( __( 'Vielleicht möchtest Du diese <abbr title="HyperText Markup Language">HTML</abbr> Befehle benutzen: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>',
    		'id_form'              => 'commentform',
    		'id_submit'            => 'submit',
    		'title_reply'          => __( 'Kommentar abgeben' ),
    		'title_reply_to'       => __( 'Kommentar abgeben an %s' ),
    		'cancel_reply_link'    => __( 'Abbrechen' ),
    		'label_submit'         => __( 'Absenden' ),
    	);
    
    	$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
    
    	?>
    		<?php if ( comments_open( $post_id ) ) : ?>
    			<?php do_action( 'comment_form_before' ); ?>
    			<div id="respond">
    				<h3 id="reply-title"><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h3>
    				<?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?>
    					<?php echo $args['must_log_in']; ?>
    					<?php do_action( 'comment_form_must_log_in_after' ); ?>
    				<?php else : ?>
    					<form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>">
    						<?php do_action( 'comment_form_top' ); ?>
    						<?php if ( is_user_logged_in() ) : ?>
    							<?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?>
    							<?php do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); ?>
    						<?php else : ?>
    							<?php echo $args['comment_notes_before']; ?>
    							<?php
    							do_action( 'comment_form_before_fields' );
    							foreach ( (array) $args['fields'] as $name => $field ) {
    								echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
    							}
    							do_action( 'comment_form_after_fields' );
    							?>
    						<?php endif; ?>
    						<?php echo apply_filters( 'comment_form_field_comment', $args['comment_field'] ); ?>
    						<?php echo $args['comment_notes_after']; ?>
    						<p class="form-submit">
    							<input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" />
    							<?php comment_id_fields( $post_id ); ?>
    						</p>
    						<?php do_action( 'comment_form', $post_id ); ?>
    					</form>
    				<?php endif; ?>
    			</div><!-- #respond -->
    			<?php do_action( 'comment_form_after' ); ?>
    		<?php else : ?>
    			<?php do_action( 'comment_form_comments_closed' ); ?>
    		<?php endif; ?>
    	<?php
    }

    any ideas what i did wrong? thx a lot guys!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter leroar

    (@leroar)

    does anyone knows help?

    I have the same problem and I can´t fix it!!! 🙁

    Thread Starter leroar

    (@leroar)

    hi, i got the solution via another forum. there are 2 options:

    1. the elegant, but quite complex one (haven’t tried it yet): copy the language-files in the language folder of your theme (those en_EN.mo and .po ones). the path is wp-content -> themes -> your theme -> laanguages. download poEdit and translate all of them. then rename them, e.g. de_DE.po instead of en_EN.po and upload them. then alter following code in your wp-config.php to the language you’ve chosen, e.g.:

    define('WPLANG', 'de_DE');

    2. go to the functions.php of your theme via dashboard->design->editor. there you’ll find the section for the comment-form and all connected phrases. search for “leave a reply” and all the other phrases you want to change and translate them. also a bit difficult, but it works. disadvantage is that all the changes get lost once you update your theme:(.

    hope that helps! cheerz…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I change the language of comment form ("leave a reply")’ is closed to new replies.