3

Is there a way to limit SugarCRM to just one language (us_en)? Right now everything we do generates 40+ language files which we'll never use. It makes finding things in the folders very difficult.

After removing all the languages except en_us my /sugarcrm/config_override.php contains the following:

<?php
/***CONFIGURATOR***/
$sugar_config['disabled_languages'] = 'bg_BG,cs_CZ,da_DK,de_DE,el_EL,es_ES,fr_FR,he_IL,
hu_HU,hr_HR,it_it,lt_LT,ja_JP,ko_KR,lv_LV,nb_NO,nl_NL,pl_PL,pt_PT,ro_RO,ru_RU,sv_SE,
th_TH,tr_TR,zh_TW,zh_CN,pt_BR,ca_ES,en_UK,sr_RS,sk_SK,sq_AL,et_EE,es_LA,fi_FI,ar_SA,uk_UA';
/***CONFIGURATOR***/

I then created test with a new package, named Dan, which has one module named Pets. When I look in version control I still have a file for each available language in the sugarcrm/custom/modulebuilder/packages/Dan/modules/Pets/languages

Dan
  • 1,238
  • 2
  • 17
  • 32
  • 1
    In Administration -> Languages you can disable languages. I don't know if that also disables language files generation for those languages, but maybe you want to try that if you didn't do that yet. – Jay Sep 14 '18 at 13:36
  • @Jay I tried that hoping it would cut down on the massive amount of language files but it did not seem to have any effect when I made a change and then did Repair > Quick Repair and Rebuild. – Dan Sep 14 '18 at 13:59

1 Answers1

3

It seems you can accomplish that by modifying the language array in the sugar config.

  1. Make sure to make a backup of your config.php, so that you have the original language array if you need it back. This is important even although our change will be in another file, because Sugar might recreate config.php automagically, using the resulting array, losing the original one.

  2. In your config_override.php add this line:

$sugar_config['languages'] = array('en_us' => 'English (US)');

Be aware that above line will make 'en_us' the only available language on that instance and Studio/etc. should now only create en_us files. If that is not the solution you're looking for - let me know please.

EDIT:

Above steps only seems to disable file creation spam for Dropdown Editor.

If you also want to make Module Builder not create any non-en_us language files, I found this - quite invasive - method of accomplishing just that:

  1. Create a Backup of the instance, then remove all *.lang.php files from the directories of include/ and modules/, except for en_us.* files. On Linux you can do this with find include modules -name '*.lang.php' -not -name 'en_us.*' -print -delete
  2. Delete the contents of the cache/ folder
  3. In Sugar run Administration -> Repair -> Quick Repair and Rebuild

This made my Module Builder only create en_us language files.

Note: If anybody should ever consider doing this for any other language than en_us, make sure to not only keep your language of choice, but also keep the en_us files additional to that! Those files are expected to exist in Sugar, as they are e.g. used for fallbacks of missing strings in any other language. Deleting the en_us files may lead to unexpected side-effects!

Jay
  • 3,640
  • 12
  • 17
  • I updated my original question with some more background on what I've tried so far. It looks like I've done the reverse of what you suggested but it seems like it might have the same effect? I will try again using you array and see if I have better results. Thanks – Dan Sep 14 '18 at 17:47
  • 1
    It's not exactly the reverse thing. "disable_languages" does also remove languages from the user's language selection. However, Sugar still seems to be aware of that language's existence. Removing a language from the language array does seem to make Sugar completely unaware of its existence (it also vanishes from the left side of the language disable screen). Waiting forward to your results, thanks for the update so far! ☺ – Jay Sep 14 '18 at 17:59
  • I can confirm that changing that language array does indeed remove all the languages except English from the Admin > Languages page. That alone is a step in the right direction. But, I still haven't been able to create a module without generating an language file for every available language though. I'm going to blow away my entire SugarCRM installation and start fresh. I will update with my results. – Dan Sep 14 '18 at 19:44
  • 1
    I just verified that using the suggestion from @Jay I am able to have some control over the language files that are generated. I made a new dropdown and for the first time I didn't get 40+ files created. It seems that the module builder may not follow the same rules. I'm going to dig a little deeper. Thanks ⭐️⭐️⭐️⭐️ – Dan Sep 14 '18 at 20:04
  • 1
    I update my answer with a solution that is somewhat brutal, but probably still easier to repeat/maintain than solutions that e.g.might involve patching `modules/ModuleBuilder/MB/MBLanguage.php`. – Jay Sep 14 '18 at 21:28
  • @Dan Just curious: Did the updated solution do the trick for you? Or are there any remaining issues with regards to unwanted language files getting generated - or Problems with this solution of any kind? – Jay Sep 17 '18 at 15:50
  • Hi @Jay, thanks for all your help on this. The combination of updating the correct config file (`config_override.php`) with the appropriate language array plus the awesome terminal command you supplied has us all sorted out. It's tempting to look inside the ModuleBuilder/MB/MBLanguage.php and make it behave correctly but I think I'll leave that alone. We're almost done making packages/modules I think (and hope). – Dan Sep 17 '18 at 18:25