Plugin: BuddyPress ScholarPress Courseware

Join this plugin group to follow comments, support topics and reviews.

Rename Labels (2 posts)

Started 8 months, 2 weeks ago by: matheuwhitehead

  • Profile picture of matheuwhitehead matheuwhitehead said 8 months, 2 weeks ago:

    Hi,

    I have began to edit the PO file to rename some of the labels, although notice there are some labels I am unable to change.

    For example I am in the process of changing Course to Wiki and I have change the majority of it, although cannot change the ‘New Course’ input form labels, which are:

    - Add a New Course (Title)
    - Course Title (Field)
    - Add a New Course (Button)

    Hope that makes sense, will help me if I could understand where to change this, much appreciated!

    Matt

  • Profile picture of Stas SuČ™cov Stas Suscov said 8 months, 2 weeks ago:

    po files are what should be updated.
    Though, I wrote something like this, to replace any appearence of word group, you can use it as an example.

    /**
     * Project specific string changes
     */
    function learn_gettext( $translation, $text ) {
        $dirty = false;
        $strings_map = array(
            'group'     => 'class',
            'groups'    => 'classes',
            'Group'     => 'Class',
            'Groups'    => 'Classes'
        );
    
        $text_words = explode( ' ', $text );
    
        // Try to find strings to be replaced and preserve the punctuation
        foreach ( $text_words as $k => $word ) {
            $w = trim( $word, '.,:!?-_()' );
            if ( isset( $strings_map[ $w ] ) ) {
                $text_words[ $k ] = str_replace( $w, $strings_map[ $w ], $word );
                $dirty = true;
            }
        }
    
        if ( $dirty ) {
            return implode( ' ', $text_words );
        }
    
        return $translation;
    }
    add_filter( 'gettext', 'learn_gettext', 10, 2 );