locale_ca.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.ca = ca;
  4. const locale_js_1 = require("../locale.js");
  5. const locale_util_js_1 = require("../locale_util.js");
  6. const numbers_ca_js_1 = require("../numbers/numbers_ca.js");
  7. const transformers_js_1 = require("../transformers.js");
  8. const sansserifCombiner = function (letter, font, cap) {
  9. letter = 'sans serif ' + (cap ? cap + ' ' + letter : letter);
  10. return font ? letter + ' ' + font : letter;
  11. };
  12. let locale = null;
  13. function ca() {
  14. if (!locale) {
  15. locale = create();
  16. }
  17. return locale;
  18. }
  19. function create() {
  20. const loc = (0, locale_js_1.createLocale)();
  21. loc.NUMBERS = numbers_ca_js_1.NUMBERS;
  22. loc.COMBINERS['sansserif'] = sansserifCombiner;
  23. loc.FUNCTIONS.fracNestDepth = (_node) => false;
  24. loc.FUNCTIONS.combineRootIndex = locale_util_js_1.combinePostfixIndex;
  25. loc.FUNCTIONS.combineNestedRadical = (a, _b, c) => a + c;
  26. loc.FUNCTIONS.fontRegexp = (font) => RegExp('^' + font + ' ');
  27. loc.FUNCTIONS.plural = (unit) => {
  28. if (/.*os$/.test(unit)) {
  29. return unit + 'sos';
  30. }
  31. if (/.*s$/.test(unit)) {
  32. return unit + 'os';
  33. }
  34. if (/.*ga$/.test(unit)) {
  35. return unit.slice(0, -2) + 'gues';
  36. }
  37. if (/.*ça$/.test(unit)) {
  38. return unit.slice(0, -2) + 'ces';
  39. }
  40. if (/.*ca$/.test(unit)) {
  41. return unit.slice(0, -2) + 'ques';
  42. }
  43. if (/.*ja$/.test(unit)) {
  44. return unit.slice(0, -2) + 'ges';
  45. }
  46. if (/.*qua$/.test(unit)) {
  47. return unit.slice(0, -3) + 'qües';
  48. }
  49. if (/.*a$/.test(unit)) {
  50. return unit.slice(0, -1) + 'es';
  51. }
  52. if (/.*(e|i)$/.test(unit)) {
  53. return unit + 'ns';
  54. }
  55. if (/.*í$/.test(unit)) {
  56. return unit.slice(0, -1) + 'ins';
  57. }
  58. return unit + 's';
  59. };
  60. loc.FUNCTIONS.si = (prefix, unit) => {
  61. if (unit.match(/^metre/)) {
  62. prefix = prefix.replace(/a$/, 'à').replace(/o$/, 'ò').replace(/i$/, 'í');
  63. }
  64. return prefix + unit;
  65. };
  66. loc.ALPHABETS.combiner = transformers_js_1.Combiners.prefixCombiner;
  67. return loc;
  68. }