diff options
author | bptato <nincsnevem662@gmail.com> | 2023-11-30 10:55:18 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-11-30 10:55:18 +0100 |
commit | 12aa7f1a48fe83a690e25ada0f0f2a390b12e981 (patch) | |
tree | a6c17b96aa80ab9559e9363e7efd7da6b63084a2 /src/js/intl.nim | |
parent | a969b10663e923ff903ea7c77c479ef0ec71f66a (diff) | |
download | chawan-12aa7f1a48fe83a690e25ada0f0f2a390b12e981.tar.gz |
intl: stub out Intl.PluralRules
Diffstat (limited to 'src/js/intl.nim')
-rw-r--r-- | src/js/intl.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/js/intl.nim b/src/js/intl.nim index 8892d302..285a2b4e 100644 --- a/src/js/intl.nim +++ b/src/js/intl.nim @@ -1,19 +1,35 @@ # Very minimal Intl module... TODO make it more complete import bindings/quickjs +import js/dict import js/javascript import js/tojs type NumberFormat = ref object + PluralRules = ref object + + PRResolvedOptions = object of JSDict + locale: string + jsDestructor(NumberFormat) +jsDestructor(PluralRules) #TODO ...yeah proc newNumberFormat(name: string = "en-US", options = none(JSValue)): NumberFormat {.jsctor.} = return NumberFormat() +#TODO +proc newPluralRules(): PluralRules {.jsctor.} = + return PluralRules() + +proc resolvedOptions(this: PluralRules): PRResolvedOptions {.jsfunc.} = + return PRResolvedOptions( + locale: "en-US" + ) + #TODO: this should accept string/BigInt too proc format(nf: NumberFormat, num: float64): string {.jsfunc.} = let s = $num @@ -45,5 +61,6 @@ proc addIntlModule*(ctx: JSContext) = let global = JS_GetGlobalObject(ctx) let intl = JS_NewObject(ctx) ctx.registerType(NumberFormat, namespace = intl) + ctx.registerType(PluralRules, namespace = intl) ctx.defineProperty(global, "Intl", intl) JS_FreeValue(ctx, global) |