diff options
| -rw-r--r-- | app/Individual.php | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/app/Individual.php b/app/Individual.php index f34c83891b..194f6d1368 100644 --- a/app/Individual.php +++ b/app/Individual.php @@ -1177,23 +1177,12 @@ class Individual extends GedcomRecord { // GEDCOM nicknames should be specificied in a NICK field, or in the // NAME filed, surrounded by ASCII quotes (or both). if ($NICK) { - // NICK field found. Add localised quotation marks. + // A NICK field is present. + $QNICK = /* I18N: Place a nickname in quotation marks */ I18N::translate('“%s”', $NICK); - // GREG 28/Jan/12 - these localised quotation marks apparently cause problems with LTR names on RTL - // pages and vice-versa. Just use straight ASCII quotes. Keep the old code, so that we keep the - // translations. - if (false) { - $QNICK = - /* I18N: Place a nickname in quotation marks */ - I18N::translate('“%s”', $NICK); - } else { - $QNICK = '"' . $NICK . '"'; - } - - if (preg_match('/(^| |"|«|“|\'|‹|‘|„)' . preg_quote($NICK, '/') . '( |"|»|”|\'|›|’|”|$)/', $full)) { - // NICK present in name. Localise ASCII quotes (but leave others). - // GREG 28/Jan/12 - redundant - see comment above. - // $full=str_replace('"'.$NICK.'"', $QNICK, $full); + if (strpos($full, '"' . $NICK . '"') !== false) { + // NICK present in name. Localise ASCII quotes. + $full = str_replace('"' . $NICK . '"', $QNICK, $full); } else { // NICK not present in NAME. $pos = strpos($full, '/'); @@ -1205,6 +1194,9 @@ class Individual extends GedcomRecord { $full = substr($full, 0, $pos) . $QNICK . ' ' . substr($full, $pos); } } + } else { + // No NICK field - but nickname may be included in NAME (in quotes) + $full = preg_replace_callback('/"([^"]*)"/', function($matches) { return I18N::translate('“%s”', $matches[1]); }, $full); } // Remove slashes - they don’t get displayed |
