In a project i am working we use V8 to execute javascript. There are v8lib_monolith.a files ( which suggest that v8 engine is pre compiled) . In the cmakelists which i am using to build my project i am linking my runtime with the v8 monolith library too. I also have a wrapper around this v8 where i am initalizing ICU. Still i am getting error when trying to use a function which utilised ICU library. the error call stack is:
stack: 'ReferenceError: Intl is not defined\n' + ' at getDateTimeFormat ([email protected]/plugin/timezone/index.js:24:5)\n' + ' at makeFormatParts ([email protected]/plugin/timezone/index.js:51:15)\n' + ' at tzOffset ([email protected]/plugin/timezone/index.js:56:24)\n' + ' at Function.d.tz ([email protected]/plugin/timezone/index.js:163:26)\n'
One possible reason i thought was if i build my V8 with
V8_ENABLE_I18N_SUPPORT=false
in args.gn file will initalizing the icu using
v8::V8::InitializeICUDefaultLocation(path to lib file)
enable the ICU support.
You didn't actually ask a question. Presumably you want to know how to get an
Intlobject?With
v8_enable_i18n_support = falsein yourargs.gn, you get noIntlobject. So either drop that arg (to use the default value, which istrue), or explicitly set it totrueif you prefer.You need to initialize the location of the ICU data file in addition to enabling compile-time support for i18n.
Frankly, I'm not sure what
V8_ENABLE_I18N_SUPPORT=false(in upper-case spelling) does. Based on the fact that you don't have anIntlobject, I guess the variable name is case-insensitive. To make things clearer, why not spell it the official way, which is lower-case?