deps: i18next 10 -> 23, react-i18next 7 -> 14

Modernizes the whole i18n stack:
- 48 translate([], {wait:true}) / translate() HOCs -> withTranslation()
- react.wait:true -> react.useSuspense:false
- whitelist -> supportedLngs; added compatibilityJSON: 'v3' so our
  natural-language keys + v3 _plural layout keep working (custom
  separators ss/eth/dj preserved)
- backends: xhr -> i18next-http-backend (client), sync-fs ->
  i18next-fs-backend (server); dropped i18next-localstorage-cache
  (was enabled:false); languagedetector 2 -> 8
- ReSendEmail: <Interpolate> (removed in v10) -> <Trans values={{email}}/>,
  dropped the removed bare t export
- saveMissing handler signature (lngs, ns, key, fallbackValue)

Silences the per-component Translate/I18n legacy-context warnings.
Browser-verified es/en switch and <Trans> interpolation on /fires;
REST smoke byte-identical.
This commit is contained in:
vjrj 2026-07-18 06:28:41 +02:00
parent f1eae84e25
commit 12bdbe8fed
52 changed files with 226 additions and 553 deletions

View file

@ -3,9 +3,8 @@ import i18n from 'i18next';
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { ReactiveVar } from 'meteor/reactive-var';
import backend from 'i18next-xhr-backend';
import backend from 'i18next-http-backend';
import LngDetector from 'i18next-browser-languagedetector';
import Cache from 'i18next-localstorage-cache';
import { T9n } from 'meteor-accounts-t9n';
import moment from 'moment';
import 'moment/locale/es';
@ -31,21 +30,9 @@ const detectorOptions = {
export const i18nReady = new ReactiveVar(false);
const cacheOptions = {
// turn on or off
enabled: false,
// prefix for stored languages
prefix: 'i18next_res_',
// expiration
expirationTime: 7 * 24 * 60 * 60 * 1000,
// language versions
versions: {}
};
i18nOpts.cache = cacheOptions;
i18nOpts.detection = detectorOptions;
i18nOpts.react = {
wait: true,
useSuspense: false, // was `wait: true` pre-react-i18next-10
defaultTransParent: 'span'
// https://react.i18next.com/components/i18next-instance.ht
/* bindI18n: 'languageChanged loaded',
@ -55,8 +42,10 @@ i18nOpts.react = {
const sendMissing = true; // Meteor.isDevelopment;
if (sendMissing && Meteor.isDevelopment) {
i18nOpts.sendMissing = true;
i18nOpts.missingKeyHandler = function miss(lng, ns, key, defaultValue) {
i18nOpts.saveMissing = true;
// Modern signature is (lngs, ns, key, fallbackValue, ...); key/fallback keep
// the same positions, so we still only need those two.
i18nOpts.missingKeyHandler = function miss(lngs, ns, key, defaultValue) {
Meteor.call('utility.saveMissingI18n', key, defaultValue);
};
}
@ -71,7 +60,6 @@ function setT9(lang) {
i18n.use(backend)
.use(LngDetector)
.use(Cache)
.init(i18nOpts, (err, t) => {
// initialized and ready to
if (err) {