Add languages

This commit is contained in:
eraden 2022-05-10 08:23:35 +02:00
parent 6255b4914c
commit ecf0bc7ce0
7 changed files with 73 additions and 45 deletions

8
Cargo.lock generated
View File

@ -2743,6 +2743,12 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "pure-rust-locales"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b45c49fc4f91f35bae654f85ebb3a44d60ac64f11b3166ffa609def390c732d8"
[[package]]
name = "quick-error"
version = "1.2.3"
@ -4248,7 +4254,9 @@ dependencies = [
"chrono",
"gloo-timers",
"indexmap",
"js-sys",
"model",
"pure-rust-locales",
"rusty-money",
"seed",
"serde",

View File

@ -19,12 +19,15 @@ serde_json = { version = "1.0.81" }
serde-wasm-bindgen = { version = "0.4.2" }
wasm-bindgen = { version = "0.2.80", features = ["default"] }
web-sys = { version = "0.3.57", features = [] }
web-sys = { version = "0.3.57", features = ["Navigator"] }
js-sys = { version = "0.3.57", features = [] }
indexmap = { version = "1", features = ["serde-1"] }
rusty-money = { version = "0.4.1", features = ["iso"] }
pure-rust-locales = { version = "0.5.6" }
[profile.release]
lto = true
opt-level = 's'

6
web/dist/index.html vendored
View File

@ -6,14 +6,14 @@
<base href="/">
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<link rel="preload" href="/web-cd27614be2332599_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/web-cd27614be2332599.js"></head>
<link rel="preload" href="/web-3b4fd2c9223643ce_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/web-3b4fd2c9223643ce.js"></head>
<body>
<main id="main">
</main>
<script type="module">import init from '/web-cd27614be2332599.js';init('/web-cd27614be2332599_bg.wasm');</script><script>(function () {
<script type="module">import init from '/web-3b4fd2c9223643ce.js';init('/web-3b4fd2c9223643ce_bg.wasm');</script><script>(function () {
var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
var url = protocol + '//' + window.location.host + '/_trunk/ws';
var poll_interval = 5000;

View File

@ -7,20 +7,6 @@ heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let WASM_VECTOR_LEN = 0;
let cachegetUint8Memory0 = null;
@ -84,6 +70,10 @@ function passStringToWasm0(arg, malloc, realloc) {
return ptr;
}
function isLikeNone(x) {
return x === undefined || x === null;
}
let cachegetInt32Memory0 = null;
function getInt32Memory0() {
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
@ -92,9 +82,7 @@ function getInt32Memory0() {
return cachegetInt32Memory0;
}
function isLikeNone(x) {
return x === undefined || x === null;
}
let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
@ -105,6 +93,18 @@ function addHeapObject(obj) {
return idx;
}
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
@ -203,11 +203,11 @@ function makeMutClosure(arg0, arg1, dtor, f) {
return real;
}
function __wbg_adapter_28(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h9beddee2cc3f9938(arg0, arg1, addHeapObject(arg2));
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hc049abcf4b80cae9(arg0, arg1, arg2);
}
function __wbg_adapter_31(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5098bb554daea520(arg0, arg1, arg2);
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h7e8af47ca9f57c91(arg0, arg1, addHeapObject(arg2));
}
function __wbg_adapter_34(arg0, arg1) {
@ -274,27 +274,10 @@ async function load(module, imports) {
async function init(input) {
if (typeof input === 'undefined') {
input = new URL('web-cd27614be2332599_bg.wasm', import.meta.url);
input = new URL('web-3b4fd2c9223643ce_bg.wasm', import.meta.url);
}
const imports = {};
imports.wbg = {};
imports.wbg.__wbindgen_cb_drop = function(arg0) {
const obj = takeObject(arg0).original;
if (obj.cnt-- == 1) {
obj.a = 0;
return true;
}
const ret = false;
return ret;
};
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = JSON.stringify(obj === undefined ? null : obj);
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = typeof(obj) === 'string' ? obj : undefined;
@ -307,6 +290,23 @@ async function init(input) {
const ret = getObject(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = JSON.stringify(obj === undefined ? null : obj);
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
imports.wbg.__wbindgen_cb_drop = function(arg0) {
const obj = takeObject(arg0).original;
if (obj.cnt-- == 1) {
obj.a = 0;
return true;
}
const ret = false;
return ret;
};
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
@ -914,12 +914,12 @@ async function init(input) {
const ret = wasm.memory;
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper4403 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 133, __wbg_adapter_28);
imports.wbg.__wbindgen_closure_wrapper1665 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 46, __wbg_adapter_28);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper4405 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 135, __wbg_adapter_31);
imports.wbg.__wbindgen_closure_wrapper1667 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 44, __wbg_adapter_31);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper11199 = function(arg0, arg1, arg2) {

16
web/src/i18n.rs Normal file
View File

@ -0,0 +1,16 @@
pub struct I18n {}
impl I18n {
pub fn load() -> Self {
// let languages: js_sys::Array = seed::window().navigator().languages();
// for lang in languages {
// let l: wasm_bindgen::JsValue = lang;
// if let Some(s) = l.as_string() {
// if let Ok(local) = pure_rust_locales::Locale::try_from(&s) {
// //
// }
// }
// }
Self {}
}
}

View File

@ -1,4 +1,5 @@
pub mod api;
mod i18n;
mod model;
mod pages;
pub mod shared;