I'm using wordpress. I have query string functionally that displays the content in the correct language.
Example urls
example.com/terms/?lang=en
example.com/terms/?lang=es
example.com/terms/?lang=fr
example.com/terms/?lang=db
The code below grabs the query string value[lang code] and the API uses it to show the correct language.
<script type="text/javascript" charset="UTF-8">
var langCodeSearch = new URLSearchParams(window.location.search);
var langCode = Object.fromEntries(langCodeSearch.entries());
Api.Initialized.then(function() {
Api.LoadContent(["https://url-to-api-that-has-content.json"], langCode.lang //**language declaration need to happen here**);
});
</script>
The above code works great but would it be possible to have the same functionally but using the following URL structure?
example.com/terms/en
example.com/terms/es
example.com/terms/fr
example.com/terms/gb
I want to display content based on the last part of the URLs.