ui: improve localization and plural handling

This commit is contained in:
a.tolmachev
2026-04-12 01:24:09 +03:00
parent 4dffad603f
commit fa75393e5f
5 changed files with 158 additions and 69 deletions
+27 -9
View File
@@ -1064,9 +1064,15 @@ function renderServiceResults(parsed, ids) {
var totalMethods = parsed.services.reduce(function(n, s) { return n + s.methods.length; }, 0);
var summaryEl = document.getElementById(ids.summary);
if (summaryEl) {
var servicesLabel = window.tPlural('wizard.grpc.services_label', parsed.services.length, {
count: parsed.services.length,
});
var methodsLabel = window.tPlural('wizard.grpc.methods_label', totalMethods, {
count: totalMethods,
});
summaryEl.textContent = tfKey('wizard.grpc.services_found', {
services: parsed.services.length,
methods: totalMethods,
services_label: servicesLabel,
methods_label: methodsLabel,
});
}
@@ -1109,7 +1115,9 @@ function renderServiceResults(parsed, ids) {
function renderParsedProto(parsed) {
var notice = document.getElementById('proto-streaming-text');
if (notice && parsed && parsed.streamingCount) {
notice.textContent = tfKey('wizard.step3.grpc.streaming_hidden', { count: parsed.streamingCount });
notice.textContent = window.tPlural('wizard.step3.grpc.streaming_hidden', parsed.streamingCount, {
count: parsed.streamingCount,
});
}
renderServiceResults(parsed, {
notice: 'proto-streaming-notice', count: 'proto-streaming-count',
@@ -1120,7 +1128,9 @@ function renderParsedProto(parsed) {
function renderReflectionResult(parsed) {
var reflectText = document.querySelector('#reflect-streaming-notice .info-callout-text');
if (reflectText && parsed && parsed.streamingCount) {
reflectText.textContent = tfKey('wizard.step3.grpc.streaming_hidden', { count: parsed.streamingCount });
reflectText.textContent = window.tPlural('wizard.step3.grpc.streaming_hidden', parsed.streamingCount, {
count: parsed.streamingCount,
});
}
renderServiceResults(parsed, {
notice: 'reflect-streaming-notice', count: 'reflect-streaming-count',
@@ -2572,13 +2582,21 @@ function describeWizardTestResult(result) {
}
if (result.window) {
var bodyParts = [
tKey('wizard.test.window_completed_body')
];
if (result.window.truncated) {
bodyParts.push(tKey('wizard.test.window_truncated_note'));
}
if (result.window.has_more) {
bodyParts.push(tKey('wizard.test.window_more_note'));
}
if (!result.window.window_complete) {
bodyParts.push(tKey('wizard.test.window_incomplete_note'));
}
return {
title: result.ok ? tKey('wizard.test.window_completed') : tKey('wizard.test.failed'),
body: tfKey('wizard.test.window_completed_body', {
truncated: result.window.truncated ? tKey('wizard.boolean.yes') : tKey('wizard.boolean.no'),
has_more: result.window.has_more ? tKey('wizard.boolean.yes') : tKey('wizard.boolean.no'),
window_complete: result.window.window_complete ? tKey('wizard.boolean.yes') : tKey('wizard.boolean.no')
}),
body: bodyParts.join(' '),
isError: !result.ok,
};
}