todos-contra-el-fuego-web/imports/startup/common/i18n.js
vjrj 6b6f02d92d quality: web debt batch (tests runner, FireContainer, rate-limit, maps, i18n)
Independent-of-prod quality debt from PENDIENTE.md §2:

- test: migrate broken Jest -> meteortesting:mocha. Tests rewritten to chai +
  Meteor 3 async APIs, moved to test/server/ (server-only). test/server/
  00-setup.test.js re-runs the collection2/accounts init that `meteor test`
  skips (no server/main.js). New comments method + mediaAnalyzers coverage.
  Dropped rest.test.js (removed meteor/http; covered by smoke/). 36 passing.
- fix: scope FireContainer read by the URL _id on the archive route instead of
  a selector-less FiresCollection.findOne() (imports/ui/pages/Fires/Fires.js).
- feat: rate-limit abusable publications via rateLimitSubscriptions (fireFrom*
  and comments.forReference 5/1000ms; geo subs 10/1000ms).
- perf: append loading=async to the Google Maps loader URL (Gkeys.js).
- deps: meteor-accounts-t9n 2.0 -> 2.6 (no gl build -> keep gl->es fallback,
  documented); add 3 missing gl/common.json keys (0 missing now).
- deps: drop jest/babel/enzyme, add chai.
2026-07-21 22:59:06 +02:00

61 lines
2.1 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import moment from 'moment';
// Load the js langs
import es from 'meteor-accounts-t9n/build/es';
import en from 'meteor-accounts-t9n/build/en';
// meteor-accounts-t9n (2.6.0) ships no Galician build (build/gl.js), so account
// error messages fall back to Spanish for gl — see setT9() in client/i18n.js.
// Re-enable this import if the upstream package ever adds a gl translation.
// import gl from 'meteor-accounts-t9n/build/gl';
const backOpts = {
// path where resources get loaded from
loadPath: '/locales/{{lng}}/{{ns}}.json',
// path to post missing resources
addPath: '/locales/{{lng}}/{{ns}}.missing.json',
// jsonIndent to use when storing json files
jsonIndent: 2
};
const forceDebug = true;
const shouldDebug = (forceDebug && !Meteor.isProduction);
const i18nOpts = {
backend: backOpts,
// lng: 'es',
fallbackLng: {
gl: ['es'],
default: ['en']
},
sendMissingTo: 'fallback',
interpolation: {
escapeValue: false, // not needed for react!!
formatSeparator: ',',
format: function f(value, format, lng) {
// https://www.i18next.com/formatting.html
// console.log(`Value: ${value} with format: ${format} to lang: ${lng}`);
if (format === 'uppercase') return value.toUpperCase();
if (value instanceof Date) return moment(value).format(format);
if (format === 'number') return Intl.NumberFormat(lng).format(value);
return value;
}
},
supportedLngs: ['es', 'en', 'gl'], // allowed languages (was `whitelist` pre-i18next-21)
load: 'languageOnly', // 'es' o 'en', previously: 'all', // es-ES -> es, en-US -> en
debug: shouldDebug,
ns: 'common',
defaultNS: 'common',
saveMissing: shouldDebug, // if true seems it's fails to getResourceBundle
saveMissingTo: 'es',
// Our locale JSON uses natural-language (Spanish) keys and the v3 plural
// layout (`key_plural`), so keep i18next on the v3 JSON format instead of
// the v4 suffix scheme (`key_one`/`key_other`).
compatibilityJSON: 'v3',
keySeparator: 'ß',
nsSeparator: 'ð',
pluralSeparator: 'đ'
};
export default i18nOpts;