@bigbinary/neeto-playwright-commons 7.0.3 → 7.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +7 -3
  2. package/package.json +2 -3
package/index.js CHANGED
@@ -4143,10 +4143,13 @@ const loadRailsTranslations = () => {
4143
4143
  ]));
4144
4144
  };
4145
4145
  // Loaded once per worker, in its own namespace so Rails keys can't clash with t.
4146
+ const ensureRailsTranslations = (i18n) => {
4147
+ if (i18n.hasResourceBundle(ENGLISH_LOCALE, RAILS_NAMESPACE))
4148
+ return;
4149
+ Object.entries(loadRailsTranslations()).forEach(([locale, translations]) => i18n.addResourceBundle(locale, RAILS_NAMESPACE, translations));
4150
+ };
4151
+ // Loads on the first railsT call, so tests that never use it don't need the gems.
4146
4152
  const getRailsT = (i18n = getI18nInstance()) => {
4147
- if (!i18n.hasResourceBundle(ENGLISH_LOCALE, RAILS_NAMESPACE)) {
4148
- Object.entries(loadRailsTranslations()).forEach(([locale, translations]) => i18n.addResourceBundle(locale, RAILS_NAMESPACE, translations));
4149
- }
4150
4153
  const fixedT = i18n.getFixedT(ENGLISH_LOCALE, RAILS_NAMESPACE);
4151
4154
  const { locales } = getTranslationsConfig();
4152
4155
  // A requested es-MX the app doesn't ship falls back to es, as in Rails.
@@ -4154,6 +4157,7 @@ const getRailsT = (i18n = getI18nInstance()) => {
4154
4157
  ((locales === "all" || locales.includes(lng)) &&
4155
4158
  i18n.hasResourceBundle(lng.split("-")[0], RAILS_NAMESPACE));
4156
4159
  return ((key, options = {}) => {
4160
+ ensureRailsTranslations(i18n);
4157
4161
  if (options.lng && !isLoaded(options.lng)) {
4158
4162
  throw new Error(`Rails translations for "${options.lng}" aren't loaded. Add it to translationsConfig.locales, or check that the app ships it in config/locales.`);
4159
4163
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-playwright-commons",
3
- "version": "7.0.3",
3
+ "version": "7.0.5",
4
4
  "description": "A package encapsulating common playwright code across neeto projects.",
5
5
  "repository": "git@github.com:bigbinary/neeto-playwright-commons.git",
6
6
  "license": "apache-2.0",
@@ -21,8 +21,7 @@
21
21
  },
22
22
  "packageManager": "yarn@4.18.1",
23
23
  "engines": {
24
- "node": ">=24",
25
- "yarn": ">=4"
24
+ "node": ">=24"
26
25
  },
27
26
  "files": [
28
27
  "/index.js",