Skip to main content

[Obsolete] Translations and Simple Copy or Simple Copies

Translations​

  • Create/ Use the copy from simple_copies yml filesAll the commonly used simple copies will be added to general.yml (Accessed as POWr.simpleCopies('general.<key>'))
  • All keys related to specific components will be added to components.yml (Accessed as POWr.simpleCopies('components.<component_name>.<key>'))
  • If you are adding copies for specific apps - it will be under <app_parent_name>.yml.
  • The namespace and separation of files will help us load only the requried simple copies on pages
    • app/helpers/simple_copy_helper.rb has the logic
    • none of the js simple copies are loaded in /view page. If you need that talk to Praneeta
    • general, components are loaded on all pages (except /view)
    • users_components is loaded on on /users pages
    • app_settings is loaded only on plugins pages - like /standalone, /settings etc
    • formbuilder.yml is loaded only on /standalone, /settings for formbuilder and it's aliases.
  • The yml file
    • has key:value - Value is the english translation. you can choose not t provide a value here but that will result in the value being same as key - so you'll need to be fast on your feet when you deploy to prod to update it.
    • Create - If the key is not already stored in simple_copies table in db, it will create a new copy, use the value as the translation . IT WILL NOT UPDATE AN EXISTING ONE.
    • Edit - this can be easily edited using the current UI, so that functionality stays the same except now we have more context for translations. https://www.powr.io/simple_copies

In yml file test_multiple: "Test {name} - success {success}"

POWr.simpleCopies('general.ok')
=> "Ok"
POWr.simpleCopies('general.variable_sc_test.test_none')
=> "Test none - success"
POWr.simpleCopies('general.variable_sc_test.test_none', {name: 'internet'})
=> "Test none - success"
POWr.simpleCopies('general.variable_sc_test.test_single', {name: 'internet'})
=> "Test internet - success"
POWr.simpleCopies('general.variable_sc_test.test_double', {name: 'internet'})
=> "Test internet - success internet"
POWr.simpleCopies('general.variable_sc_test.test_double')
=> "Test {name} - success {name}"
POWr.simpleCopies('general.variable_sc_test.test_multiple', {name: 'internet'})
=> "Test internet - success {success}"
POWr.simpleCopies('general.variable_sc_test.test_multiple', {name: 'internet', success: 'ok'})
=> "Test internet - success ok"
POWr.simpleCopies('general.variable_sc_test.test_multiple', {name: 'internet', success: '<span class="awesomesauce"> HTML WORKS <span>'})
=> "Test internet - success <span class="awesomesauce"> HTML WORKS <span>"

- I don't see any translations - only namespaced keys:​

https://www.getoutline.com/doc/how-to-move-simple-copies-around-to-different-servers-riqXgwuubE

  • You can check if your simple copies slug is available by looking at the console of your browser. Type something like SIMPLE_COPIES_DICTIONARY['users_components.account.my_plugins'] and you should see.
  • To add your content to the correct page, use the app/helpers/simple_copy_helper.rb file

Auto translation of simple/general copies​

After SimpleCopy or GeneralCopy is created (via active record) worker will start and automatically translate it. If body is present it will be used for translation, otherwise name will be used. For ex: user.info.first_name will be translated as First Name from english to all other languages, If you want different value for simple copy the make sure to pass body.

How to add new simple copies?:

  • Add your simple copies via migration so that when code is deployed, your simple copies are already created.
  • If there are very few of them, you can add them via /admin interface.

EXAMPLE MIGRATIONS​

20190225195809_add_map_translations.rb - example of migration for reactified app. db/migrate/20200203062444_fix_paypal_button_simple_copies.rb