aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdrien Hopkins <[email protected]>2022-08-23 11:43:11 -0500
committerAdrien Hopkins <[email protected]>2022-08-23 11:43:11 -0500
commit5b1750b94a4bd44140cb792f676328e7ce4145cb (patch)
tree6103df26a7e6528b652f55c9747d6f4acd5728de /src
parenta810aee9747d18666a59fb58af18aa5de6ad015d (diff)
downloadcoinos-ui-5b1750b94a4bd44140cb792f676328e7ce4145cb.tar.gz
coinos-ui-5b1750b94a4bd44140cb792f676328e7ce4145cb.zip
put sveltekit-i18n locale in localStorage
Diffstat (limited to 'src')
-rw-r--r--src/routes/+layout.svelte11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 0485e71d..5eab20bd 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -9,7 +9,9 @@
import { goto } from '$app/navigation';
import { LoadingSplash } from '$comp';
import { warning, protectedRoutes } from '$lib/utils';
- import { t } from '$lib/translations';
+ import { t, locale } from '$lib/translations';
+
+ const localeLocalStorageKey = 'sveltekit-i18n-locale';
$: $token = data.token;
@@ -19,6 +21,13 @@
$: $selectedRate = data.user && $rate * (data.rates[data.user.currency] / data.rates.USD);
onMount(() => {
+ let localStorageLocale = localStorage.getItem(localeLocalStorageKey);
+ if (localStorageLocale) locale.set(localStorageLocale);
+
+ locale.subscribe((lng) => {
+ if (lng) localStorage.setItem(localeLocalStorageKey, lng);
+ });
+
if (protectedRoutes.find((p) => $page.url.pathname.match(p))) {
if (!$token) {
goto('/login');
e previous revision' href='/coinos-server.git/blame/index.js?id=6bafea9bffe24d2227d269812a73a9a513d92ddf'>^
04d0ffe1 ^
9a6f65be ^


91e84712 ^
9a6f65be ^
27fa1e54 ^
8fae698d ^
9a6f65be ^
91e84712 ^
a7322928 ^
a7322928 ^
193457c5 ^
7a84d255 ^
0b2f9a96 ^
80470a2c ^
74af7b1d ^
92e7d156 ^
91e84712 ^
0aea6033 ^
7f1be926 ^
91e84712 ^

33229e38 ^
9089698e ^
91e84712 ^

33d67e43 ^
91e84712 ^


91e84712 ^

db38e8f3 ^
be16090d ^
91e84712 ^
3ec79e2f ^
273afd10 ^
91e84712 ^
a7667374 ^
9a6f65be ^
ff4d63f3 ^
0de0e3ba ^
9a6f65be ^

9662c275 ^
9a6f65be ^
615e3d3d ^
0de0e3ba ^
b15b5d40 ^
ef71c296 ^


263ffd68 ^
9a6f65be ^
ad6bbbd5 ^
8c7fa95d ^
5264f702 ^
91e84712 ^
3b15d163 ^
fbf27aae ^
05b18b10 ^
1629a9ea ^


b3b12c6c ^
05b18b10 ^
5264f702 ^
cfca71ff ^
2f1372b5 ^
2a60293d ^
517065e5 ^
3498d1b6 ^
9c3b89f9 ^
0acff570 ^
692315c0 ^
8fae698d ^


53a4d40f ^
692315c0 ^

0b7f6a88 ^
692315c0 ^

414f8fab ^
59fe8d2e ^
1629a9ea ^
2edcafb3 ^
30910e1a ^
02a373b8 ^

2edcafb3 ^

91e84712 ^
f76ffaf5 ^
c28a1b61 ^
5c105c8f ^

c28a1b61 ^
5c105c8f ^
013dffcb ^
91e84712 ^
044c1737 ^
fb5ae5bb ^
91e84712 ^

6f5602d1 ^
91e84712 ^

602f5097 ^
a81cb5ad ^
4b5c6dde ^
3d38a365 ^

00b8317b ^

602f5097 ^
e68c302e ^


581fb404 ^







e68c302e ^

66198815 ^
8b019c45 ^
de7435e3 ^
e68c302e ^



91e84712 ^
88175fc2 ^


0ffadeb3 ^



d1272e81 ^
1d5053fe ^

91e84712 ^
831877b7 ^
91e84712 ^
05c582f6 ^
91e84712 ^
04d0ffe1 ^



99860c48 ^
04d0ffe1 ^
58e3d523 ^
5b9f051a ^
d5d15b1a ^
972ea530 ^
cc0e94b7 ^
d5d15b1a ^
9a6f65be ^
b255c6bb ^
0c55be9b ^
f8cfd7e1 ^
00f0cda6 ^
b82f045f ^
703564c4 ^
8b019c45 ^
703564c4 ^


f8cfd7e1 ^
3c68cfff ^




0acff570 ^
66198815 ^
c3565838 ^
fe62cadd ^
a7322928 ^
92e7d156 ^
013575bf ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
                           
                                                  
 
                                                                                            
                                               
                                              
                           
                                               
                                   

                                             
                                  
                                  
                                
                                        
                                  


                                          
                                        
                                  
                                      
                                    
                                  
 
     
                 
          
            
        
          
                        
              
 
                                     
                                         

                                 
                                    
                                

                               
                         


                               

                                      
                                      
                                          
                                                
                                                    
                                       
 
                                                                         
                                         
                                            
                                       

                                               
                                         
                                   
                                        
                                        
                                     


                                                
                                     
 
                                
                                                     
                                             
                                          
                                         
                                         
                                    


                                                            
                                                                      
                                                 
                                       
                                         
                                                               
                                           
                                       
                                             
                                            
                                                 
 


                                                 
 

                                 
                                           

                                           
                                     
                                             
                                      
 
                                     

                                       

                                               
 
                                             
                                                    

                                                 
                                                       
 
                                    
                               
                               
                                         

                                    
                                                

                                        
                                          
                                        
                                              

                                        

                                          
                                  


           







                                                                                                   

              
                                
                                       
                                        



                                                
 


                                                



                                                   
                                                     

                                                                 
                                            
                                  
                                              
                                                   
 



                                           
                                          
 
                                  
 
                                           
                                           
                              
 
                                         
                              
                                      
                                    
                                    
                                      
 
                                         


                           
 




                                 
                                                      
                                                                  
 
                           
 
                                

                                         
import app from "$lib/app";
import { admin, auth, optional } from "$lib/auth";

import { fixBolt12, listenForLightning, ensureListenerAlive, replay } from "$lib/lightning";
import { startHealthCheck } from "$lib/health";
import { getLocations } from "$lib/locations";
import nwc from "$lib/nwc";
import { catchUp, check } from "$lib/payments";
import { getFx } from "$lib/rates";
import { sendHeartbeat } from "$lib/sockets";

import ecash from "$routes/ecash";
import email from "$routes/email";
import info from "$routes/info";
import invoices from "$routes/invoices";
import items from "$routes/items";
import lnurl from "$routes/lnurl";
import locations from "$routes/locations";
import nostr from "$routes/nostr";
import payments from "$routes/payments";
import rates from "$routes/rates";
import shopify from "$routes/shopify";
import square from "$routes/square";
import users from "$routes/users";

try {
  getLocations();
  getFx();
  catchUp();
  nwc();
  check();
  // startHealthCheck();
} catch (e) {}

setTimeout(listenForLightning, 2000);
setInterval(ensureListenerAlive, 120000);
setInterval(sendHeartbeat, 2000);

app.get("/balances", info.balances);
app.get("/health", info.health);
app.post("/email", email.send);

app.get("/fx", rates.fx);
app.get("/rate", rates.last);
app.get("/rates", rates.index);

app.get("/locations", locations.list);

app.get("/invoice/:id", invoices.get);
app.get("/invoices", auth, invoices.list);
app.post("/invoice", optional, invoices.create);
app.post("/invoice/:id", optional, invoices.update);
app.post("/sign", auth, invoices.sign);

app.get("/assetlinks.json", (_, res) => res.sendFile("assetlinks.json"));
app.get("/nostr.json", nostr.identities);
app.get("/profile/:profile", nostr.profile);
app.get("/:pubkey/count", nostr.count);
app.get("/:pubkey/followers", nostr.followers);
app.get("/:pubkey/follows", nostr.follows);
app.get("/:pubkey/events", nostr.events);
app.get("/event/:id", nostr.event);
app.get("/event/:id/full", nostr.event);
app.post("/event", auth, nostr.publish);
app.post("/parseEvent", nostr.parse);
app.get("/zaps/:id", nostr.zaps);
app.post("/zap", auth, nostr.zap);
app.post("/zapRequest", auth, nostr.zapRequest);
app.get("/thread/:id", nostr.thread);

app.get("/info", payments.info);
app.post("/sendinvoice", auth, payments.sendinvoice);
app.post("/payments", auth, payments.create);
app.get("/payments", auth, payments.list);
app.get("/payments/:hash", payments.get);
app.post("/parse", auth, payments.parse);
app.get("/fund/:id", payments.fund);
// app.get("/fund/:name/withdraw", auth, payments.withdraw);
app.get("/fund/:name/managers", payments.managers);
app.post("/fund/managers", auth, payments.addManager);
app.post("/fund/:name/managers/delete", auth, payments.deleteManager);
app.post("/authorize", auth, payments.authorize);
app.post("/take", auth, payments.take);
app.post("/print", auth, payments.print);
app.post("/send/:lnaddress/:amount", auth, payments.lnaddress);
app.post("/send", auth, payments.internal);
app.post("/gateway", payments.gateway);
app.post("/replace", auth, payments.replace);
app.get("/decode/:bolt11", payments.decode);
app.post("/fetchinvoice", payments.fetchinvoice);

app.get("/square/connect", auth, square.connect);
app.get("/square/auth", auth, square.auth);
app.post("/square/payment", square.payment);

app.get("/encode", lnurl.encode);
app.get("/decode", lnurl.decode);
app.get("/lnurl/verify/:id", lnurl.verify);
app.get("/lnurlp/:username", lnurl.lnurlp);
app.get("/lnurl/:id", lnurl.lnurl);
app.get("/pay/:username", lnurl.pay);
app.get("/pay/:username/:amount", lnurl.pay);
// app.get("/lnurlw", lnurl.withdraw);

app.post("/freeze", payments.freeze);

app.post("/confirm", payments.confirm);
app.post("/bitcoin/fee", auth, payments.fee);
app.post("/bitcoin/send", auth, payments.send);

app.get("/account/:id", auth, users.account);
app.post("/account/:id", auth, users.updateAccount);
app.get("/accounts", auth, users.accounts);
app.post("/accounts", auth, users.createAccount);
app.post("/account/delete", auth, users.deleteAccount);

app.get("/users", auth, users.list);
app.get("/me", auth, users.me);
app.get("/ro", auth, users.ro);
app.get("/credits", auth, users.credits);
app.get("/users/:key", users.get);
app.post("/register", users.create);
app.post("/disable2fa", auth, users.disable2fa);
app.post("/2fa", auth, users.enable2fa);
app.post("/user", auth, users.update);
app.post("/reset", optional, users.reset);
app.post("/upload/:type", users.upload);
app.get("/users/delete/:username", users.del);
app.post("/acl", users.acl);
app.post("/superuser", users.superuser);
app.get("/verify/:code", users.verify);
app.post("/request", auth, users.request);
app.post("/forgot", users.forgot);
app.post(
  "/login",
  {
    config: {
      rateLimit: {
        max: 5,
        timeWindow: "5 seconds",
        keyGenerator: (req) => req.headers["cf-connecting-ip"] as string, // IP-based rate limiting
      },
    },
  },
  users.login,
);
app.post("/flash", users.flash);
app.get("/challenge", users.challenge);
app.post("/nostrAuth", users.nostrAuth);
app.get("/app/:pubkey", auth, users.app);
app.get("/apps", auth, users.apps);
app.post("/app", auth, users.updateApp);
app.post("/apps/delete", auth, users.deleteApp);

app.post("/pins", auth, users.addPin);
app.post("/pins/delete", auth, users.deletePin);

app.get("/trust", auth, users.trust);
app.post("/trust", auth, users.addTrust);
app.post("/trust/delete", auth, users.deleteTrust);

app.get("/subscriptions", auth, users.subscriptions);
app.post("/subscription", auth, users.subscription);
app.post("/subscription/delete", auth, users.deleteSubscription);
app.post("/password", auth, users.password);
app.post("/pin", auth, users.pin);
app.post("/otpsecret", auth, users.otpsecret);
app.get("/contacts/:limit?", auth, users.contacts);

app.get("/:id/items", items.list);
app.get("/items/:id", items.get);
app.post("/items", auth, items.create);
app.post("/items/delete", auth, items.del);
app.post("/items/sort", auth, items.sort);

app.post("/shopify/:id", shopify);

app.post("/hidepay", admin, users.hidepay);
app.post("/unlimit", admin, users.unlimit);
app.get("/bolt12", fixBolt12);

app.get("/cash/:id/:version", ecash.get);
app.post("/cash", ecash.save);
app.post("/claim", auth, ecash.claim);
app.post("/mint", auth, ecash.mint);
app.post("/melt", auth, ecash.melt);
app.post("/ecash/:id", ecash.receive);

app.get("/replay/:index", (req, res) => {
  replay(req.params.index);
  res.send({});
});

app.post("/echo", (req, res) => {
  console.log("echo", req.body);
  res.send(req.body);
});

const host: string = process.env["HOST"] || "0.0.0.0";
const port: number = Number.parseInt(process.env["PORT"]) || 3119;

app.listen({ host, port });

const logerr = (e: Error) => {};
process.on("unhandledRejection", logerr);
process.on("uncaughtException", logerr);