Announcement

Collapse
No announcement yet.

Detecting current Language

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ron Frigon
    replied
    William Davis Sure, I'll report back in a bit. Give me a nudge if I forget...

    We're using the paid version of GTranslate, the sub-directory version. The Sub-domain version was too problematic. This does not work well with Miva out of the box but hopefully they have it figured out now. For example cart contents would get cached causing all kinds of problems. Disable cache when an item is added to cart...

    GTranslate does have some basic analytics. You'll need to create some custom events, etc., for GA4 based on language selection which will require some js foo.

    GTranslate does update canonical urls and also updates the html lang="en" based on language selected. You also have the ability to edit on site translations directly from your web browser which is pretty slick.

    So far, as far as SEO is concerned, it seems to have increased our visibility for the alternate language. I haven't seen any negative issues. We have our setup limited to English/Spanish only.

    Leave a comment:


  • William Davis
    replied
    Originally posted by Ron Frigon View Post
    Thank you for the help guys. All makes sense.
    Ron Frigon, we've been contemplating implementing such a solution. Could you please report back a few months from now and let us know how it worked out for you?

    Also, is there any analytics involved to determine which traffic is seeing what and order placed?

    Leave a comment:


  • Ron Frigon
    replied
    Thank you for the help guys. All makes sense.

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    Originally posted by Kent Multer View Post
    It looks to me like a timing problem.
    Template code runs in the server, before the page is sent to the browser. Javascript runs in the browser, after the template has been completely rendered. So you can't use an mvt:if to check the value of a variable that won't have a value until after the template has been rendered.
    Exactly. If you can't do what you need via JS (which you might), then check if:

    &mvt:system:http_accept_language; or &mvt:system:miva_language; is coming from the customer's browser or an internal variable miva uses. (don't know--never used).

    Leave a comment:


  • Kent Multer
    replied
    It looks to me like a timing problem.
    Template code runs in the server, before the page is sent to the browser. Javascript runs in the browser, after the template has been completely rendered. So you can't use an mvt:if to check the value of a variable that won't have a value until after the template has been rendered.

    Leave a comment:


  • Ron Frigon
    started a topic Detecting current Language

    Detecting current Language

    We recently added a translate widget to our site. I'm trying to switch some content based on the current language selected.

    I was provided with this script sample.

    Code:
    var current_lang = document.getElementsByTagName('html')[0].getAttribute('lang');
    This should get me the current language. Now I want to do something like:

    Code:
    <mvt:if expr="'es' IN g.current_lang">
    // do this
    <mvt:else>
    // do something else
    </mvt:if>
    I'm just spinning my wheels. Seems like it should be simple...
Working...
X