diff options
| author | Greg Roach <fisharebest@gmail.com> | 2015-02-28 19:07:07 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2015-02-28 19:07:07 +0000 |
| commit | a92f322d58302cc9ecd07150776fb1e0253ae139 (patch) | |
| tree | acffff4181297399a1f21dbb2a5de233f3765060 /app/Individual.php | |
| parent | 5c5130184524127cdcb09f364807bd8997a9e08e (diff) | |
| download | webtrees-a92f322d58302cc9ecd07150776fb1e0253ae139.tar.gz webtrees-a92f322d58302cc9ecd07150776fb1e0253ae139.tar.bz2 webtrees-a92f322d58302cc9ecd07150776fb1e0253ae139.zip | |
Localize quotation marks around nicknames
Diffstat (limited to 'app/Individual.php')
| -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 |
