I18n: faza 4 (aplikacja) - document.title per jezyk, historia: norma/bonus/deficyt przez klucze common

This commit is contained in:
tisachi
2026-10-17 16:11:15 +02:00
parent 3a6588b639
commit 3b76e8e0ee
4 changed files with 42 additions and 18 deletions

View File

@@ -101,11 +101,19 @@ export default function HistoryTable({
{duration && <span className="tabular-nums">{duration}</span>}
{plannedTotal > 0 && (
<span className="tabular-nums">
norma {plannedDone}/{plannedTotal}
{t('history.quota', { done: plannedDone, total: plannedTotal })}
</span>
)}
{extraSets > 0 && (
<span className="tabular-nums">
{t('history.bonusValue', { n: extraSets })}
</span>
)}
{deficit > 0 && (
<span className="tabular-nums">
{t('history.deficitValue', { n: deficit })}
</span>
)}
{extraSets > 0 && <span className="tabular-nums">+{extraSets} bonus</span>}
{deficit > 0 && <span className="tabular-nums">deficyt {deficit}</span>}
</div>
</div>
<div className="flex shrink-0 items-center gap-2">

View File

@@ -86,20 +86,28 @@ const resources = {
const initial = detectInitialLanguage();
applyDocumentLanguage(initial);
void i18n.use(initReactI18next).init({
lng: initial,
fallbackLng: 'pl',
supportedLngs: ['pl', 'en'],
defaultNS: 'common',
ns: [...NAMESPACES],
resources,
interpolation: { escapeValue: false },
react: { useSuspense: false },
});
void i18n
.use(initReactI18next)
.init({
lng: initial,
fallbackLng: 'pl',
supportedLngs: ['pl', 'en'],
defaultNS: 'common',
ns: [...NAMESPACES],
resources,
interpolation: { escapeValue: false },
react: { useSuspense: false },
})
.then(() => {
document.title = i18n.t('common:documentTitle');
});
// <html lang> podąża za językiem także przy zmianie przez i18n.changeLanguage
// (testy, przełącznik), nie tylko przez changeLanguage() z tego modułu.
i18n.on('languageChanged', (lng) => applyDocumentLanguage(lng === 'en' ? 'en' : 'pl'));
// <html lang> i document.title podążają za językiem także przy zmianie przez
// i18n.changeLanguage (testy, przełącznik), nie tylko przez changeLanguage() z tego modułu.
i18n.on('languageChanged', (lng) => {
applyDocumentLanguage(lng === 'en' ? 'en' : 'pl');
document.title = i18n.t('common:documentTitle');
});
export function changeLanguage(lang: Language) {
setStoredLanguage(lang);

View File

@@ -1,5 +1,6 @@
{
"appName": "FitOS",
"documentTitle": "FitOS",
"errorPrefix": "Error: ",
"cancel": "Cancel",
"confirm": "Confirm",
@@ -160,6 +161,9 @@
"addComment": "Add a comment",
"difficultyWord": "difficulty {{n}}",
"deleteCommentAria": "Delete {{author}}'s comment",
"commentForAria": "Comment for {{name}}"
"commentForAria": "Comment for {{name}}",
"quota": "quota {{done}}/{{total}}",
"bonusValue": "+{{n}} bonus",
"deficitValue": "deficit {{n}}"
}
}

View File

@@ -1,5 +1,6 @@
{
"appName": "FitOS",
"documentTitle": "FitOS",
"errorPrefix": "Błąd: ",
"cancel": "Anuluj",
"confirm": "Potwierdź",
@@ -173,6 +174,9 @@
"addComment": "Dodaj komentarz",
"difficultyWord": "trudność {{n}}",
"deleteCommentAria": "Usuń komentarz {{author}}",
"commentForAria": "Komentarz dla ćwiczenia {{name}}"
"commentForAria": "Komentarz dla ćwiczenia {{name}}",
"quota": "norma {{done}}/{{total}}",
"bonusValue": "+{{n}} bonus",
"deficitValue": "deficyt {{n}}"
}
}