Jelajahi Sumber

test: verify Russian pluralization (узел/узла/узлов) via Fluent CLDR

Updated the Russian cluster-selected message to use Fluent's built-in
CLDR plural rules instead of hardcoded 'узлов'.  Added unit test
verifying all three Russian plural forms:
  - 1 → '1 узел'   (CLDR 'one')
  - 2 → '2 узла'   (CLDR 'few')
  - 5 → '5 узлов'  (CLDR 'many')

The test explicitly sets locale to 'ru' and checks the t!() output.
Alexander Korolev 4 bulan lalu
induk
melakukan
c54d12d7cc
2 mengubah file dengan 15 tambahan dan 1 penghapusan
  1. 5 1
      locales/ru/main.ftl
  2. 10 0
      src/config.rs

+ 5 - 1
locales/ru/main.ftl

@@ -1,7 +1,11 @@
 cluster-not-found = Кластер "{ $name }" не найден
 nccl-config-missing = NCCL конфиг не найден
 cluster-auto-fail = Не удалось подобрать подходящий кластер
-cluster-selected = ✅ Автоподбор кластера: { $name } ({ $nodes } узлов)
+cluster-selected = ✅ Автоподбор кластера: { $name } ({ $nodes } { $nodes ->
+        [one] узел
+        [few] узла
+       *[many] узлов
+    })
 container-log-header = 📜 Последние логи контейнеров:
 cluster-stopping = 🛑 Останавливаем кластер '{ $name }'...
 cluster-all-stopped = ✅ Все контейнеры остановлены.

+ 10 - 0
src/config.rs

@@ -465,6 +465,16 @@ nodes = [
         assert!(result.is_err());
     }
     #[test]
+    fn test_russian_pluralization() {
+        let _prev = fluent_i18n::set_locale(Some("ru")).ok();
+        let s1 = fluent_i18n::t!("cluster-selected", { "name" => "c", "nodes" => 1u64 });
+        assert!(s1.contains("1 узел"), "got: {}", s1);
+        let s2 = fluent_i18n::t!("cluster-selected", { "name" => "c", "nodes" => 2u64 });
+        assert!(s2.contains("2 узла"), "got: {}", s2);
+        let s5 = fluent_i18n::t!("cluster-selected", { "name" => "c", "nodes" => 5u64 });
+        assert!(s5.contains("5 узлов"), "got: {}", s5);
+    }
+    #[test]
     fn test_default_engine_is_vllm() {
         let recipe: Recipe = toml::from_str("name = \"x\"\nmodel = \"m\"").unwrap();
         assert_eq!(recipe.engine, "vllm");