Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second issue #2476

Closed
wants to merge 12 commits into from
Closed

Conversation

CptHappyHands
Copy link
Contributor

for troubleshooting


<tr class="language-row" data-lang="<?php echo esc_html( $language_key ) ?>">
<td class='lang_key'><?php echo esc_html( $language_key ) ?></td>
<td class='default_label'><?php echo esc_html( isset( $dt_global_languages_list[$language_key] ) ? $dt_global_languages_list[$language_key]['label'] : '' ) ?></td>
<td class='custom_label'><input type="text" placeholder="Custom Label" name="language_label[<?php echo esc_html( $language_key ) ?>][default]" value="<?php echo esc_html( ( !isset( $dt_global_languages_list[$language_key] ) || ( isset( $dt_global_languages_list[$language_key] ) && $dt_global_languages_list[$language_key]['label'] != $language_option['label'] ) ) ? $language_option['label'] : '' ) ?>"></td>
<td class='iso_code'><input type="text" placeholder="ISO 639-3 code" maxlength="3" name="language_code[<?php echo esc_html( $language_key ) ?>]" value="<?php echo esc_html( $language_option['iso_639-3'] ?? '' ) ?>"></td>
<td class='custom_label'><input type="text" placeholder="Custom Label" name="language_label[<?php echo esc_html( $language_key ) ?>][default]" value="<?php echo esc_html( $language_option['label'] ?? '' )?>"></td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CptHappyHands keep the "custom" label blank if the admin has not saved a custom label yet. This should not be filled with the default label.

<td class='custom_label'><input type="text" placeholder="Custom Label" name="language_label[<?php echo esc_html( $language_key ) ?>][default]" value="<?php echo esc_html( ( !isset( $dt_global_languages_list[$language_key] ) || ( isset( $dt_global_languages_list[$language_key] ) && $dt_global_languages_list[$language_key]['label'] != $language_option['label'] ) ) ? $language_option['label'] : '' ) ?>"></td>
<td class='iso_code'><input type="text" placeholder="ISO 639-3 code" maxlength="3" name="language_code[<?php echo esc_html( $language_key ) ?>]" value="<?php echo esc_html( $language_option['iso_639-3'] ?? '' ) ?>"></td>
<td class='custom_label'><input type="text" placeholder="Custom Label" name="language_label[<?php echo esc_html( $language_key ) ?>][default]" value="<?php echo esc_html( $language_option['label'] ?? '' )?>"></td>
<td class='iso_code'><input type="text" placeholder="ISO 639-3 code" maxlength="3" name="language_code[<?php echo esc_html( $language_key ) ?>]" value="<?php echo esc_html( $language_option['flag'] ?? '' ) ?>"></td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was iso_639-3 replaced with 'flag' here on accident?

native_name: '',
flag: '',
rtl: false,
enabled: '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we only want to save custom_label, iso_639-3 and enabled.
The rest should be removed

},
success: function (response) {
var languages = JSON.parse(response);
console.log(languages, 'success line 40');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @CptHappyHands !

You can do window.location.reload() on the success for now.
Some in the other ajax

/**
* @todo:
* only save user provided customizations to the dt_working_languages options
* this includes labels, the iso code, the enabled status and translations
* does not include: the key, default labels etc
*/

recursive_array_update( $saved_language_options, $params );
update_option( 'dt_working_languages', $saved_language_options, false );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CptHappyHands
Here we only want to save the custom values the admin has entered. Not any that are default.

So if the admin sets english to enabled:
We'd do saved_language_options[en_US]['enabled'] = true

I expect a lot of the code from process_languages_box() would be copied here.

@corsacca
Copy link
Member

Closing this one in favor of: #2500

@corsacca corsacca closed this May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants