Hardcoded language string not translatable

Closed
REHub - Price Comparison, Affiliate Marketing, Multi Vendor Store, Community Theme REHub - Price Comparison, Affiliate Marketing, Multi Vendor Store, Community Theme April 12, 2020
Login to reply
Igor Sunz Support Agent
4 years ago

__('Go to shop', 'rehub-theme') - this code is clearly visible as translation https://developer.wordpress.org/reference/functions/__/

Go to shop is available in translation file. Simply create and update localization file as described in documentation. In current point you didn't update localization

Dirk Meij
4 years ago

Hi Igor,

The topic i found did not do the trick unfortunately. So here are the steps:

I change the translation in the rehub-theme.pot file on line: 10933

#: taxonomy-dealstore.php:54 woocommerce/brandarchive.php:50

msgid "Go to shop"

msgstr "" 

To:

#: taxonomy-dealstore.php:54 woocommerce/brandarchive.php:50

msgid "Go to Brand"

msgstr ""


After reindexing the strings I am getting this message in WPML: go-to source in string translation.

The string looks directly to the source and not the pot file. So even after Ive changed ibn in the pot file WPML is reading it directly from the source:

<?php             

 

                    if($brandurl){

 

                        echo '<a class="blockstyle mt15 rehub_main_btn width-100p wpsm-button" data-cashbacknotice="'.$cashback_notice.'" href="'.esc_url($brandurl).'" target="_blank" rel="nofollow" data-url="'.esc_url($brandurl).'" data-merchant="'.$tagname.'"><i class="far fa-external-link"></i> '.__('Go to shop', 'rehub-theme').'</a>';

 

                    }

 

                    if($brandshortdesc){

 

                        echo '<div class="mt15 font80 lineheight20 text-left-align rtltext-right-align">'.wp_specialchars_decode( $brandshortdesc, ENT_QUOTES ).'</div>';

 

                    }

 

                ?>

After I have changed it in the source: wp-content/themes/rehub-theme/woocommerce/brandarchive.php

Only then its changed. 

Dirk Meij
4 years ago

Hi Igor,


Found the issue, Sorry.

Igor Sunz Support Agent
4 years ago

It's not hardcoded and it's available in POT file

https://share.getcloudapp.com/NQuDOOY7

Please, read our documentation how to update localization files http://rehubdocs.wpsoul.com/docs/rehub-theme/theme-install-update-translation/translation/

Dirk Meij
4 years ago

Hi amazing code wizards,


I am busy with some translations and came across the following:

Normally you can change the translation string in:

wp-content/themes/rehub-theme/lang/rehub-theme.pot

If we look closely at the following string:

wp-content/themes/rehub-theme/woocommerce/brandarchive.php

Line: 50 

<?php             

                    if($brandurl){

                        echo '<a class="blockstyle mt15 rehub_main_btn width-100p wpsm-button" data-cashbacknotice="'.$cashback_notice.'" href="'.esc_url($brandurl).'" target="_blank" rel="nofollow" data-url="'.esc_url($brandurl).'" data-merchant="'.$tagname.'"><i class="far fa-external-link"></i> '.__('Go to shop', 'rehub-theme').'</a>';

                    }

                    if($brandshortdesc){

                        echo '<div class="mt15 font80 lineheight20 text-left-align rtltext-right-align">'.wp_specialchars_decode( $brandshortdesc, ENT_QUOTES ).'</div>';

                    }

                ?>


The 'Go to shop', is hardcoded and not visible via any po/mo/pot file. This means you cant properly translate it. You can change it in the file itself but with every update, it's referred back to initial wording.


Is there a possibility you add this to the pot file instead of hardcoding it?


You guys rock!


//Mistermeij