Basic Examples (5)
Basic Examples
(5)
Set your cloud directory:
In[1]:=
SetCloudDirectory["/HTTPLanguageRedirect"]
Out[1]=
Assume you have two localized versions of a site:
In[2]:=
CloudDeploy["Hello","en/index.nb",Permissions"Public"]
Out[2]=
In[3]:=
CloudDeploy["Hola","es/index.nb",Permissions"Public"]
Out[3]=
Apply to the at index.nb:
HTTPLanguageRedirect
In[4]:=
CloudDeploy[{"en","es"}],CloudObject["index.nb"],Permissions"Public"
Out[4]=
Now send users to the root of your site:
In[5]:=
URL[First[CloudObject[""]]<>"/"]
Out[5]=
URL
Based on their browser settings, they will be automatically redirected to the correct localized version:
In[6]:=
Association[URLRead[HTTPRequest[CloudObject[""],<|"Headers"<|"Accept-Language""en"|>|>],"Headers",FollowRedirectsFalse]]["location"]
Out[6]=
en/
In[7]:=
Association[URLRead[HTTPRequest[CloudObject[""],<|"Headers"<|"Accept-Language""es"|>|>],"Headers",FollowRedirectsFalse]]["location"]
Out[7]=
es/
Scope (1)
Scope
(1)
Options (2)
Options
(2)
Possible Issues (1)
Possible Issues
(1)