use reqwest::blocking::get;
use serde_json::{ Value, from_str };
use current_platform::{CURRENT_PLATFORM, COMPILED_ON};
use sys_locale::get_locale;
use std::path::Path;
use gettext_ng::Catalog;
use std::fs::File;
fn main(){
const VERSION: &str = env!("CARGO_PKG_VERSION");
const NAME: &str = env!("CARGO_PKG_NAME");
let current_locale = get_locale().unwrap_or_else(|| String::from("en-US"));
let filename = format!("{}.mo", current_locale);
let file_path = format!("{current_locale}.mo");
let path = Path::new(&file_path);
if path.exists() {
println!("LanguageFile: {file_path} exists!");
let f = File::open(filename).expect("could not open the catalog");
let catalog = Catalog::parse(f).expect("could not parse the catalog");
println!("Platform: {} Program was compiled on {}", CURRENT_PLATFORM, COMPILED_ON);
println!("The locale is {}\n", current_locale);
println!("{} v{}\n", NAME, VERSION);
println!("{}", catalog.gettext("\nInfo Checker"));
let url = format!("https://myserver.mydomain.tld/info.json");
let response = get(url).unwrap();
let response_text = response.text().unwrap();
let json: Value = from_str(&response_text).expect("JSON was not well-formatted");
let ABC = json["ABC"].as_str().unwrap();
let DEF = json["DEF"].as_str().unwrap();
let GHI = json["GHI"].as_str().unwrap();
println!("\n{} ABC\n", ABC);
println!("\n{} DEF\n", DEF);
println!("\n{} GHI\n", GHI);
} else {
println!("File: {file_path} does not exist! Program abort");
}
}
use reqwest::blocking::get;
use serde_json::{ Value, from_str };
use current_platform::{CURRENT_PLATFORM, COMPILED_ON};
use sys_locale::get_locale;
use std::path::Path;
use gettext_ng::Catalog;
use std::fs::File;
fn main(){
const VERSION: &str = env!("CARGO_PKG_VERSION");
const NAME: &str = env!("CARGO_PKG_NAME");
let current_locale = get_locale().unwrap_or_else(|| String::from("en-US"));
let filename = format!("{}.mo", current_locale);
let file_path = format!("{current_locale}.mo");
let path = Path::new(&file_path);
if path.exists() {
println!("LanguageFile: {file_path} exists!");
let f = File::open(filename).expect("could not open the catalog");
let catalog = Catalog::parse(f).expect("could not parse the catalog");
println!("Platform: {} Program was compiled on {}", CURRENT_PLATFORM, COMPILED_ON);
println!("The locale is {}\n", current_locale);
println!("{} v{}\n", NAME, VERSION);
println!("{}", catalog.gettext("\nInfo Checker"));
let url = format!("https://myserver.mydomain.tld/info.json");
let response = get(url).unwrap();
let response_text = response.text().unwrap();
let json: Value = from_str(&response_text).expect("JSON was not well-formatted");
let ABC = json["ABC"].as_f64().unwrap();
let DEF = json["DEF"].as_f64().unwrap();
let GHI = json["GHI"].as_f64().unwrap();
println!("\n{} ABC\n", ABC);
println!("\n{} DEF\n", DEF);
println!("\n{} GHI\n", GHI);
} else {
println!("File: {file_path} does not exist! Program abort");
}
}