Sha256: cf4d7693e73a795b71e65b4671ad6bbb040ed056ff03ea2bab01e0dfd2f9a015

Contents?: true

Size: 579 Bytes

Versions: 3

Compression:

Stored size: 579 Bytes

Contents

import md5 from "md5";

function onMissingTranslation(I18n, md5, message) {
  return `translation missing: ${I18n.locale}.${message}`;
}

const interpolate = (message, data) =>
  message.replace(/%{([^{}]*)}/g, (a, b) => data[b]);

export default function configure(I18n) {
  I18n.screw = function screw(message, data) {
    const hash = md5(message);
    let translation = I18n.translations[I18n.locale]?.[hash];
    if (typeof translation === "undefined") {
      translation = onMissingTranslation(I18n, hash, message);
    }
    return interpolate(translation, data);
  };
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
i18n_screwdriver-10.7.2 package/src/index.js
i18n_screwdriver-10.7.1 package/src/index.js
i18n_screwdriver-10.7.0 package/src/index.js