Commit 65c86f7d authored by eileen's avatar eileen

Define gettext translation for world_region

parent 5ad28d28
......@@ -1349,7 +1349,7 @@ SELECT is_primary,
case 'world_region':
case 'worldregion':
case 'worldregion_id':
return CRM_Core_PseudoConstant::worldRegion();
return CRM_Core_BAO_Country::buildOptions('region_id', $context);
}
return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
}
......
......@@ -403,7 +403,9 @@ class CRM_Core_CodeGen_Specification {
$field['widget']['required'] = $this->value('required', $fieldXML);
}
}
if (isset($fieldXML->localize_context)) {
$field['localize_context'] = $fieldXML->localize_context;
}
$field['pseudoconstant'] = $this->value('pseudoconstant', $fieldXML);
if (!empty($field['pseudoconstant'])) {
//ok this is a bit long-winded but it gets there & is consistent with above approach
......
......@@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Core/Address.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:7e4fc550c624fb3f273f3b2f53a23ee3)
* (GenCodeChecksum:a81d4789f6650c68145ab9bf1e4481a8)
*/
/**
......@@ -585,6 +585,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
'entity' => 'Address',
'bao' => 'CRM_Core_BAO_Address',
'localizable' => 0,
'localize_context' => 'province',
'FKClassName' => 'CRM_Core_DAO_StateProvince',
'html' => [
'type' => 'ChainSelect',
......@@ -656,6 +657,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
'entity' => 'Address',
'bao' => 'CRM_Core_BAO_Address',
'localizable' => 0,
'localize_context' => 'country',
'FKClassName' => 'CRM_Core_DAO_Country',
'html' => [
'type' => 'Select',
......
......@@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Core/Country.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:a71fa14f07c9291cf9db0e2335ee4613)
* (GenCodeChecksum:467cb92fabf3d936d330591eec94504d)
*/
/**
......@@ -220,7 +220,13 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO {
'entity' => 'Country',
'bao' => 'CRM_Core_BAO_Country',
'localizable' => 0,
'localize_context' => 'country',
'FKClassName' => 'CRM_Core_DAO_Worldregion',
'pseudoconstant' => [
'table' => 'civicrm_worldregion',
'keyColumn' => 'id',
'labelColumn' => 'name',
]
],
'is_province_abbreviated' => [
'name' => 'is_province_abbreviated',
......
......@@ -201,10 +201,14 @@ class CRM_Core_PseudoConstant {
public static function get($daoName, $fieldName, $params = array(), $context = NULL) {
CRM_Core_DAO::buildOptionsContext($context);
$flip = !empty($params['flip']);
// Historically this was 'false' but according to the notes in
// CRM_Core_DAO::buildOptionsContext it should be context dependent.
// timidly changing for 'search' only to fix world_region in search options.
$localizeDefault = in_array($context, ['search']) ? TRUE : FALSE;
// Merge params with defaults
$params += array(
'grouping' => FALSE,
'localize' => FALSE,
'localize' => $localizeDefault,
'onlyActive' => ($context == 'validate' || $context == 'get') ? FALSE : TRUE,
'fresh' => FALSE,
'context' => $context,
......@@ -378,11 +382,8 @@ class CRM_Core_PseudoConstant {
// Localize results
if (!empty($params['localize']) || $pseudoconstant['table'] == 'civicrm_country' || $pseudoconstant['table'] == 'civicrm_state_province') {
$I18nParams = array();
if ($pseudoconstant['table'] == 'civicrm_country') {
$I18nParams['context'] = 'country';
}
if ($pseudoconstant['table'] == 'civicrm_state_province') {
$I18nParams['context'] = 'province';
if (isset($fieldSpec['localize_context'])) {
$I18nParams['context'] = $fieldSpec['localize_context'];
}
$i18n = CRM_Core_I18n::singleton();
$i18n->localizeArray($output, $I18nParams);
......
......@@ -284,6 +284,7 @@
<keyColumn>id</keyColumn>
<labelColumn>name</labelColumn>
</pseudoconstant>
<localize_context>province</localize_context>
<html>
<type>ChainSelect</type>
</html>
......@@ -350,6 +351,7 @@
<labelColumn>name</labelColumn>
<nameColumn>iso_code</nameColumn>
</pseudoconstant>
<localize_context>country</localize_context>
<html>
<type>Select</type>
</html>
......
......@@ -80,6 +80,12 @@
<required>true</required>
<comment>Foreign key to civicrm_worldregion.id.</comment>
<add>1.8</add>
<localize_context>country</localize_context>
<pseudoconstant>
<table>civicrm_worldregion</table>
<keyColumn>id</keyColumn>
<labelColumn>name</labelColumn>
</pseudoconstant>
</field>
<foreignKey>
<name>region_id</name>
......
......@@ -138,6 +138,7 @@ class {$table.className} extends CRM_Core_DAO {ldelim}
'entity' => '{$table.entity}',
'bao' => '{$table.bao}',
'localizable' => {if $field.localizable}1{else}0{/if},
{if $field.localize_context}'localize_context' => '{$field.localize_context}',{/if}
{if $field.FKClassName}
'FKClassName' => '{$field.FKClassName}',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment