From 12aa7f1a48fe83a690e25ada0f0f2a390b12e981 Mon Sep 17 00:00:00 2001 From: bptato Date: Thu, 30 Nov 2023 10:55:18 +0100 Subject: intl: stub out Intl.PluralRules --- src/js/intl.nim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/js/intl.nim') 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) -- cgit 1.4.1-2-gfad0