3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Core_I18n_PseudoConstant
{
24 public static function longForShort($short) {
25 $longForShortMapping = self
::longForShortMapping();
26 return $longForShortMapping[$short];
32 public static function &longForShortMapping() {
33 static $longForShortMapping = NULL;
34 if ($longForShortMapping === NULL) {
36 CRM_Core_OptionValue
::getValues(['name' => 'languages'], $rows);
38 $longForShortMapping = [];
39 foreach ($rows as $row) {
40 $longForShortMapping[$row['value']] = $row['name'];
42 // hand-crafted enforced overrides for language variants
43 // NB: when adding support for a regional override for a new language below, update
44 // relevant comments in templates/CRM/common/civicrm.settings.php.template as well
45 $longForShortMapping['zh'] = defined("CIVICRM_LANGUAGE_MAPPING_ZH") ? CIVICRM_LANGUAGE_MAPPING_ZH
: 'zh_CN';
46 $longForShortMapping['en'] = defined("CIVICRM_LANGUAGE_MAPPING_EN") ? CIVICRM_LANGUAGE_MAPPING_EN
: 'en_US';
47 $longForShortMapping['fr'] = defined("CIVICRM_LANGUAGE_MAPPING_FR") ? CIVICRM_LANGUAGE_MAPPING_FR
: 'fr_FR';
48 $longForShortMapping['pt'] = defined("CIVICRM_LANGUAGE_MAPPING_PT") ? CIVICRM_LANGUAGE_MAPPING_PT
: 'pt_PT';
49 $longForShortMapping['es'] = defined("CIVICRM_LANGUAGE_MAPPING_ES") ? CIVICRM_LANGUAGE_MAPPING_ES
: 'es_ES';
51 return $longForShortMapping;
59 public static function shortForLong($long) {
60 return substr($long, 0, 2);
64 * Returns a list of ISO 639-1 "right-to-left" language codes.
68 public static function getRTLlanguages() {