summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2015-01-21 21:11:29 +0000
committerGreg Roach <fisharebest@gmail.com>2015-01-21 21:11:29 +0000
commitc772ce871b2489736f6fa581b3268992ec31ca0f (patch)
tree93b3ecefd61864d018bf6a6fb3109517c8677f97
parentfd4cb105b9d7c112ff67d111b8bf160f6a6e26a2 (diff)
downloadwebtrees-c772ce871b2489736f6fa581b3268992ec31ca0f.tar.gz
webtrees-c772ce871b2489736f6fa581b3268992ec31ca0f.tar.bz2
webtrees-c772ce871b2489736f6fa581b3268992ec31ca0f.zip
The code to match the scripts of names/languages only works for certain langauges
-rw-r--r--library/WT/GedcomRecord.php55
1 files changed, 13 insertions, 42 deletions
diff --git a/library/WT/GedcomRecord.php b/library/WT/GedcomRecord.php
index f96a7e708e..ecbc323236 100644
--- a/library/WT/GedcomRecord.php
+++ b/library/WT/GedcomRecord.php
@@ -613,55 +613,26 @@ class WT_GedcomRecord {
* @return integer
*/
public function getPrimaryName() {
- if (is_null($this->_getPrimaryName)) {
+ static $language_script;
+
+ if ($language_script === null) {
+ $language_script = WT_I18N::languageScript(WT_LOCALE);
+ }
+
+ if ($this->_getPrimaryName === null) {
// Generally, the first name is the primary one....
$this->_getPrimaryName = 0;
- // ....except when the language/name use different character sets
+ // ...except when the language/name use different character sets
if (count($this->getAllNames()) > 1) {
- switch (WT_LOCALE) {
- case 'el':
- foreach ($this->getAllNames() as $n=>$name) {
- if ($name['type'] != '_MARNM' && WT_I18N::textScript($name['sort']) == 'Grek') {
- $this->_getPrimaryName = $n;
- break;
- }
- }
- break;
- case 'ru':
- foreach ($this->getAllNames() as $n=>$name) {
- if ($name['type'] != '_MARNM' && WT_I18N::textScript($name['sort']) == 'Cyrl') {
- $this->_getPrimaryName = $n;
- break;
- }
- }
- break;
- case 'he':
- foreach ($this->getAllNames() as $n=>$name) {
- if ($name['type'] != '_MARNM' && WT_I18N::textScript($name['sort']) == 'Hebr') {
- $this->_getPrimaryName = $n;
- break;
- }
- }
- break;
- case 'ar':
- foreach ($this->getAllNames() as $n=>$name) {
- if ($name['type'] != '_MARNM' && WT_I18N::textScript($name['sort']) == 'Arab') {
- $this->_getPrimaryName = $n;
- break;
- }
- }
- break;
- default:
- foreach ($this->getAllNames() as $n=>$name) {
- if ($name['type'] != '_MARNM' && WT_I18N::textScript($name['sort']) == 'Latn') {
- $this->_getPrimaryName = $n;
- break;
- }
+ foreach ($this->getAllNames() as $n => $name) {
+ if ($name['type'] !== '_MARNM' && WT_I18N::textScript($name['sort']) === $language_script) {
+ $this->_getPrimaryName = $n;
+ break;
}
- break;
}
}
}
+
return $this->_getPrimaryName;
}