Skip to content

bug: incorrect locales used in in generated date functions #359

@cdaringe

Description

@cdaringe

Problem

locale es-MX gets en formatted functions

Demonstration

tiny runnable demo here: https://github.com/cdaringe/multi-locale-invalid-dates

it can be seen in just this code too:

const MessageFormat = require("@messageformat/core");
const compileMessageModule = require("@messageformat/core/lib/compile-module");

const messagePacks = {
  "en-US": {
    utilsDate: "{date, date, ::EEEMMMd}",
    utilsToday: "today",
    utilsTomorrow: "tomorrow",
  },
  "es-MX": {
    utilsDate: "{date, date, ::MMMMd}",
    utilsToday: "hoy",
    utilsTomorrow: "mañana",
  },
};

const mf = new MessageFormat("*");
console.log(compileMessageModule(mf, messagePacks));

which emits:

const date_en_MMMMd_meky2n = (function() { // should be es_mx
  var opt = {"month":"long","day":"numeric"}; // need to research if this is correct or not
  var dtf = new Intl.DateTimeFormat("en", opt); // should be "es-MX"
  return function(value) { return dtf.format(value); }
})();
export default {
  "en-US":   {/* snip */},
  "es-MX": {
    utilsDate: (d) => date_en_MMMMd_meky2n(d.date),
    utilsToday: () => "hoy",
    utilsTomorrow: () => "mañana"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions