@@ -2,13 +2,14 @@ use regex::Regex;
22use std:: collections:: HashMap ;
33use std:: env;
44use std:: error:: Error ;
5- use std:: fs:: { self , create_dir_all, read_to_string, File } ;
6- use std:: io:: BufWriter ;
7- use std:: io:: Write ;
8- use std:: path:: { Path , PathBuf } ;
5+ use std:: fs:: { self , File } ;
6+ use std:: path:: Path ;
97use std:: sync:: LazyLock ;
108use tera:: { Context , Tera } ;
119
10+ #[ path = "locales/build.rs" ]
11+ mod locales;
12+
1213fn main ( ) -> Result < ( ) , Box < dyn Error > > {
1314 #[ cfg( windows) ]
1415 {
@@ -31,25 +32,8 @@ fn main() -> Result<(), Box<dyn Error>> {
3132 ) ?;
3233 fs:: write ( output_path, rust_code) ?;
3334
34- println ! ( "cargo:rerun-if-changed=locales/" ) ;
35- let locales_dir = PathBuf :: from ( "locales" ) . read_dir ( ) ?;
36- let out_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( "__locales_compiled" ) ;
37-
38- for dir in locales_dir {
39- let dir = dir?. path ( ) ;
40- let lang = dir. components ( ) . last ( ) . unwrap ( ) ;
41-
42- let out_dir = out_dir. join ( lang) ;
43- create_dir_all ( & out_dir) . unwrap ( ) ;
44-
45- let mut out_file = BufWriter :: new ( File :: create ( out_dir. join ( "onefetch.ftl" ) ) ?) ;
46-
47- for ftl in dir. read_dir ( ) ? {
48- let ftl = ftl?. path ( ) ;
49- let contents = read_to_string ( & ftl) ?;
50- writeln ! ( out_file, "{contents}" ) ?;
51- }
52- }
35+ locales:: concat_locales ( ) ?;
36+ locales:: generate_consts ( & out_dir) ?;
5337
5438 Ok ( ( ) )
5539}
0 commit comments