Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript script to change custom field value

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #173931
    ntarantino
    Participant

    Self starter here and I have run into a wall.

    Is it possible to have a script take a custom field value (in WordPress) and on the front-end, check browser language, then display the correct text?

    For instance, on a post I have a CF field called language, in which can be populated with something like En,Fr,Nl.

    When you would view this post live, it would say currently, Speaks: En, FR, Nl still when I want it to check that it´s English, then display Speaks: English, French, Dutch.

    Thanks ! Always learning!

    #174139
    clokey2k
    Participant

    I have had to read your original question a few times.

    I think you are asking if it is possible, based on browser language, to display different language labels. So an English speaker would see: English, French, Dutch; A French speaker: Anglais, Français, Néerlandais;

    JavaScript has the window.navigator.language property to identify browser language (i.e. "en-GB"). Then you could use this to display the localised version of the Languages. I don’t know the best way to index these for retrieval.

    Maybe there is a localisation plugin that could help you in this case?

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.