|
7 | 7 | use anyhow::{Context, Result}; |
8 | 8 | use fsn_node_core::store::StoreEntry; |
9 | 9 | use fsn_store::StoreClient; |
10 | | -use toml; |
11 | 10 |
|
12 | 11 | // Schema version bundled with this binary — must match Lib's sync_snippets.py SCHEMA_VERSION. |
13 | 12 | const BUNDLED_SCHEMA_VERSION: &str = "1.0.0"; |
@@ -123,47 +122,23 @@ pub async fn update_check() -> Result<()> { |
123 | 122 |
|
124 | 123 | // ── i18n ─────────────────────────────────────────────────────────────────────── |
125 | 124 |
|
126 | | -/// One entry from `[[languages]]` in the store's `catalog/i18n.toml`. |
127 | | -#[derive(serde::Deserialize)] |
128 | | -struct I18nCatalogEntry { |
129 | | - code: String, |
130 | | - name: String, |
131 | | - #[serde(default)] |
132 | | - completeness: u8, |
133 | | - #[serde(default)] |
134 | | - schema_version: String, |
135 | | - // file / sha256 / size are used by the updater, not displayed here |
136 | | -} |
137 | | - |
138 | | -#[derive(serde::Deserialize)] |
139 | | -struct I18nCatalog { |
140 | | - #[serde(default, rename = "languages")] |
141 | | - languages: Vec<I18nCatalogEntry>, |
142 | | -} |
143 | | - |
144 | 125 | /// Show all available language packs from the store catalog with completeness. |
| 126 | +/// |
| 127 | +/// Reads `[[locales]]` from the main Node `catalog.toml`. |
145 | 128 | pub async fn i18n_status() -> Result<()> { |
146 | | - let client = StoreClient::node_store(); |
147 | | - let raw = client |
148 | | - .fetch_raw("Node/catalog/i18n.toml") |
149 | | - .await |
150 | | - .context("fetching i18n catalog")?; |
151 | | - let catalog: I18nCatalog = toml::from_str(&raw).context("parsing i18n catalog")?; |
152 | | - |
153 | | - if catalog.languages.is_empty() { |
154 | | - println!("No language packs available in the store yet."); |
| 129 | + let catalog = fetch_node_catalog().await?; |
| 130 | + |
| 131 | + if catalog.locales.is_empty() { |
| 132 | + println!("No language packs listed in the store catalog."); |
155 | 133 | return Ok(()); |
156 | 134 | } |
157 | 135 |
|
158 | | - println!("{:<6} {:<24} {:>5} {:<8} {}", "CODE", "LANGUAGE", "COMP%", "SCHEMA", ""); |
159 | | - println!("{}", "─".repeat(58)); |
160 | | - for e in &catalog.languages { |
161 | | - let ok = e.schema_version.is_empty() || e.schema_version == BUNDLED_SCHEMA_VERSION; |
162 | | - let marker = if ok { "✓" } else { "⚠ outdated" }; |
163 | | - let schema = if e.schema_version.is_empty() { BUNDLED_SCHEMA_VERSION } else { &e.schema_version }; |
164 | | - println!("{:<6} {:<24} {:>4}% {:<8} {}", e.code, e.name, e.completeness, schema, marker); |
| 136 | + println!("{:<6} {:<24} {:>5} {}", "CODE", "LANGUAGE", "COMP%", "DIR"); |
| 137 | + println!("{}", "─".repeat(46)); |
| 138 | + for loc in &catalog.locales { |
| 139 | + println!("{:<6} {:<24} {:>4}% {}", loc.code, loc.name, loc.completeness, loc.direction); |
165 | 140 | } |
166 | | - println!("\nRequired schema: {BUNDLED_SCHEMA_VERSION} (⚠ = needs update, run `fsn store i18n set <code>`)"); |
| 141 | + println!("\n{} language packs available.", catalog.locales.len()); |
167 | 142 | Ok(()) |
168 | 143 | } |
169 | 144 |
|
|
0 commit comments