Implementation of Simple Copies inside POWR repo
What is Simple Copies
Our Simple Copies is way how we store translated strings for text.
We store it on a strapi content manager to upload, change data without knowing the code
Downloading Simple Copies
While building with docker, we get these simple copies by API in deployment/fetch_simple_copies.js from strapi and store them in yml files by locales.
Backend part of implementation
/Users/ranger/dev/powr/app/helpers/switchboard_helper.rbwe get simple copies by name fromI18ngem. here is the full descriptionHere
/Users/ranger/dev/powr/config/application.rbloads all simple copies for I18n in this line of code:config.i18n.load_path += Dir[Rails.root.join('config', 'locales', 'copies-from-strapi', '*.yml').to_s]
Fronted part of implementation
The
app/helpers/switchboard_helper.rbgets all the simple copies from theymlfiles that are stored inconfig/locales/copies-from-strapi, parses them intoJSONas a flat hash and thenapp/helpers/simple_copy_helper.rbloads them into a view insidewindow.SIMPLE_COPIES_DICTIONARY.If you want to add some new root key to load in the js part, for example
example.test,exampleis the (root key), you need to go toapp/helpers/simple_copy_helper.rband insidesimple_copies_dictionaryyou can add this line to upload simple copies that from your root key
simple_copies.merge!(copies_from_yaml("example"))