Skip to content

Commit

Permalink
Merge pull request #4274 from Codeinwp/fix/js-translations
Browse files Browse the repository at this point in the history
[WIP] Translations adjustments
  • Loading branch information
abaicus authored Jul 29, 2024
2 parents 519535f + 5b94516 commit ee3b572
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/diff-translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
uses: actions/checkout@v2
with:
path: neve-head
- name: Setup node 16
- name: Setup node 18
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 18.x
- name: FRESH Makepot BASE
run: |
cd neve-head
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function() {
'is_enabled' => ! defined( 'NEVE_PRO_VERSION' ),
'pro_name' => 'Neve Pro Addon',
'logo' => get_template_directory_uri() . '/assets/img/dashboard/logo.svg',
'cta_link' => tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/?discount=LOYALUSER582&dvalue=50', 'neve-welcome', 'notice' ),
'cta_link' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/?discount=LOYALUSER582&dvalue=50', 'neve-welcome', 'notice' ), 'query' ),

Check failure on line 162 in functions.php

View workflow job for this annotation

GitHub Actions / PHPStan

Function tsdk_translate_link not found.
];
}
);
Expand Down
4 changes: 2 additions & 2 deletions header-footer-grid/Core/Builder/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function init() {
'footer_copyright_content' => array(
'label' => esc_html__( 'Change Copyright', 'neve' ),
'icon' => 'dashicons-nametag',
'url' => $this->has_valid_addons() ? null : tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'copyright' ),
'url' => $this->has_valid_addons() ? null : tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'copyright' ), 'query' ),

Check failure on line 70 in header-footer-grid/Core/Builder/Footer.php

View workflow job for this annotation

GitHub Actions / PHPStan

Function tsdk_translate_link not found.
),
'hfg_footer_layout_bottom_background' => array(
'label' => esc_html__( 'Change Footer Color', 'neve' ),
Expand Down Expand Up @@ -156,7 +156,7 @@ public function add_footer_component( $builder, $row, $slot ) {
$output .= sprintf(
/* translators: %1$s is Theme Name ( Neve ), %2$s is WordPress */
esc_html__( '%1$s | Powered by %2$s', 'neve' ),
wp_kses_post( '<p><a href="https://themeisle.com/themes/neve/" rel="nofollow">Neve</a>' ),
wp_kses_post( '<p><a href="' . tsdk_translate_link( 'https://themeisle.com/themes/neve/', 'path' ) . '" rel="nofollow">Neve</a>' ),

Check failure on line 159 in header-footer-grid/Core/Builder/Footer.php

View workflow job for this annotation

GitHub Actions / PHPStan

Function tsdk_translate_link not found.
wp_kses_post( '<a href="https://wordpress.org" rel="nofollow">WordPress</a></p>' )
);
$output .= '</div></div></div></div>';
Expand Down
16 changes: 8 additions & 8 deletions inc/admin/dashboard/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function () use ( $filtered_name ) {
// Add predefined product pages to the about page.
'product_pages' => [ 'otter-page' ],
// Upgrade menu item link & text
'upgrade_link' => tsdk_utmify( esc_url( 'https://themeisle.com/themes/neve/upgrade/' ), 'aboutfilter', 'nevedashboard' ),
'upgrade_link' => tsdk_translate_link( tsdk_utmify( esc_url( 'https://themeisle.com/themes/neve/upgrade/' ), 'aboutfilter', 'nevedashboard' ), 'query' ),

Check failure on line 127 in inc/admin/dashboard/main.php

View workflow job for this annotation

GitHub Actions / PHPStan

Function tsdk_translate_link not found.
'upgrade_text' => __( 'Upgrade', 'neve' ) . ' ' . $filtered_name,
];
}
Expand Down Expand Up @@ -299,7 +299,7 @@ public function enqueue() {

$build_path = get_template_directory_uri() . '/assets/apps/dashboard/build/';
$dependencies = ( include get_template_directory() . '/assets/apps/dashboard/build/dashboard.asset.php' );

wp_register_style( 'neve-dash-style', $build_path . 'style-dashboard.css', [ 'wp-components', 'neve-components' ], $dependencies['version'] );
wp_style_add_data( 'neve-dash-style', 'rtl', 'replace' );
wp_enqueue_style( 'neve-dash-style' );
Expand Down Expand Up @@ -339,10 +339,10 @@ private function get_localization() {
'plugins' => $this->get_useful_plugins(),
'featureData' => $this->get_free_pro_features(),
'showFeedbackNotice' => $this->should_show_feedback_notice(),
'allfeaturesNeveProURL' => tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'seeallfeatures', 'freevspropage' ),
'startSitesgetNeveProURL' => tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'welcomestartersitescard', 'nevedashboard' ),
'customLayoutsNeveProURL' => tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'customlayoutscard', 'nevedashboard' ),
'upgradeURL' => apply_filters( 'neve_upgrade_link_from_child_theme_filter', tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'getpronow', 'freevspropage' ) ),
'allfeaturesNeveProURL' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'seeallfeatures', 'freevspropage' ), 'query' ),

Check failure on line 342 in inc/admin/dashboard/main.php

View workflow job for this annotation

GitHub Actions / PHPStan

Function tsdk_translate_link not found.
'startSitesgetNeveProURL' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'welcomestartersitescard', 'nevedashboard' ), 'query' ),

Check failure on line 343 in inc/admin/dashboard/main.php

View workflow job for this annotation

GitHub Actions / PHPStan

Function tsdk_translate_link not found.
'customLayoutsNeveProURL' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'customlayoutscard', 'nevedashboard' ), 'query' ),

Check failure on line 344 in inc/admin/dashboard/main.php

View workflow job for this annotation

GitHub Actions / PHPStan

Function tsdk_translate_link not found.
'upgradeURL' => apply_filters( 'neve_upgrade_link_from_child_theme_filter', tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'getpronow', 'freevspropage' ), 'query' ) ),

Check failure on line 345 in inc/admin/dashboard/main.php

View workflow job for this annotation

GitHub Actions / PHPStan

Function tsdk_translate_link not found.
'supportURL' => esc_url( 'https://wordpress.org/support/theme/neve/' ),
'docsURL' => esc_url( 'https://docs.themeisle.com/article/946-neve-doc' ),
'codexURL' => esc_url( 'https://codex.nevewp.com/' ),
Expand Down Expand Up @@ -371,7 +371,7 @@ private function get_localization() {
'licenseCardDescription' => sprintf(
// translators: store name (Themeisle)
__( 'Enter your license from %1$s purchase history in order to get plugin updates', 'neve' ),
'<a target="_blank" rel="external noreferrer noopener" href="https://store.themeisle.com/">ThemeIsle<span class="components-visually-hidden">' . esc_html__( '(opens in a new tab)', 'neve' ) . '</span><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" class="components-external-link__icon" role="img" aria-hidden="true" focusable="false" style="fill: #0073AA"><path d="M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"></path></svg></a>'
'<a target="_blank" rel="external noreferrer noopener" href="' . tsdk_translate_link( 'https://store.themeisle.com/', 'query' ) . '">ThemeIsle<span class="components-visually-hidden">' . esc_html__( '(opens in a new tab)', 'neve' ) . '</span><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" class="components-external-link__icon" role="img" aria-hidden="true" focusable="false" style="fill: #0073AA"><path d="M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"></path></svg></a>'

Check failure on line 374 in inc/admin/dashboard/main.php

View workflow job for this annotation

GitHub Actions / PHPStan

Function tsdk_translate_link not found.
),
],
'changelog' => $this->cl_handler->get_changelog( get_template_directory() . '/CHANGELOG.md' ),
Expand Down Expand Up @@ -470,7 +470,7 @@ public function get_notifications() {
__( 'From 3.3.0 we decided to remove the copyright component from the free version. You can continue using it if you rollback to 3.2.x or you can upgrade to pro, using a one time 50%% discount: %s', 'neve' ),
wp_kses_post( '<code>NEVEBRANDING50</code>' )
),
'url' => tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'copyrightnotice', 'nevedashboard' ),
'url' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'copyrightnotice', 'nevedashboard' ), 'query' ),

Check failure on line 473 in inc/admin/dashboard/main.php

View workflow job for this annotation

GitHub Actions / PHPStan

Function tsdk_translate_link not found.
'targetBlank' => true,
'cta' => __( 'Upgrade', 'neve' ),
];
Expand Down
2 changes: 1 addition & 1 deletion inc/admin/hooks_upsells.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function () use ( $hook_value, $hook_label, $upsell_label ) {
if ( 'woocommerce_before_shop_loop_item' === $hook_value ) {
$style = 'max-width: 200px;';
}
$upsell_url = tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'viewhooks' );
$upsell_url = tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'viewhooks' ), 'query' );
echo '<div class="nv-hook-wrapper nv-hook-upsell-wrapper">';
echo '<div class="nv-hook-placeholder">';
echo '<a href="' . esc_url( $upsell_url ) . '" title="' . esc_attr( $upsell_label ) . '" target="_blank">';
Expand Down
1 change: 1 addition & 0 deletions inc/core/core_loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function () {
add_action( 'wp_enqueue_scripts', array( $front_end, 'enqueue_scripts' ) );
add_action( 'after_setup_theme', array( $front_end, 'setup_theme' ) );
add_action( 'widgets_init', array( $front_end, 'register_sidebars' ) );
add_filter( 'load_script_translation_file', array( $front_end, 'fix_script_translation_files' ), 10, 3 );
}

/**
Expand Down
25 changes: 25 additions & 0 deletions inc/core/front_end.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,4 +573,29 @@ public function css_global_custom_colors( $current_styles, $context ) {

return $current_styles;
}

/**
* Fix script translations language directory.
*
* @param string | false $file File path.
* @param string $handle Script handle.
* @param string $domain Script text domain.
*
* @return string | false
*/
public function fix_script_translation_files( $file, $handle, $domain ) {
if ( ! $file || $domain !== 'neve' ) {
return $file;
}

if ( is_file( $file ) ) {
return $file;
}

if ( strpos( $file, WP_LANG_DIR . '/plugins' ) !== false ) {
$file = str_replace( WP_LANG_DIR . '/plugins', WP_LANG_DIR . '/themes', $file );
}

return $file;
}
}
6 changes: 3 additions & 3 deletions inc/customizer/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function enqueue_customizer_controls() {
'controls' => array(),
'options' => array(),
),
'upsellComponentsLink' => tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'hfgcomponents' ),
'upsellComponentsLink' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'hfgcomponents' ), 'query' ),
'fonts' => array(
'System' => neve_get_standard_fonts(),
'Google' => neve_get_google_fonts(),
Expand Down Expand Up @@ -168,11 +168,11 @@ public function enqueue_customizer_controls() {

if ( isset( $dependencies['chunks'] ) ) {
foreach ( $dependencies['chunks'] as $chunk_file ) {

$chunk_handle = 'neve-customizer-chunk-' . $chunk_file;
wp_register_script( $chunk_handle, $bundle_path . $chunk_file, [], $dependencies['version'], true );
wp_enqueue_script( $chunk_handle );

if ( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations( $chunk_handle, 'neve' );
}
Expand Down
Loading

0 comments on commit ee3b572

Please sign in to comment.