civicrm / civicrm-setup

MIT License
7 stars 5 forks source link

AvailableLangs.civi-setup.php - Work without running GenCode #7

Closed totten closed 6 years ago

totten commented 6 years ago

The list of available languages currently follows this dataflow:

  1. The file xml/templates/languages.tpl contains a prototype of a SQL statement to insert a list of languages in a table.
  2. GenCode calls CRM/Core/CodeGen/I18n.php, which does regex-foo to extract the list of languages. It writes the list to install/langs.php.
  3. The plugin AvailableLangs.civi-setup.php reads the list of from install/langs.php.

Complaints with this arrangement:

  1. (Primary complaint) Using civicrm-setup to install requires that you previously ran GenCode (or copied the files)
  2. Using civicrm-setup to install requires that you have the old install/ folder.
  3. It is aesthetically displeasing to read data by running regex against a SQL statement.

Possible solutions:

  1. Commit install/langs.php to git (like we do with DAOs). Sounds easy - and fixes the primary complaint (#1).
  2. Copy the static list of languages into AvailableLangs.civi-setup.php. Sounds easy - and eventually fixes everything (if we manage to deprecate the install/ folder). But in the interim, adding a language requires an extra step. (Patch both civicrm-core and civicrm-setup.)
  3. Update civicrm-core so that the canonical list of languages is not in a SQL file. (Put it in something easy to parse -- like .json or .csv or .php.) Update both CRM/Core/CodeGen/I18n.php and AvailableLangs.civi-setup.php to read from this file. (This is prettiest, but a little more work/coordination.)
totten commented 6 years ago

The install/langs.php file was committed by https://github.com/civicrm/civicrm-core/pull/11667/, resolving the main issue.