Skip to content

Commit

Permalink
fix: internationalization and slug text domain congruence (#69)
Browse files Browse the repository at this point in the history
* fix: internationalization and slug text domain congruence

* fix: add a specific text domain to check in the phpcs tests
  • Loading branch information
MaferMazu authored Apr 2, 2024
1 parent 645a92d commit 8461178
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 38 deletions.
28 changes: 14 additions & 14 deletions admin/views/class-openedx-commerce-enrollment-info-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function render_enrollment_info_form( $post ) {
?>
>
<span class="openedx-tooltip-icon">?</span>
<span class="openedx-tooltip-text"><?php esc_html_e( 'The id of the course to be used for the enroll, e.g. course-v1:edX+DemoX+Demo_Course.', 'wp-openedx-commerce' ); ?></span>
<span class="openedx-tooltip-text"><?php esc_html_e( 'The id of the course to be used for the enroll, e.g. course-v1:edX+DemoX+Demo_Course.', 'openedx-commerce' ); ?></span>
</td>
</tr>
<tr>
Expand All @@ -126,8 +126,8 @@ public function render_enrollment_info_form( $post ) {
<input type="email" id="openedx_enrollment_email" name="openedx_enrollment_email" value="<?php echo esc_attr( $email ); ?>">
</div>
<span class="openedx-tooltip-icon">?</span>
<span class="openedx-tooltip-text"><?php esc_html_e( 'The email of the user to be used for the enroll.', 'wp-openedx-commerce' ); ?></span>
<button name="enrollment_sync" class="button save_order button-secondary sync_button"><span><?php esc_html_e( 'Read from Open edX', 'wp-openedx-commerce' ); ?></span></button>
<span class="openedx-tooltip-text"><?php esc_html_e( 'The email of the user to be used for the enroll.', 'openedx-commerce' ); ?></span>
<button name="enrollment_sync" class="button save_order button-secondary sync_button"><span><?php esc_html_e( 'Read from Open edX', 'openedx-commerce' ); ?></span></button>
</td>
</tr>
<tr class="gray_zone first_zone">
Expand All @@ -141,7 +141,7 @@ public function render_enrollment_info_form( $post ) {
<?php endforeach; ?>
</select>
<span class="openedx-tooltip-icon">?</span>
<span class="openedx-tooltip-text"><?php esc_html_e( 'The mode of your enrollment request. Make sure to set a mode that your course has.', 'wp-openedx-commerce' ); ?></span>
<span class="openedx-tooltip-text"><?php esc_html_e( 'The mode of your enrollment request. Make sure to set a mode that your course has.', 'openedx-commerce' ); ?></span>
</td>
</tr>

Expand All @@ -160,7 +160,7 @@ public function render_enrollment_info_form( $post ) {
?>
>
<?php
esc_html_e( 'Enroll', 'wp-openedx-commerce' );
esc_html_e( 'Enroll', 'openedx-commerce' );
?>
</option>
<option value="unenroll"
Expand All @@ -171,12 +171,12 @@ public function render_enrollment_info_form( $post ) {
?>
>
<?php
esc_html_e( 'Un-enroll', 'wp-openedx-commerce' );
esc_html_e( 'Un-enroll', 'openedx-commerce' );
?>
</option>
</select>
<span class="openedx-tooltip-icon">?</span>
<span class="openedx-tooltip-text"><?php esc_html_e( 'The type of your request. If you select Enroll, you will create an enrollment, and if you select Un-enroll, you will set a soft unenrollment (enrollment with status inactive).', 'wp-openedx-commerce' ); ?></span>
<span class="openedx-tooltip-text"><?php esc_html_e( 'The type of your request. If you select Enroll, you will create an enrollment, and if you select Un-enroll, you will set a soft unenrollment (enrollment with status inactive).', 'openedx-commerce' ); ?></span>
</td>
</tr>
<tr class="gray_zone">
Expand All @@ -195,31 +195,31 @@ public function render_enrollment_info_form( $post ) {
?>
</div>
<span class="openedx-tooltip-icon">?</span>
<span class="openedx-tooltip-text"><?php esc_html_e( 'The id of the order associated with this request.', 'wp-openedx-commerce' ); ?></span>
<span class="openedx-tooltip-text"><?php esc_html_e( 'The id of the order associated with this request.', 'openedx-commerce' ); ?></span>
</td>
</tr>

<tr class="gray_zone">
<td class="checkbox-td">
<input class="action-checkbox" type="checkbox" id="openedx_enrollment_force" name="openedx_enrollment_force" value="openedx_force">
<label for="openedx_enrollment_force"><?php esc_html_e( 'Use the "force" flag', 'wp-openedx-commerce' ); ?></label>
<label for="openedx_enrollment_force"><?php esc_html_e( 'Use the "force" flag', 'openedx-commerce' ); ?></label>
<span class="openedx-tooltip-icon">?</span>
<span class="openedx-tooltip-text"><?php esc_html_e( "Disregard the course's enrollment end dates.", 'wp-openedx-commerce' ); ?></span>
<span class="openedx-tooltip-text"><?php esc_html_e( "Disregard the course's enrollment end dates.", 'openedx-commerce' ); ?></span>
</td>
<td>
<input class="action-checkbox" type="checkbox" id="openedx_enrollment_allowed" name="openedx_enrollment_allowed" value="openedx_allowed">
<label for="openedx_enrollment_allowed"><?php esc_html_e( "Create course enrollment allowed if the user doesn't exist", 'wp-openedx-commerce' ); ?></label>
<label for="openedx_enrollment_allowed"><?php esc_html_e( "Create course enrollment allowed if the user doesn't exist", 'openedx-commerce' ); ?></label>
<span class="openedx-tooltip-icon">?</span>
<span class="openedx-tooltip-text"><?php esc_html_e( 'Creates a register in the table Course Enrollment Allowed if the email we use in the request is not a user in our Open edX platform yet.', 'wp-openedx-commerce' ); ?></span>
<span class="openedx-tooltip-text"><?php esc_html_e( 'Creates a register in the table Course Enrollment Allowed if the email we use in the request is not a user in our Open edX platform yet.', 'openedx-commerce' ); ?></span>
</td>
</tr>

<tr class="gray_zone">
<td class="first">
<button name="enrollment_process" class="button save_order button-primary"><span><?php esc_html_e( 'Save and update Open edX', 'wp-openedx-commerce' ); ?></span></button>
<button name="enrollment_process" class="button save_order button-primary"><span><?php esc_html_e( 'Save and update Open edX', 'openedx-commerce' ); ?></span></button>
</td>
<td>
<button name="save_no_process" class="button save_order button-secondary"><span><?php esc_html_e( 'Save in WordPress', 'wp-openedx-commerce' ); ?></span></button>
<button name="save_no_process" class="button save_order button-secondary"><span><?php esc_html_e( 'Save in WordPress', 'openedx-commerce' ); ?></span></button>
</td>
</tr>
</tbody>
Expand Down
16 changes: 8 additions & 8 deletions includes/model/class-openedx-commerce-enrollment.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,57 +148,57 @@ public function register_status() {
register_post_status(
'success',
array(
'label' => __( 'success', 'wp-openedx-commerce' ),
'label' => __( 'success', 'openedx-commerce' ),
'public' => false,
'internal' => true,
'private' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
// translators: %s: number of items.
'label_count' => _n_noop( 'Success <span class="count">(%s)</span>', 'Success <span class="count">(%s)</span>', 'wp-openedx-commerce' ),
'label_count' => _n_noop( 'Success <span class="count">(%s)</span>', 'Success <span class="count">(%s)</span>', 'openedx-commerce' ),
)
);
register_post_status(
'no_process',
array(
'label' => __( 'success', 'wp-openedx-commerce' ),
'label' => __( 'success', 'openedx-commerce' ),
'public' => false,
'internal' => true,
'private' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
// translators: %s: number of items.
'label_count' => _n_noop( 'No process <span class="count">(%s)</span>', 'No process <span class="count">(%s)</span>', 'wp-openedx-commerce' ),
'label_count' => _n_noop( 'No process <span class="count">(%s)</span>', 'No process <span class="count">(%s)</span>', 'openedx-commerce' ),
)
);
register_post_status(
'pending',
array(
'label' => __( 'pending', 'wp-openedx-commerce' ),
'label' => __( 'pending', 'openedx-commerce' ),
'public' => false,
'internal' => true,
'private' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
// translators: %s: number of items.
'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'wp-openedx-commerce' ),
'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'openedx-commerce' ),
)
);
register_post_status(
'error',
array(
'label' => __( 'error', 'wp-openedx-commerce' ),
'label' => __( 'error', 'openedx-commerce' ),
'public' => false,
'internal' => true,
'private' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
// translators: %s: number of items.
'label_count' => _n_noop( 'Error <span class="count">(%s)</span>', 'Error <span class="count">(%s)</span>', 'wp-openedx-commerce' ),
'label_count' => _n_noop( 'Error <span class="count">(%s)</span>', 'Error <span class="count">(%s)</span>', 'openedx-commerce' ),
)
);
}
Expand Down
20 changes: 10 additions & 10 deletions includes/model/class-openedx-commerce-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,25 @@ public function register_post_type() {
'name' => $this->plural,
'singular_name' => $this->single,
'name_admin_bar' => $this->single,
'add_new' => _x( 'Add New', $this->post_type, 'wp-openedx-commerce' ), // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralContext
'add_new' => sprintf( _x( 'Add New', 'openedx-commerce', 'openedx-commerce' ), $this->post_type ),
// translators: %s: Name of the post type in singular.
'add_new_item' => sprintf( __( 'Add New %s', 'wp-openedx-commerce' ), $this->single ),
'add_new_item' => sprintf( __( 'Add New %s', 'openedx-commerce' ), $this->single ),
// translators: %s: Name of the post type in singular.
'edit_item' => sprintf( __( 'Edit %s', 'wp-openedx-commerce' ), $this->single ),
'edit_item' => sprintf( __( 'Edit %s', 'openedx-commerce' ), $this->single ),
// translators: %s: Name of the post type in singular.
'new_item' => sprintf( __( 'New %s', 'wp-openedx-commerce' ), $this->single ),
'new_item' => sprintf( __( 'New %s', 'openedx-commerce' ), $this->single ),
// translators: %s: Name of the post type in plural.
'all_items' => sprintf( __( 'All %s', 'wp-openedx-commerce' ), $this->plural ),
'all_items' => sprintf( __( 'All %s', 'openedx-commerce' ), $this->plural ),
// translators: %s: Name of the post type in singular.
'view_item' => sprintf( __( 'View %s', 'wp-openedx-commerce' ), $this->single ),
'view_item' => sprintf( __( 'View %s', 'openedx-commerce' ), $this->single ),
// translators: %s: Name of the post type in plural.
'search_items' => sprintf( __( 'Search %s', 'wp-openedx-commerce' ), $this->plural ),
'search_items' => sprintf( __( 'Search %s', 'openedx-commerce' ), $this->plural ),
// translators: %s: Name of the post type in plural.
'not_found' => sprintf( __( 'No %s Found', 'wp-openedx-commerce' ), $this->plural ),
'not_found' => sprintf( __( 'No %s Found', 'openedx-commerce' ), $this->plural ),
// translators: %s: Name of the post type in plural.
'not_found_in_trash' => sprintf( __( 'No %s Found In Trash', 'wp-openedx-commerce' ), $this->plural ),
'not_found_in_trash' => sprintf( __( 'No %s Found In Trash', 'openedx-commerce' ), $this->plural ),
// translators: %s: Name of the post type in singular.
'parent_item_colon' => sprintf( __( 'Parent %s' ), $this->single ),
'parent_item_colon' => sprintf( __( 'Parent %s', 'openedx-commerce' ), $this->single ),
'menu_name' => $this->plural,
);

Expand Down
10 changes: 10 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<exclude-pattern>./admin/index.php</exclude-pattern>
<exclude-pattern>./public/index.php</exclude-pattern>
<exclude-pattern>index.php</exclude-pattern>
<exclude-pattern>composer-setup.php</exclude-pattern>

<arg value="sp"/>
<arg name="basepath" value="./"/>
Expand All @@ -18,6 +19,15 @@
<rule ref="WordPress">
</rule>

<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="openedx-commerce"/>
<element value="woocommerce"/>
</property>
</properties>
</rule>

<rule ref="Generic.Files.LineEndings">
<properties>
<property name="eolChar" value="\n"/>
Expand Down
12 changes: 6 additions & 6 deletions utils/openedx-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
*/
function get_enrollment_options() {
return array(
'Honor' => __( 'Honor', 'wp-openedx-commerce' ),
'Audit' => __( 'Audit', 'wp-openedx-commerce' ),
'Verified' => __( 'Verified', 'wp-openedx-commerce' ),
'Credit' => __( 'Credit', 'wp-openedx-commerce' ),
'Professional' => __( 'Professional', 'wp-openedx-commerce' ),
'No ID Professional' => __( 'No ID Professional', 'wp-openedx-commerce' ),
'Honor' => __( 'Honor', 'openedx-commerce' ),
'Audit' => __( 'Audit', 'openedx-commerce' ),
'Verified' => __( 'Verified', 'openedx-commerce' ),
'Credit' => __( 'Credit', 'openedx-commerce' ),
'Professional' => __( 'Professional', 'openedx-commerce' ),
'No ID Professional' => __( 'No ID Professional', 'openedx-commerce' ),
);
}

0 comments on commit 8461178

Please sign in to comment.