• Resolved jlstysis

    (@jlstysis)


    Hello,

    My entire site is in a foreign language, which also makes the billing and shipping address field labels and even US state names in that language. However, all of my customers are based in the US, so addresses will need to be entered in English and I’d like to display address filed labels and US state names in English.

    The following code works very well, but it forces the entire checkout and my account page into English, which is not ideal since the rest of the site is in another language. I’d like to only force the address filed labels and state names to English.

    // change checkout page to English
    add_filter('locale', function($locale) {
        if (strpos($_SERVER['REQUEST_URI'], "checkout") !== false)
          return 'en_EN';
        return $locale;
    });
    
    // change my-account page to English
    add_filter('locale', function($locale) {
        if (strpos($_SERVER['REQUEST_URI'], "my-account") !== false)
          return 'en_EN';
        return $locale;
    });
    
    • This topic was modified 2 years, 7 months ago by jlstysis.
    • This topic was modified 2 years, 7 months ago by jlstysis.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @jlstysis,

    What if you use “Checkout field editor” to manually change them?

    Cheers,
    Naz.

    Plugin Support Paulo P – a11n

    (@paulostp)

    Hello @jlstysis,

    Thanks for reaching out!

    If I understood correctly, you would like to have the checkout billing/shipping labels and US state names in English, while the rest of the elements at checkout (and elsewhere on the site) remain in another language.

    You could use Loco Translate for that. You would edit the translation file and change the strings you need to show in English.

    Hope this helps!

    Thread Starter jlstysis

    (@jlstysis)

    Thank you for your replies.

    “Checkout field editor” works on the checkout page (as designed), but it does not affect address fields on the My Account page (still working as designed).

    Loco Translate seems like the path to go. I was just hoping to find a way to set locale for the address section of the page to have WordPress display it in English automatically rather than having to go into Loco and manually rename every state into English as well as the address field labels.

    But I guess Loco it is.
    Thanks again!

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    Glad to know that Loco Translate might work for you. Since the thread is now closed, feel free to create a new topic if you need assistance with anything else.

    All the best.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Force address fields to English’ is closed to new replies.