From 8e1ea7517ef0cf0dd4a9b8dc3fa54f21fd249729 Mon Sep 17 00:00:00 2001 From: a-ill Date: Mon, 3 Jul 2023 12:55:46 +0300 Subject: [PATCH] Update --- Server/app/layouts/main.jl.html | 2 - .../svelte/public/js/libraries/serverTools.js | 56 +++++++++---------- .../app/svelte/public/locales/available.json | 1 - .../svelte/src/communities-component.svelte | 2 +- .../app/svelte/src/join-us-component.svelte | 6 +- .../svelte/src/navbar/navbar-component.svelte | 34 ++++++----- .../public/js/components/join-us-component.js | 2 +- .../public/js/components/navbar-component.js | 2 +- Server/public/js/libraries/serverTools.js | 56 +++++++++---------- Server/public/sitemap.txt | 2 +- Server/routes.jl | 22 +++++--- 11 files changed, 95 insertions(+), 90 deletions(-) delete mode 100644 Server/app/svelte/public/locales/available.json diff --git a/Server/app/layouts/main.jl.html b/Server/app/layouts/main.jl.html index 6d54157..ea10148 100644 --- a/Server/app/layouts/main.jl.html +++ b/Server/app/layouts/main.jl.html @@ -12,8 +12,6 @@ - - diff --git a/Server/app/svelte/public/js/libraries/serverTools.js b/Server/app/svelte/public/js/libraries/serverTools.js index 72037f0..a15f954 100644 --- a/Server/app/svelte/public/js/libraries/serverTools.js +++ b/Server/app/svelte/public/js/libraries/serverTools.js @@ -66,40 +66,38 @@ function onlyUnique(value, index, array) { return array.indexOf(value) === index; } +export let locales = { + en: "English", + ru: "Русский" +} + export function loadLocaleContent(content,componentName,loaded,callback) { + let locale let langs - let localesAvailable - let locale = localStorage.getItem("locale") - if (locale==null) { - langs = navigator.languages.map(x => x.split("-")[0]).filter(onlyUnique) + let localesAvailable = Object.keys(locales) + let localeUrl = location.href.split("/").filter(x => localesAvailable.includes(x)) + if (localeUrl.length>0) { + locale = localeUrl } - getData("/locales/available.json",function(response) { - if (locale!=null) { - getData("/locales/" + locale + "/" + componentName + ".json" ,function(response) { - let parsed = JSON.parse(response) - content.set(parsed) - if (callback!=undefined) { - callback(locale) - } - loaded = 1 - }) - } - else { - localesAvailable = JSON.parse(response) - for (let lang of langs) { - if (localesAvailable.includes(lang)) { - getData("/locales/" + lang + "/" + componentName + ".json" ,function(response) { - let parsed = JSON.parse(response) - content.set(parsed) - if (callback!=undefined) { - callback(locale) - } - loaded = 1 - }) - } - break + else { + langs = navigator.languages.map(x => x.split("-")[0]).filter(onlyUnique) + for (let lang of langs) { + if (localesAvailable.includes(lang)) { + locale = lang } + break } + if (locale==undefined) { + locale = "en" + } + } + getData("/locales/" + locale + "/" + componentName + ".json" ,function(response) { + let parsed = JSON.parse(response) + content.set(parsed) + if (callback!=undefined) { + callback(locale) + } + loaded = 1 }) } diff --git a/Server/app/svelte/public/locales/available.json b/Server/app/svelte/public/locales/available.json deleted file mode 100644 index 29b6e3b..0000000 --- a/Server/app/svelte/public/locales/available.json +++ /dev/null @@ -1 +0,0 @@ -["en","ru"] \ No newline at end of file diff --git a/Server/app/svelte/src/communities-component.svelte b/Server/app/svelte/src/communities-component.svelte index 6ad934f..46a2f40 100644 --- a/Server/app/svelte/src/communities-component.svelte +++ b/Server/app/svelte/src/communities-component.svelte @@ -5,7 +5,7 @@ import { onMount } from 'svelte' import { writable } from 'svelte/store'; import { communities, addMarkersCommunities } from '/js/communities.js' - import { loadLocaleContent,getLocale } from "/js/libraries/serverTools.js" + import { loadLocaleContent, getLocale } from "/js/libraries/serverTools.js" // Import components import "/js/components/map-component.js" diff --git a/Server/app/svelte/src/join-us-component.svelte b/Server/app/svelte/src/join-us-component.svelte index 777011f..9885b48 100644 --- a/Server/app/svelte/src/join-us-component.svelte +++ b/Server/app/svelte/src/join-us-component.svelte @@ -55,9 +55,9 @@

{$content.findOur}

    -
  1. {$content.group},
  2. -
  3. {$content.community} {$content.or}
  4. -
  5. {$content.cooperative}
  6. +
  7. {$content.group},
  8. +
  9. {$content.community} {$content.or}
  10. +
  11. {$content.cooperative}

{$content.nearYou}

diff --git a/Server/app/svelte/src/navbar/navbar-component.svelte b/Server/app/svelte/src/navbar/navbar-component.svelte index 4cb5c07..6854774 100644 --- a/Server/app/svelte/src/navbar/navbar-component.svelte +++ b/Server/app/svelte/src/navbar/navbar-component.svelte @@ -4,17 +4,18 @@ // Import statements import { onMount, getContext } from 'svelte' - import { loadLocaleContent } from "/js/libraries/serverTools.js" - import { writable } from 'svelte/store'; + import { writable } from 'svelte/store' + import { loadLocaleContent, getLocale, locales } from "/js/libraries/serverTools.js" // Main code let hambInput let navbar let localesDropdown let loaded + let locale = [] let content = writable({}) - loadLocaleContent(content,"navbar-component",loaded) + loadLocaleContent(content,"navbar-component",loaded,(lang) => getLocale(locale,lang)) function changeNavbar() { if (hambInput.checked) { @@ -43,7 +44,11 @@ function changeLocale(lang) { localStorage.setItem("locale",lang) - location.reload() + let locSplit = location.href.split("/") + let localesSymbols = Object.keys(locales) + locSplit = locSplit.filter(x => !localesSymbols.includes(x)) + let loc = locSplit.slice(0,locSplit.length-1).join("/") + "/" + lang + "/" + locSplit[locSplit.length-1] + location.href = loc } onMount(() => { @@ -60,19 +65,19 @@ - - + + {$content.orgName} diff --git a/Server/public/js/components/join-us-component.js b/Server/public/js/components/join-us-component.js index 48db008..0eef9ea 100644 --- a/Server/public/js/components/join-us-component.js +++ b/Server/public/js/components/join-us-component.js @@ -1 +1 @@ -import{S as o,i as t,a as i,b as r,s as n,e,n as a,d as s,c as m,o as l,f as c,t as p,g as u,j as d,h as g,k as h,l as f,m as v}from"./index-ce8c147b.js";import{w as b}from"./index-f2dbf8ff.js";import{addMarkersGroups as j}from"../../../../../../../../../js/groups.js";import{addMarkersCoops as x}from"../../../../../../../../../js/coops.js";import{addMarkersCommunities as y}from"../../../../../../../../../js/communities.js";import{loadLocaleContent as P,getLocale as w}from"../../../../../../../../../js/libraries/serverTools.js";import"../../../../../../../../../js/components/map-component.js";function k(o){let t,i,n,e,a,m,l,b,j,x,y,P,w,k,O,A,S,T,D,H,N,L,M,U,z,B,E,G,R,W,Y,_,C,J,K,Z,q,F,I,Q,V,X,$,oo,to,io,ro,no,eo,ao,so,mo,lo,co,po,uo,go,ho,fo,vo,bo,jo,xo,yo,Po,wo,ko,Oo,Ao,So,To,Do,Ho,No,Lo,Mo,Uo,zo,Bo,Eo=o[0].heading+"",Go=o[0].condition1+"",Ro=o[0].condition2+"",Wo=o[0].condition3+"",Yo=o[0].conditionsOutcome+"",_o=o[0].subheading1+"",Co=o[0].valueProposition1+"",Jo=o[0].valueProposition2+"",Ko=o[0].valueProposition3+"",Zo=o[0].valueProposition4+"",qo=o[0].valueProposition5+"",Fo=o[0].subheading2+"",Io=o[0].findOur+"",Qo=o[0].group+"",Vo=o[0].community+"",Xo=o[0].or+"",$o=o[0].cooperative+"",ot=o[0].nearYou+"",tt=o[0].noneNear+"",it=o[0].WhatsAppGroup+"",rt=o[0].or+"",nt=o[0].DiscordServer+"",et=o[0].helpStart+"";return{c(){t=c("div"),i=c("div"),n=c("h1"),e=p(Eo),a=u(),m=c("img"),b=u(),j=c("ol"),x=c("li"),y=p(Go),P=u(),w=c("li"),k=p(Ro),O=u(),A=c("li"),S=p(Wo),T=u(),D=c("p"),H=u(),N=c("h2"),L=p(_o),M=u(),U=c("ol"),z=c("li"),B=p(Co),E=u(),G=c("li"),R=p(Jo),W=u(),Y=c("li"),_=p(Ko),C=u(),J=c("li"),K=p(Zo),Z=u(),q=c("p"),F=p(qo),I=u(),Q=c("h2"),V=p(Fo),X=u(),$=c("div"),oo=c("p"),to=p(Io),io=u(),ro=c("ol"),no=c("li"),eo=c("a"),ao=p(Qo),so=p(","),mo=u(),lo=c("li"),co=c("a"),po=p(Vo),uo=u(),go=p(Xo),ho=u(),fo=c("li"),vo=c("a"),bo=p($o),jo=u(),xo=c("p"),yo=p(ot),Po=u(),wo=c("p"),ko=p(tt),Oo=u(),Ao=c("a"),So=p(it),To=u(),Do=p(rt),Ho=u(),No=c("a"),Lo=p(nt),Mo=p(et),Uo=u(),zo=c("map-component"),d(m.src,l="/img/common/join-group.svg")||g(m,"src","/img/common/join-group.svg"),g(m,"id","join-group"),g(m,"alt","join group"),g(j,"id","condition-list"),g(U,"id","value-proposition-list"),g(eo,"href","/groups"),g(co,"href","/communities"),g(vo,"href","/cooperatives"),g($,"id","call-to-action-list"),g(Ao,"href","https://chat.whatsapp.com/BhnmUNljUxJ2AjeHUwyTKh"),g(Ao,"target","_blank"),g(Ao,"rel","noreferrer"),g(No,"href","https://discord.gg/xAPZmyr8B6"),g(No,"target","_blank"),g(No,"rel","noreferrer"),h(zo,"id","map"),h(zo,"callback",Bo=o[5]),g(i,"id","text-container"),g(t,"id","container")},m(o,s){r(o,t,s),f(t,i),f(i,n),f(n,e),f(i,a),f(i,m),f(i,b),f(i,j),f(j,x),f(x,y),f(j,P),f(j,w),f(w,k),f(j,O),f(j,A),f(A,S),f(j,T),f(j,D),D.innerHTML=Yo,f(i,H),f(i,N),f(N,L),f(i,M),f(i,U),f(U,z),f(z,B),f(U,E),f(U,G),f(G,R),f(U,W),f(U,Y),f(Y,_),f(U,C),f(U,J),f(J,K),f(U,Z),f(U,q),f(q,F),f(i,I),f(i,Q),f(Q,V),f(i,X),f(i,$),f($,oo),f(oo,to),f($,io),f($,ro),f(ro,no),f(no,eo),f(eo,ao),f(no,so),f(ro,mo),f(ro,lo),f(lo,co),f(co,po),f(lo,uo),f(lo,go),f(ro,ho),f(ro,fo),f(fo,vo),f(vo,bo),f($,jo),f($,xo),f(xo,yo),f(i,Po),f(i,wo),f(wo,ko),f(wo,Oo),f(wo,Ao),f(Ao,So),f(wo,To),f(wo,Do),f(wo,Ho),f(wo,No),f(No,Lo),f(wo,Mo),f(i,Uo),f(i,zo)},p(o,t){1&t&&Eo!==(Eo=o[0].heading+"")&&v(e,Eo),1&t&&Go!==(Go=o[0].condition1+"")&&v(y,Go),1&t&&Ro!==(Ro=o[0].condition2+"")&&v(k,Ro),1&t&&Wo!==(Wo=o[0].condition3+"")&&v(S,Wo),1&t&&Yo!==(Yo=o[0].conditionsOutcome+"")&&(D.innerHTML=Yo),1&t&&_o!==(_o=o[0].subheading1+"")&&v(L,_o),1&t&&Co!==(Co=o[0].valueProposition1+"")&&v(B,Co),1&t&&Jo!==(Jo=o[0].valueProposition2+"")&&v(R,Jo),1&t&&Ko!==(Ko=o[0].valueProposition3+"")&&v(_,Ko),1&t&&Zo!==(Zo=o[0].valueProposition4+"")&&v(K,Zo),1&t&&qo!==(qo=o[0].valueProposition5+"")&&v(F,qo),1&t&&Fo!==(Fo=o[0].subheading2+"")&&v(V,Fo),1&t&&Io!==(Io=o[0].findOur+"")&&v(to,Io),1&t&&Qo!==(Qo=o[0].group+"")&&v(ao,Qo),1&t&&Vo!==(Vo=o[0].community+"")&&v(po,Vo),1&t&&Xo!==(Xo=o[0].or+"")&&v(go,Xo),1&t&&$o!==($o=o[0].cooperative+"")&&v(bo,$o),1&t&&ot!==(ot=o[0].nearYou+"")&&v(yo,ot),1&t&&tt!==(tt=o[0].noneNear+"")&&v(ko,tt),1&t&&it!==(it=o[0].WhatsAppGroup+"")&&v(So,it),1&t&&rt!==(rt=o[0].or+"")&&v(Do,rt),1&t&&nt!==(nt=o[0].DiscordServer+"")&&v(Lo,nt),1&t&&et!==(et=o[0].helpStart+"")&&v(Mo,et),1&t&&Bo!==(Bo=o[5])&&h(zo,"callback",Bo)},d(o){o&&s(t)}}}function O(o){let t,i=0!=Object.keys(o[0]).length,n=i&&k(o);return{c(){n&&n.c(),t=e(),this.c=a},m(o,i){n&&n.m(o,i),r(o,t,i)},p(o,[r]){1&r&&(i=0!=Object.keys(o[0]).length),i?n?n.p(o,r):(n=k(o),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:a,o:a,d(o){n&&n.d(o),o&&s(t)}}}function A(o,t,i){let r,n,e=[],a=b({});function s(o,t,i){let r=o([51.505,-.09],3);j(r,t,i),x(r,t,i),y(r,t,i)}m(o,a,(o=>i(0,r=o))),P(a,"join-us-component",n,(o=>w(e,o))),l((()=>{}));return[r,n,e,a,s,o=>s(o,r,e)]}class S extends o{constructor(o){super(),this.shadowRoot.innerHTML="",t(this,{target:this.shadowRoot,props:i(this.attributes),customElement:!0},A,O,n,{},null),o&&o.target&&r(o.target,this,o.anchor)}}customElements.define("join-us-component",S);export{S as default}; +import{S as o,i as t,a as i,b as r,s as n,e,n as a,d as s,c as m,o as l,f as c,t as p,g as u,j as d,h as g,k as h,l as f,m as v}from"./index-ce8c147b.js";import{w as b}from"./index-f2dbf8ff.js";import{addMarkersGroups as j}from"../../../../../../../../../js/groups.js";import{addMarkersCoops as x}from"../../../../../../../../../js/coops.js";import{addMarkersCommunities as y}from"../../../../../../../../../js/communities.js";import{loadLocaleContent as P,getLocale as w}from"../../../../../../../../../js/libraries/serverTools.js";import"../../../../../../../../../js/components/map-component.js";function k(o){let t,i,n,e,a,m,l,b,j,x,y,P,w,k,O,A,S,T,D,H,N,L,M,U,z,B,E,G,R,W,Y,_,C,J,K,Z,q,F,I,Q,V,X,$,oo,to,io,ro,no,eo,ao,so,mo,lo,co,po,uo,go,ho,fo,vo,bo,jo,xo,yo,Po,wo,ko,Oo,Ao,So,To,Do,Ho,No,Lo,Mo,Uo,zo,Bo,Eo=o[0].heading+"",Go=o[0].condition1+"",Ro=o[0].condition2+"",Wo=o[0].condition3+"",Yo=o[0].conditionsOutcome+"",_o=o[0].subheading1+"",Co=o[0].valueProposition1+"",Jo=o[0].valueProposition2+"",Ko=o[0].valueProposition3+"",Zo=o[0].valueProposition4+"",qo=o[0].valueProposition5+"",Fo=o[0].subheading2+"",Io=o[0].findOur+"",Qo=o[0].group+"",Vo=o[0].community+"",Xo=o[0].or+"",$o=o[0].cooperative+"",ot=o[0].nearYou+"",tt=o[0].noneNear+"",it=o[0].WhatsAppGroup+"",rt=o[0].or+"",nt=o[0].DiscordServer+"",et=o[0].helpStart+"";return{c(){t=c("div"),i=c("div"),n=c("h1"),e=p(Eo),a=u(),m=c("img"),b=u(),j=c("ol"),x=c("li"),y=p(Go),P=u(),w=c("li"),k=p(Ro),O=u(),A=c("li"),S=p(Wo),T=u(),D=c("p"),H=u(),N=c("h2"),L=p(_o),M=u(),U=c("ol"),z=c("li"),B=p(Co),E=u(),G=c("li"),R=p(Jo),W=u(),Y=c("li"),_=p(Ko),C=u(),J=c("li"),K=p(Zo),Z=u(),q=c("p"),F=p(qo),I=u(),Q=c("h2"),V=p(Fo),X=u(),$=c("div"),oo=c("p"),to=p(Io),io=u(),ro=c("ol"),no=c("li"),eo=c("a"),ao=p(Qo),so=p(","),mo=u(),lo=c("li"),co=c("a"),po=p(Vo),uo=u(),go=p(Xo),ho=u(),fo=c("li"),vo=c("a"),bo=p($o),jo=u(),xo=c("p"),yo=p(ot),Po=u(),wo=c("p"),ko=p(tt),Oo=u(),Ao=c("a"),So=p(it),To=u(),Do=p(rt),Ho=u(),No=c("a"),Lo=p(nt),Mo=p(et),Uo=u(),zo=c("map-component"),d(m.src,l="/img/common/join-group.svg")||g(m,"src","/img/common/join-group.svg"),g(m,"id","join-group"),g(m,"alt","join group"),g(j,"id","condition-list"),g(U,"id","value-proposition-list"),g(eo,"href","/"+o[2][0]+"/groups"),g(co,"href","/"+o[2][0]+"/communities"),g(vo,"href","/"+o[2][0]+"/cooperatives"),g($,"id","call-to-action-list"),g(Ao,"href","https://chat.whatsapp.com/BhnmUNljUxJ2AjeHUwyTKh"),g(Ao,"target","_blank"),g(Ao,"rel","noreferrer"),g(No,"href","https://discord.gg/xAPZmyr8B6"),g(No,"target","_blank"),g(No,"rel","noreferrer"),h(zo,"id","map"),h(zo,"callback",Bo=o[5]),g(i,"id","text-container"),g(t,"id","container")},m(o,s){r(o,t,s),f(t,i),f(i,n),f(n,e),f(i,a),f(i,m),f(i,b),f(i,j),f(j,x),f(x,y),f(j,P),f(j,w),f(w,k),f(j,O),f(j,A),f(A,S),f(j,T),f(j,D),D.innerHTML=Yo,f(i,H),f(i,N),f(N,L),f(i,M),f(i,U),f(U,z),f(z,B),f(U,E),f(U,G),f(G,R),f(U,W),f(U,Y),f(Y,_),f(U,C),f(U,J),f(J,K),f(U,Z),f(U,q),f(q,F),f(i,I),f(i,Q),f(Q,V),f(i,X),f(i,$),f($,oo),f(oo,to),f($,io),f($,ro),f(ro,no),f(no,eo),f(eo,ao),f(no,so),f(ro,mo),f(ro,lo),f(lo,co),f(co,po),f(lo,uo),f(lo,go),f(ro,ho),f(ro,fo),f(fo,vo),f(vo,bo),f($,jo),f($,xo),f(xo,yo),f(i,Po),f(i,wo),f(wo,ko),f(wo,Oo),f(wo,Ao),f(Ao,So),f(wo,To),f(wo,Do),f(wo,Ho),f(wo,No),f(No,Lo),f(wo,Mo),f(i,Uo),f(i,zo)},p(o,t){1&t&&Eo!==(Eo=o[0].heading+"")&&v(e,Eo),1&t&&Go!==(Go=o[0].condition1+"")&&v(y,Go),1&t&&Ro!==(Ro=o[0].condition2+"")&&v(k,Ro),1&t&&Wo!==(Wo=o[0].condition3+"")&&v(S,Wo),1&t&&Yo!==(Yo=o[0].conditionsOutcome+"")&&(D.innerHTML=Yo),1&t&&_o!==(_o=o[0].subheading1+"")&&v(L,_o),1&t&&Co!==(Co=o[0].valueProposition1+"")&&v(B,Co),1&t&&Jo!==(Jo=o[0].valueProposition2+"")&&v(R,Jo),1&t&&Ko!==(Ko=o[0].valueProposition3+"")&&v(_,Ko),1&t&&Zo!==(Zo=o[0].valueProposition4+"")&&v(K,Zo),1&t&&qo!==(qo=o[0].valueProposition5+"")&&v(F,qo),1&t&&Fo!==(Fo=o[0].subheading2+"")&&v(V,Fo),1&t&&Io!==(Io=o[0].findOur+"")&&v(to,Io),1&t&&Qo!==(Qo=o[0].group+"")&&v(ao,Qo),1&t&&Vo!==(Vo=o[0].community+"")&&v(po,Vo),1&t&&Xo!==(Xo=o[0].or+"")&&v(go,Xo),1&t&&$o!==($o=o[0].cooperative+"")&&v(bo,$o),1&t&&ot!==(ot=o[0].nearYou+"")&&v(yo,ot),1&t&&tt!==(tt=o[0].noneNear+"")&&v(ko,tt),1&t&&it!==(it=o[0].WhatsAppGroup+"")&&v(So,it),1&t&&rt!==(rt=o[0].or+"")&&v(Do,rt),1&t&&nt!==(nt=o[0].DiscordServer+"")&&v(Lo,nt),1&t&&et!==(et=o[0].helpStart+"")&&v(Mo,et),1&t&&Bo!==(Bo=o[5])&&h(zo,"callback",Bo)},d(o){o&&s(t)}}}function O(o){let t,i=0!=Object.keys(o[0]).length,n=i&&k(o);return{c(){n&&n.c(),t=e(),this.c=a},m(o,i){n&&n.m(o,i),r(o,t,i)},p(o,[r]){1&r&&(i=0!=Object.keys(o[0]).length),i?n?n.p(o,r):(n=k(o),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:a,o:a,d(o){n&&n.d(o),o&&s(t)}}}function A(o,t,i){let r,n,e=[],a=b({});function s(o,t,i){let r=o([51.505,-.09],3);j(r,t,i),x(r,t,i),y(r,t,i)}m(o,a,(o=>i(0,r=o))),P(a,"join-us-component",n,(o=>w(e,o))),l((()=>{}));return[r,n,e,a,s,o=>s(o,r,e)]}class S extends o{constructor(o){super(),this.shadowRoot.innerHTML="",t(this,{target:this.shadowRoot,props:i(this.attributes),customElement:!0},A,O,n,{},null),o&&o.target&&r(o.target,this,o.anchor)}}customElements.define("join-us-component",S);export{S as default}; diff --git a/Server/public/js/components/navbar-component.js b/Server/public/js/components/navbar-component.js index f1c3aa8..3024d0e 100644 --- a/Server/public/js/components/navbar-component.js +++ b/Server/public/js/components/navbar-component.js @@ -1 +1 @@ -import{S as e,i as o,a as t,b as i,s as n,e as a,n as r,d as s,c as l,o as c,f as d,g as m,t as p,h,j as g,l as u,u as b,m as f,x as v,v as k}from"./index-ce8c147b.js";import{loadLocaleContent as w}from"../../../../../../../../../js/libraries/serverTools.js";import{w as x}from"./index-f2dbf8ff.js";function y(e){let o,t,n,a,r,l,c,k,w,x,y,j,z,T,E,H,L,M,N,S,C,O,R,U,I,X,q,A,B,D,F,G,J,K,P,Q,V,W,Y,Z,$,_,ee,oe,te,ie,ne,ae=e[3].orgName+"",re=e[3].manifesto+"",se=e[3].joinUs+"",le=e[3].groups+"",ce=e[3].communities+"",de=e[3].cooperatives+"",me=e[3].partners+"";return{c(){o=d("header"),t=d("input"),n=m(),a=d("label"),a.innerHTML='',r=m(),l=d("a"),c=d("img"),w=m(),x=d("span"),y=p(ae),j=m(),z=d("nav"),T=d("ul"),E=d("li"),H=d("a"),L=p(re),M=m(),N=d("li"),S=d("a"),C=p(se),O=m(),R=d("li"),U=d("a"),I=p(le),X=m(),q=d("li"),A=d("a"),B=p(ce),D=m(),F=d("li"),G=d("a"),J=p(de),K=m(),P=d("li"),Q=d("a"),V=p(me),W=m(),Y=d("li"),Z=d("button"),Z.innerHTML=' \n \n globe',$=m(),_=d("div"),ee=d("button"),ee.textContent="English",oe=m(),te=d("button"),te.textContent="Русский",h(t,"type","checkbox"),h(t,"id","side-menu"),h(a,"id","hamb"),h(a,"for","side-menu"),g(c.src,k="img/common/flag.png")||h(c,"src","img/common/flag.png"),h(c,"id","navbar-logo"),h(c,"alt","logo"),h(x,"id","navbar-logo-text"),h(l,"id","logo-container"),h(l,"href","/"),h(H,"href","/manifesto"),h(S,"href","/join-us"),h(U,"href","/groups"),h(A,"href","/communities"),h(G,"href","/cooperatives"),h(Q,"href","/partners"),h(Y,"id","locales"),h(_,"id","locales-dropdown"),h(T,"id","menu"),h(z,"id","nav"),h(o,"id","navbar")},m(s,d){i(s,o,d),u(o,t),e[8](t),u(o,n),u(o,a),u(o,r),u(o,l),u(l,c),u(l,w),u(l,x),u(x,y),u(o,j),u(o,z),u(z,T),u(T,E),u(E,H),u(H,L),u(T,M),u(T,N),u(N,S),u(S,C),u(T,O),u(T,R),u(R,U),u(U,I),u(T,X),u(T,q),u(q,A),u(A,B),u(T,D),u(T,F),u(F,G),u(G,J),u(T,K),u(T,P),u(P,Q),u(Q,V),u(T,W),u(T,Y),u(Y,Z),u(T,$),u(T,_),u(_,ee),u(_,oe),u(_,te),e[11](_),e[12](o),ie||(ne=[b(t,"click",e[6]),b(Z,"click",e[7]),b(ee,"click",e[9]),b(te,"click",e[10])],ie=!0)},p(e,o){8&o&&ae!==(ae=e[3].orgName+"")&&f(y,ae),8&o&&re!==(re=e[3].manifesto+"")&&f(L,re),8&o&&se!==(se=e[3].joinUs+"")&&f(C,se),8&o&&le!==(le=e[3].groups+"")&&f(I,le),8&o&&ce!==(ce=e[3].communities+"")&&f(B,ce),8&o&&de!==(de=e[3].cooperatives+"")&&f(J,de),8&o&&me!==(me=e[3].partners+"")&&f(V,me)},d(t){t&&s(o),e[8](null),e[11](null),e[12](null),ie=!1,v(ne)}}}function j(e){let o,t=0!=Object.keys(e[3]).length,n=t&&y(e);return{c(){n&&n.c(),o=a(),this.c=r},m(e,t){n&&n.m(e,t),i(e,o,t)},p(e,[i]){8&i&&(t=0!=Object.keys(e[3]).length),t?n?n.p(e,i):(n=y(e),n.c(),n.m(o.parentNode,o)):n&&(n.d(1),n=null)},i:r,o:r,d(e){n&&n.d(e),e&&s(o)}}}function z(e){localStorage.setItem("locale",e),location.reload()}function T(e,o,t){let i,n,a,r,s,d=x({});l(e,d,(e=>t(3,i=e))),w(d,"navbar-component",s),c((()=>{}));return[n,a,r,i,s,d,function(){n.checked?t(1,a.style.background="white",a):setTimeout((()=>{t(1,a.style.position="relative",a),t(1,a.style.background="",a),t(1,a.style.boxShadow="",a)}),510)},function(){"block"==r.style.display?t(2,r.style.display="none",r):t(2,r.style.display="block",r)},function(e){k[e?"unshift":"push"]((()=>{n=e,t(0,n)}))},()=>z("en"),()=>z("ru"),function(e){k[e?"unshift":"push"]((()=>{r=e,t(2,r)}))},function(e){k[e?"unshift":"push"]((()=>{a=e,t(1,a)}))}]}class E extends e{constructor(e){super(),this.shadowRoot.innerHTML="",o(this,{target:this.shadowRoot,props:t(this.attributes),customElement:!0},T,j,n,{},null),e&&e.target&&i(e.target,this,e.anchor)}}customElements.define("navbar-component",E);export{E as default}; +import{S as e,i as o,a as t,b as n,s as i,e as a,n as r,d as s,c as l,o as c,f as d,g as m,t as h,h as p,j as g,l as u,u as f,m as b,p as v,x as k,v as w}from"./index-ce8c147b.js";import{w as y}from"./index-f2dbf8ff.js";import{loadLocaleContent as x,getLocale as j,locales as z}from"../../../../../../../../../js/libraries/serverTools.js";function O(e,o,t){const n=e.slice();return n[14]=o[t][0],n[15]=o[t][1],n}function T(e){let o,t,i,a,r,l,c,w,y,x,j,T,L,M,N,S,E,R,U,I,X,q,A,B,C,D,F,G,J,K,P,Q,V,W,Y,Z,$,_,ee,oe,te,ne,ie,ae,re=e[3].orgName+"",se=e[3].manifesto+"",le=e[3].joinUs+"",ce=e[3].groups+"",de=e[3].communities+"",me=e[3].cooperatives+"",he=e[3].partners+"",pe=Object.entries(z),ge=[];for(let o=0;o',r=m(),l=d("a"),c=d("img"),y=m(),x=d("span"),j=h(re),T=m(),L=d("nav"),M=d("ul"),N=d("li"),S=d("a"),E=h(se),R=m(),U=d("li"),I=d("a"),X=h(le),q=m(),A=d("li"),B=d("a"),C=h(ce),D=m(),F=d("li"),G=d("a"),J=h(de),K=m(),P=d("li"),Q=d("a"),V=h(me),W=m(),Y=d("li"),Z=d("a"),$=h(he),_=m(),ee=d("li"),oe=d("button"),oe.innerHTML=' \n \n globe',te=m(),ne=d("div");for(let e=0;e!t.includes(e)));let n=o.slice(0,o.length-1).join("/")+"/"+e+"/"+o[o.length-1];location.href=n}l(e,m,(e=>t(3,n=e))),x(m,"navbar-component",s,(e=>j(d,e))),c((()=>{}));return[i,a,r,n,s,d,m,function(){i.checked?t(1,a.style.background="white",a):setTimeout((()=>{t(1,a.style.position="relative",a),t(1,a.style.background="",a),t(1,a.style.boxShadow="",a)}),510)},function(){"block"==r.style.display?t(2,r.style.display="none",r):t(2,r.style.display="block",r)},h,function(e){w[e?"unshift":"push"]((()=>{i=e,t(0,i)}))},e=>h(e),function(e){w[e?"unshift":"push"]((()=>{r=e,t(2,r)}))},function(e){w[e?"unshift":"push"]((()=>{a=e,t(1,a)}))}]}class N extends e{constructor(e){super(),this.shadowRoot.innerHTML="",o(this,{target:this.shadowRoot,props:t(this.attributes),customElement:!0},M,L,i,{},null),e&&e.target&&n(e.target,this,e.anchor)}}customElements.define("navbar-component",N);export{N as default}; diff --git a/Server/public/js/libraries/serverTools.js b/Server/public/js/libraries/serverTools.js index 72037f0..a15f954 100644 --- a/Server/public/js/libraries/serverTools.js +++ b/Server/public/js/libraries/serverTools.js @@ -66,40 +66,38 @@ function onlyUnique(value, index, array) { return array.indexOf(value) === index; } +export let locales = { + en: "English", + ru: "Русский" +} + export function loadLocaleContent(content,componentName,loaded,callback) { + let locale let langs - let localesAvailable - let locale = localStorage.getItem("locale") - if (locale==null) { - langs = navigator.languages.map(x => x.split("-")[0]).filter(onlyUnique) + let localesAvailable = Object.keys(locales) + let localeUrl = location.href.split("/").filter(x => localesAvailable.includes(x)) + if (localeUrl.length>0) { + locale = localeUrl } - getData("/locales/available.json",function(response) { - if (locale!=null) { - getData("/locales/" + locale + "/" + componentName + ".json" ,function(response) { - let parsed = JSON.parse(response) - content.set(parsed) - if (callback!=undefined) { - callback(locale) - } - loaded = 1 - }) - } - else { - localesAvailable = JSON.parse(response) - for (let lang of langs) { - if (localesAvailable.includes(lang)) { - getData("/locales/" + lang + "/" + componentName + ".json" ,function(response) { - let parsed = JSON.parse(response) - content.set(parsed) - if (callback!=undefined) { - callback(locale) - } - loaded = 1 - }) - } - break + else { + langs = navigator.languages.map(x => x.split("-")[0]).filter(onlyUnique) + for (let lang of langs) { + if (localesAvailable.includes(lang)) { + locale = lang } + break } + if (locale==undefined) { + locale = "en" + } + } + getData("/locales/" + locale + "/" + componentName + ".json" ,function(response) { + let parsed = JSON.parse(response) + content.set(parsed) + if (callback!=undefined) { + callback(locale) + } + loaded = 1 }) } diff --git a/Server/public/sitemap.txt b/Server/public/sitemap.txt index 02feea3..601c91b 100644 --- a/Server/public/sitemap.txt +++ b/Server/public/sitemap.txt @@ -4,4 +4,4 @@ https://www.libsoc.org/join-us https://www.libsoc.org/groups https://www.libsoc.org/communities https://www.libsoc.org/cooperatives -https://www.libsoc.org/affiliates \ No newline at end of file +https://www.libsoc.org/partners \ No newline at end of file diff --git a/Server/routes.jl b/Server/routes.jl index 78ddb06..8d97a16 100644 --- a/Server/routes.jl +++ b/Server/routes.jl @@ -5,17 +5,23 @@ using Server.BasicController #---Basic----------------------------------------------------------- -route("/", BasicController.landing, named = :landing) +route("/:locale/manifesto", BasicController.manifesto, named = :manifest) +route("/manifesto", BasicController.manifesto) -route("/manifesto", BasicController.manifesto, named = :manifest) +route("/:locale/join-us", BasicController.join_us, named = :join_us) +route("/join-us", BasicController.join_us) -route("/join-us", BasicController.join_us, named = :join_us) +route("/:locale/groups", BasicController.groups, named = :groups) +route("/groups", BasicController.groups) -route("/groups", BasicController.groups, named = :groups) +route("/:locale/cooperatives", BasicController.cooperatives, named = :cooperatives) +route("/cooperatives", BasicController.cooperatives) -route("/cooperatives", BasicController.cooperatives, named = :cooperatives) +route("/:locale/communities", BasicController.communities, named = :communities) +route("/communities", BasicController.communities) -route("/communities", BasicController.communities, named = :communities) - -route("/partners", BasicController.partners, named = :partners) +route("/:locale/partners", BasicController.partners, named = :partners) +route("/partners", BasicController.partners) +route("/:locale", BasicController.landing, named = :landing) +route("/", BasicController.landing)