locale_fr.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { Grammar } from '../../rule_engine/grammar.js';
  2. import { createLocale } from '../locale.js';
  3. import { combinePostfixIndex, nestingToString } from '../locale_util.js';
  4. import { NUMBERS } from '../numbers/numbers_fr.js';
  5. import { Combiners } from '../transformers.js';
  6. let locale = null;
  7. export function fr() {
  8. if (!locale) {
  9. locale = create();
  10. }
  11. return locale;
  12. }
  13. function create() {
  14. const loc = createLocale();
  15. loc.NUMBERS = NUMBERS;
  16. loc.FUNCTIONS.radicalNestDepth = nestingToString;
  17. loc.FUNCTIONS.combineRootIndex = combinePostfixIndex;
  18. loc.FUNCTIONS.combineNestedFraction = (a, b, c) => c.replace(/ $/g, '') + b + a;
  19. loc.FUNCTIONS.combineNestedRadical = (a, _b, c) => c + ' ' + a;
  20. loc.FUNCTIONS.fontRegexp = (font) => RegExp(' (en |)' + font + '$');
  21. loc.FUNCTIONS.plural = (unit) => {
  22. return /.*s$/.test(unit) ? unit : unit + 's';
  23. };
  24. loc.CORRECTIONS.article = (name) => {
  25. return Grammar.getInstance().getParameter('noArticle') ? '' : name;
  26. };
  27. loc.ALPHABETS.combiner = Combiners.romanceCombiner;
  28. loc.SUBISO = {
  29. default: 'fr',
  30. current: 'fr',
  31. all: ['fr', 'be', 'ch']
  32. };
  33. return loc;
  34. }