File tree Expand file tree Collapse file tree 6 files changed +40
-0
lines changed
Expand file tree Collapse file tree 6 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ license-file = "./LICENSE_MIT"
1414autoexamples = false
1515include = [
1616 " src/*.rs" ,
17+ " src/icudtl.dat" ,
1718 " Cargo.toml" ,
1819]
1920
Original file line number Diff line number Diff line change 1+ // This setup is cloned from
2+ // https://github.com/denoland/deno_core_icudata/tree/main
3+ #[ repr( C , align( 16 ) ) ]
4+ struct IcuData < T : ?Sized > ( T ) ;
5+
6+ static ICU_DATA_RAW : & IcuData < [ u8 ] > = & IcuData ( * include_bytes ! ( "icudtl.dat" ) ) ;
7+
8+ /// Raw ICU data.
9+ pub static ICU_DATA : & [ u8 ] = & ICU_DATA_RAW . 0 ;
Original file line number Diff line number Diff line change 143143//! .body(result)
144144//! }
145145//!```
146+ mod icu;
146147mod ssr;
147148
148149pub use ssr:: { Ssr , SsrError } ;
Original file line number Diff line number Diff line change 5252 let platform = v8:: new_default_platform ( 0 , false ) . make_shared ( ) ;
5353 v8:: V8 :: initialize_platform ( platform) ;
5454 v8:: V8 :: initialize ( ) ;
55+
56+ v8:: icu:: set_common_data_74 ( crate :: icu:: ICU_DATA ) . expect ( "Failed to set ICU data" ) ;
5557 }
5658
5759 /// It creates a new SSR instance (multiple instances are allowed).
Original file line number Diff line number Diff line change 1+ use ssr_rs:: Ssr ;
2+ use std:: sync:: Once ;
3+
4+ static INIT : Once = Once :: new ( ) ;
5+
6+ fn prepare ( ) {
7+ INIT . call_once ( || {
8+ Ssr :: create_platform ( ) ;
9+ } )
10+ }
11+
12+ #[ test]
13+ fn it_supports_intl_namespace ( ) {
14+ prepare ( ) ;
15+ let mut js = Ssr :: from (
16+ r##"var ENTRY = {x: () => {
17+ return Intl.DateTimeFormat().resolvedOptions().locale;
18+ }};"##
19+ . to_string ( ) ,
20+ "ENTRY" ,
21+ )
22+ . unwrap ( ) ;
23+
24+ let html = js. render_to_string ( None ) . unwrap ( ) ;
25+
26+ assert_eq ! ( html, "en-US" ) ;
27+ }
You can’t perform that action at this time.
0 commit comments