Skip to content

Commit

Permalink
Merge pull request #104 from pedro-mendonca/master
Browse files Browse the repository at this point in the history
Fix missing i18n
  • Loading branch information
imnavanath authored Jul 16, 2024
2 parents 41992a3 + 6fc90a2 commit b966233
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ const EditGFontVariation = (
}
) => {

const [removeTitle, setRemoveTitle] = useState("Remove");
const [addTitle, setAddTitle] = useState("Add");
const [removeTitle, setRemoveTitle] = useState( __( 'Remove', 'custom-fonts' ) );
const [addTitle, setAddTitle] = useState( __( 'Add', 'custom-fonts' ) );

useEffect(() => {
if (!disable) {
setRemoveTitle("Remove");
setAddTitle("Add");
setRemoveTitle( __( 'Remove', 'custom-fonts' ) );
setAddTitle( __( 'Add', 'custom-fonts' ) );
}
}, [disable]);

Expand Down Expand Up @@ -129,9 +129,9 @@ const EditGFontVariation = (
: "flex items-center components-button is-secondary"
}
data-font_weight={weight}
onClick={(e) => { setRemoveTitle("Adding..."); addWeight(e) }}
onClick={(e) => { setRemoveTitle( __( 'Adding...', 'custom-fonts' ) ); addWeight(e) }}
>
{addTitle === "Removing..." ? (Custom_Fonts_Icons['loadingSpinner3']) : (
{addTitle === __( 'Removing...', 'custom-fonts' ) ? (Custom_Fonts_Icons['loadingSpinner3']) : (
<span data-font_weight={weight}>
{Custom_Fonts_Icons['iconsquare']}
</span>
Expand All @@ -146,7 +146,7 @@ const EditGFontVariation = (
disabled={disable}
style={
disable
? removeTitle === "Adding..."
? removeTitle === __( 'Adding...', 'custom-fonts' )
? {
color: "#3858E9",
borderColor: "#3858E9",
Expand All @@ -160,14 +160,14 @@ const EditGFontVariation = (
: { boxShadow: "inset 0 0 0 1px" }
}
className={
removeTitle === "Adding..."
removeTitle === __( 'Adding...', 'custom-fonts' )
? "flex items-center components-button is-secondary"
: "flex text-danger items-center components-button is-secondary border border-danger"
}
data-font_weight={weight}
onClick={(e) => { setAddTitle("Removing..."); removeWeight(e) }}
onClick={(e) => { setAddTitle( __( 'Removing...', 'custom-fonts' ) ); removeWeight(e) }}
>
{removeTitle === "Adding..." ? (Custom_Fonts_Icons['loadingSpinner3']) : (
{removeTitle === __( 'Adding...', 'custom-fonts' ) ? (Custom_Fonts_Icons['loadingSpinner3']) : (
<span data-font_weight={weight}>
{Custom_Fonts_Icons['iconsquare2']}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const GFontVariation = (props) => {
const { weight, font, isInGoogleState, disable } = props;
const googleFont = useSelector( ( state ) => state.googleFont );
const dispatch = useDispatch();
const [removeTitle, setRemoveTitle] = useState("Remove");
const [addTitle, setAddTitle] = useState("Add");
const [removeTitle, setRemoveTitle] = useState( __( 'Remove', 'custom-fonts' ) );
const [addTitle, setAddTitle] = useState( __( 'Add', 'custom-fonts' ) );

useEffect(() => {
if (!disable) {
setRemoveTitle("Remove");
setAddTitle("Add");
setRemoveTitle( __( 'Remove', 'custom-fonts' ) );
setAddTitle( __( 'Add', 'custom-fonts' ) );
}
}, [disable]);

Expand Down Expand Up @@ -65,7 +65,7 @@ const GFontVariation = (props) => {
const addWeight = (e) => {
e.preventDefault();
e.stopPropagation();
setRemoveTitle("Adding...");
setRemoveTitle( __( 'Adding...', 'custom-fonts' ) );

const varWt = e.target.dataset.font_weight;
const variations = googleFont.variations;
Expand Down Expand Up @@ -94,7 +94,7 @@ const GFontVariation = (props) => {
const removeWeight = (e) => {
e.preventDefault();
e.stopPropagation();
setAddTitle("Removing...");
setAddTitle( __( 'Removing...', 'custom-fonts' ) );

const updatedVariations = googleFont.variations.filter(
(variation) => variation.font_weight !== weight
Expand Down Expand Up @@ -153,7 +153,7 @@ const GFontVariation = (props) => {
disabled={disable}
style={
disable
? addTitle === "Removing..."
? addTitle === __( 'Removing...', 'custom-fonts' )
? {
color: "#3858E9", // by removing time
borderColor: "#3858E9",
Expand All @@ -167,14 +167,14 @@ const GFontVariation = (props) => {
: { boxShadow: "inset 0 0 0 1px" }
}
className={
addTitle === "Removing..."
addTitle === __( 'Removing...', 'custom-fonts' )
? "flex text-danger items-center components-button is-secondary border border-danger"
: "flex items-center components-button is-secondary"
}
data-font_weight={weight}
onClick={addWeight}
>
{addTitle === "Removing..." ? (Custom_Fonts_Icons['loadingSpinner3']) : (
{addTitle === __( 'Removing...', 'custom-fonts' ) ? (Custom_Fonts_Icons['loadingSpinner3']) : (
<span data-font_weight={weight}>
{Custom_Fonts_Icons['iconsquare']}
</span>
Expand All @@ -189,7 +189,7 @@ const GFontVariation = (props) => {
disabled={disable}
style={
disable
? removeTitle === "Adding..."
? removeTitle === __( 'Adding...', 'custom-fonts' )
? {
color: "#3858E9",
borderColor: "#3858E9", // Updated border color
Expand All @@ -203,14 +203,14 @@ const GFontVariation = (props) => {
: { boxShadow: "inset 0 0 0 1px" }
}
className={
removeTitle === "Adding..."
removeTitle === __( 'Adding...', 'custom-fonts' )
? "flex items-center components-button is-secondary"
: "flex text-danger items-center components-button is-secondary border border-danger"
}
data-font_weight={weight}
onClick={removeWeight}
>
{removeTitle === "Adding..." ? (Custom_Fonts_Icons['loadingSpinner3']) : (
{removeTitle === __( 'Adding...', 'custom-fonts' ) ? (Custom_Fonts_Icons['loadingSpinner3']) : (
<span data-font_weight={weight}>
{Custom_Fonts_Icons['iconsquare2']}
</span>
Expand Down
101 changes: 52 additions & 49 deletions includes/class-bsf-custom-fonts-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,37 +101,38 @@ public function add_new_taxonomy_data() {
$this->add_new_taxonomy_default_data();
?>
<input type="hidden" name="repeater-field-count" value="1">
<?php
echo '
<div id="repeater">
<!-- Repeater Heading -->
<!-- Repeater Heading -->

<div class="clearfix"></div>
<!-- Repeater Items -->
<div id="item-0" class="cf-bsf-items" data-group="font-weight-type">
<!-- Repeater Content -->
<div class="item-content">
<div class="clearfix"></div>
<!-- Repeater Items -->
<div id="item-0" class="cf-bsf-items" data-group="font-weight-type">
<!-- Repeater Content -->
<div class="item-content">
<div class="form-group">
<div class="weight-wrapper">';
$this->add_new_taxonomy_repeater_data();
wp_nonce_field( basename( __FILE__ ), 'bsf_custom_font_nonce' );
echo '</div>
</div>
</div>
<!-- Repeater Remove Btn -->
<div class="repeater-remove-btn">
<div class="button button-primary disabled remove-btn">
Remove
<div class="weight-wrapper">
<?php
$this->add_new_taxonomy_repeater_data();
wp_nonce_field( basename( __FILE__ ), 'bsf_custom_font_nonce' );
?>
</div>
</div>
</div>
<!-- Repeater Remove Btn -->
<div class="repeater-remove-btn">
<div class="button button-primary disabled remove-btn">
<?php esc_html_e( 'Remove', 'custom-fonts' ); ?>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
<div class="cf-addbutton-wrapper">
<div class="button button-primary repeater-add-btn">
Add Font Variation
<?php esc_html_e( 'Add Font Variation', 'custom-fonts' ); ?>
</div>
</div>';
</div>
<?php
}

/**
Expand Down Expand Up @@ -197,24 +198,26 @@ public function edit_new_taxonomy_data( $term ) {
$this->edit_new_taxonomy_default_data( $term );
?>
<tr>
<th></th>
<td>
<div id="repeater">
<!-- Repeater Heading -->
<div class="clearfix"></div>
<!-- Repeater Items -->
<?php foreach ( $data as $key => $value ) { ?>
<?php $this->edit_taxonomy_repeater_data( $key, $value ); ?>
<?php } ?>
<input type="hidden" name="repeater-field-count" value="<?php echo esc_attr( self::$edit_repeater_field_count ); ?>">
<?php wp_nonce_field( basename( __FILE__ ), 'bsf_custom_font_nonce' ); ?>
</div>
<div class="cf-addbutton-wrapper">
<div class="button button-primary edit-repeater-add-btn">
Add Font Variation
<th></th>
<td>
<div id="repeater">
<!-- Repeater Heading -->
<div class="clearfix"></div>
<!-- Repeater Items -->
<?php
foreach ( $data as $key => $value ) {
$this->edit_taxonomy_repeater_data( $key, $value );
}
?>
<input type="hidden" name="repeater-field-count" value="<?php echo esc_attr( self::$edit_repeater_field_count ); ?>">
<?php wp_nonce_field( basename( __FILE__ ), 'bsf_custom_font_nonce' ); ?>
</div>
</div>
</td>
<div class="cf-addbutton-wrapper">
<div class="button button-primary edit-repeater-add-btn">
<?php esc_html_e( 'Add Font Variation', 'custom-fonts' ); ?>
</div>
</div>
</td>
</tr>
<?php

Expand Down Expand Up @@ -299,7 +302,7 @@ public function edit_taxonomy_repeater_data( $key, $value ) {
<!-- Repeater Remove Btn -->
<div class="repeater-remove-btn">
<div class="button button-primary remove-btn <?php echo esc_attr( 1 < self::$edit_repeater_field_count ? '' : 'disabled' ); ?>">
Remove
<?php esc_html_e( 'Remove', 'custom-fonts' ); ?>
</div>
</div>
<div class="clearfix"></div>
Expand Down Expand Up @@ -447,13 +450,13 @@ private function select_edit_field( $id, $title, $description, $select_fields, $
</label>
</th>
<td>
<select type="select" id="font-<?php echo esc_attr( $id ); ?>" class="bsf-custom-font-select-field <?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug ); ?>[<?php echo esc_attr( $id ); ?>]" />
<?php
foreach ( $select_fields as $key => $value ) {
?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $saved_val ); ?>><?php echo esc_html( $value ); ?></option>;
<?php } ?>
</select>
<select type="select" id="font-<?php echo esc_attr( $id ); ?>" class="bsf-custom-font-select-field <?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug ); ?>[<?php echo esc_attr( $id ); ?>]" />
<?php
foreach ( $select_fields as $key => $value ) {
?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $saved_val ); ?>><?php echo esc_html( $value ); ?></option>;
<?php } ?>
</select>
<p><?php echo esc_html( $description ); ?></p>
</td>
</tr>
Expand Down

0 comments on commit b966233

Please sign in to comment.