New Landing How can we help? Atelier "Postcode/ZIP" is translated to Danish then revert back to English

Viewing 15 posts - 1 through 15 (of 15 total)
  • Posted in: Atelier
  • #244623
    reddion
    Member
    Post count: 52

    Hi, I would appreciate it a lot if you could check the checkout page of my website. Just try to buy something then go view the cart.

    I’m using Danish for the language, so the field “Postcode/ZIP” should be translated as “Postnummer” or “Postnr.” However only that field stays in English. The weird thing is, when you refresh the page, for a brief moment you can see it translated to “Postnr.” but then when the page is loaded completely, it changes back to “Postcode/ZIP”. Can you tell me why is that??

    The language file I modified is “woocommerce-da_DK.po” and I have compiled it to .mo file as well using poedit. Then I put those files in /languages/plugins/. There are no fuzzy translation. I’ll be waiting for your help again. Thank you very very much!!!

    Regards,
    Fred

    #244701
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please paste this code at functions.php file:-

    function sf_text_strings( $translated_text, $text, $domain ) {
    	switch ( $translated_text ) {
    		case 'Postcode / Zip' :
    			$translated_text = __( 'Postnummer', $domain );
    			break;
    	}
    	return $translated_text;
    }
    add_filter( 'gettext', 'sf_text_strings', 20, 3 );

    Thanks
    Mohammad

    #244702
    reddion
    Member
    Post count: 52

    Hi Mohammad,

    Thanks for the code, but I need to say this. The website will use WPML in the future, add Norwegian and Swedish. If I use this code, will it fix this issue in the future when I switch the language? Thanks again.

    – Fred

    #244719
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    If you use WPML then you ned to remove this code.
    Thanks
    Mohammad

    #245006
    reddion
    Member
    Post count: 52

    Hmm, I see. Alright then I will call you again when I have installed the WPML and deal with the issues later. Thanks, Mohammad.

    – Fred

    #245013
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    We are always ready to provide best help & support.
    Thanks
    Mohammad

    #245014
    reddion
    Member
    Post count: 52

    By the way, Mohammad. That code you gave me is not working. Can you please give me another solution? Thanks.

    – Fred

    #245317
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    I have managed to resolve the issue so please check it now.
    Thanks
    Mohammad

    #245828
    reddion
    Member
    Post count: 52

    Hi Mohammad,

    You’re right! The issue is resolved now, thank you so much!!! What did you do, if I may know? Please explain it to me so I understand and hopefully won’t bother you with this same problem in the future 🙂 Thanks!

    – Fred

    #245886
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    I just changed Postcode / Zip to Postcode / ZIP in my code to resolve the issue.
    Thanks
    Mohammad

    #246178
    reddion
    Member
    Post count: 52

    Ah, thank you very much for the answer. I will consider it resolved for now. Please assist me again if another problem occurred in the future when I have installed WPML plugin. Thank you in advance, Mohammad.

    – Fred

    #246362
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Dont worry. We are always ready to provide you best help and support.
    Thanks
    Mohammad

    #250556
    reddion
    Member
    Post count: 52

    Hi Mohammad,

    I have installed the WPML plugin now and remove your code. The problem is back, can you help me again?

    The strange thing is, it’s only for the Danish version of the website. If you switch to Swedish then it’s fine. I have made sure that the translation in the file “woocommerce-da_DK.po” is correct, but it’s still not working. I hope you can help me solve this issue. Thanks!

    – Fred

    #250565
    reddion
    Member
    Post count: 52

    Hi Mohammad,

    Nevermind, I have figured it out by myself. The problem is, the original string in “woocommerce-da_DK.po” is “Postcode / Zip”, while in the Atelier theme, the string of ZIP is all uppercase “Postcode / ZIP”. Therefore the translation will never going to work. I have edited the original string and everything works perfect now. I will mark this thread resolved. Thanks!!

    – Fred

    #250566
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please use this code at functions.php of child theme.

    function sf_text_strings( $translated_text, $text, $domain ) {
    	if (($translated_text == 'Postcode / ZIP') && (ICL_LANGUAGE_CODE=='sv')) {
    		
    			$translated_text = __( 'Swedish', $domain ); // please change it
    			
    	}elseif(($translated_text == 'Postcode / ZIP') && (ICL_LANGUAGE_CODE=='da')){
          
           $translated_text = __( 'Postnummer', $domain );
           }
    	return $translated_text;
    }
    add_filter( 'gettext', 'sf_text_strings', 20, 3 );

    Thanks
    Mohammad

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register