Skip to content

Add a helper method to make loading i18n in a blockly-less environment fail nicer. - #33917

Merged
Hamms merged 2 commits into
stagingfrom
safe-load-blockly
Mar 30, 2020
Merged

Add a helper method to make loading i18n in a blockly-less environment fail nicer.#33917
Hamms merged 2 commits into
stagingfrom
safe-load-blockly

Conversation

@Hamms

@Hamms Hamms commented Mar 30, 2020

Copy link
Copy Markdown
Contributor

Follow-up to #33670.

Specifically, add a helper method to wrap loading in locales from blockly. This method will take care to detect whether or not blockly is actually loaded in the calling environment, and will give a helpful warning message if it isn't. Thanks @islemaster for prototyping the implementation!

Links

Testing story

To recreate the original error from #33670, I added the following code:

diff --git a/apps/src/templates/projects/projectConstants.js b/apps/src/templates/projects/projectConstants.js
index 50a45e7ae49..90a040d986c 100644
--- a/apps/src/templates/projects/projectConstants.js
+++ b/apps/src/templates/projects/projectConstants.js
@@ -1,4 +1,7 @@
 import PropTypes from 'prop-types';
+import i18n from '@cdo/locale';
+
+console.log(`i18n.projectTypeAlgebra(): ${i18n.projectTypeAlgebra()}`);
 
 export const projectDataPropType = PropTypes.shape({
   channel: PropTypes.string.isRequired,

Loading http://localhost.code.org:3000/educate/regional-partner/playbook then gives the following console output

image

Reviewer Checklist:

  • Tests provide adequate coverage
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@Hamms Hamms changed the title Safe load blockly Add a helper method to make loading i18n in a blockly-less environment fail nicer. Mar 30, 2020
@Hamms
Hamms marked this pull request as ready for review March 30, 2020 19:23
@Hamms
Hamms requested review from a team, islemaster and jmkulwik March 30, 2020 19:24

@islemaster islemaster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@Hamms
Hamms merged commit 57e9b4e into staging Mar 30, 2020
@Hamms
Hamms deleted the safe-load-blockly branch March 30, 2020 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants