summaryrefslogtreecommitdiff
path: root/app/GedcomCode/GedcomCodeName.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/GedcomCode/GedcomCodeName.php')
-rw-r--r--app/GedcomCode/GedcomCodeName.php289
1 files changed, 151 insertions, 138 deletions
diff --git a/app/GedcomCode/GedcomCodeName.php b/app/GedcomCode/GedcomCodeName.php
index a75b044b11..751f0e8502 100644
--- a/app/GedcomCode/GedcomCodeName.php
+++ b/app/GedcomCode/GedcomCodeName.php
@@ -22,146 +22,159 @@ use Fisharebest\Webtrees\Individual;
/**
* Class GedcomCodeName - Functions and logic for GEDCOM "NAME" codes
*/
-class GedcomCodeName {
- /** @var string[] A list of possible types of name */
- private static $TYPES = ['adopted', 'aka', 'birth', 'change', 'estate', 'immigrant', 'maiden', 'married', 'religious'];
+class GedcomCodeName
+{
+ /** @var string[] A list of possible types of name */
+ private static $TYPES = [
+ 'adopted',
+ 'aka',
+ 'birth',
+ 'change',
+ 'estate',
+ 'immigrant',
+ 'maiden',
+ 'married',
+ 'religious',
+ ];
- /**
- * Translate a code, for an (optional) record
- *
- * @param string $type
- * @param GedcomRecord|null $record
- *
- * @return string
- */
- public static function getValue($type, GedcomRecord $record = null) {
- if ($record instanceof Individual) {
- $sex = $record->getSex();
- } else {
- $sex = 'U';
- }
+ /**
+ * Translate a code, for an (optional) record
+ *
+ * @param string $type
+ * @param GedcomRecord|null $record
+ *
+ * @return string
+ */
+ public static function getValue($type, GedcomRecord $record = null)
+ {
+ if ($record instanceof Individual) {
+ $sex = $record->getSex();
+ } else {
+ $sex = 'U';
+ }
- switch ($type) {
- case 'adopted':
- switch ($sex) {
- case 'M':
- /* I18N: The name given to a child by its adoptive parents */
- return I18N::translateContext('MALE', 'adopted name');
- case 'F':
- /* I18N: The name given to a child by its adoptive parents */
- return I18N::translateContext('FEMALE', 'adopted name');
- default:
- /* I18N: The name given to a child by its adoptive parents */
- return I18N::translate('adopted name');
- }
- case 'aka':
- switch ($sex) {
- case 'M':
- /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */
- return I18N::translateContext('MALE', 'also known as');
- case 'F':
- /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */
- return I18N::translateContext('FEMALE', 'also known as');
- default:
- /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */
- return I18N::translate('also known as');
- }
- case 'birth':
- switch ($sex) {
- case 'M':
- /* I18N: The name given to an individual at their birth */
- return I18N::translateContext('MALE', 'birth name');
- case 'F':
- /* I18N: The name given to an individual at their birth */
- return I18N::translateContext('FEMALE', 'birth name');
- default:
- /* I18N: The name given to an individual at their birth */
- return I18N::translate('birth name');
- }
- case 'change':
- switch ($sex) {
- case 'M':
- /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */
- return I18N::translateContext('MALE', 'change of name');
- case 'F':
- /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */
- return I18N::translateContext('FEMALE', 'change of name');
- default:
- /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */
- return I18N::translate('change of name');
- }
- case 'estate':
- switch ($sex) {
- case 'M':
- /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */
- return I18N::translateContext('MALE', 'estate name');
- case 'F':
- /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */
- return I18N::translateContext('FEMALE', 'estate name');
- default:
- /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */
- return I18N::translate('estate name');
- }
- case 'immigrant':
- switch ($sex) {
- case 'M':
- /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */
- return I18N::translateContext('MALE', 'immigration name');
- case 'F':
- /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */
- return I18N::translateContext('FEMALE', 'immigration name');
- default:
- /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */
- return I18N::translate('immigration name');
- }
- case 'maiden':
- // Only women have “maiden” names!
- return
- /* I18N: A woman’s name, before she marries (in cultures where women take their new husband’s name on marriage) */
- I18N::translate('maiden name');
- case 'married':
- switch ($sex) {
- case 'M':
- /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */
- return I18N::translateContext('MALE', 'married name');
- case 'F':
- /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */
- return I18N::translateContext('FEMALE', 'married name');
- default:
- /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */
- return I18N::translate('married name');
- }
- case 'religious':
- switch ($sex) {
- case 'M':
- /* I18N: A name taken when entering a religion or a religious order */
- return I18N::translateContext('MALE', 'religious name');
- case 'F':
- /* I18N: A name taken when entering a religion or a religious order */
- return I18N::translateContext('FEMALE', 'religious name');
- default:
- /* I18N: A name taken when entering a religion or a religious order */
- return I18N::translate('religious name');
- }
- default:
- return $type;
- }
- }
+ switch ($type) {
+ case 'adopted':
+ switch ($sex) {
+ case 'M':
+ /* I18N: The name given to a child by its adoptive parents */
+ return I18N::translateContext('MALE', 'adopted name');
+ case 'F':
+ /* I18N: The name given to a child by its adoptive parents */
+ return I18N::translateContext('FEMALE', 'adopted name');
+ default:
+ /* I18N: The name given to a child by its adoptive parents */
+ return I18N::translate('adopted name');
+ }
+ case 'aka':
+ switch ($sex) {
+ case 'M':
+ /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */
+ return I18N::translateContext('MALE', 'also known as');
+ case 'F':
+ /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */
+ return I18N::translateContext('FEMALE', 'also known as');
+ default:
+ /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */
+ return I18N::translate('also known as');
+ }
+ case 'birth':
+ switch ($sex) {
+ case 'M':
+ /* I18N: The name given to an individual at their birth */
+ return I18N::translateContext('MALE', 'birth name');
+ case 'F':
+ /* I18N: The name given to an individual at their birth */
+ return I18N::translateContext('FEMALE', 'birth name');
+ default:
+ /* I18N: The name given to an individual at their birth */
+ return I18N::translate('birth name');
+ }
+ case 'change':
+ switch ($sex) {
+ case 'M':
+ /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */
+ return I18N::translateContext('MALE', 'change of name');
+ case 'F':
+ /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */
+ return I18N::translateContext('FEMALE', 'change of name');
+ default:
+ /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */
+ return I18N::translate('change of name');
+ }
+ case 'estate':
+ switch ($sex) {
+ case 'M':
+ /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */
+ return I18N::translateContext('MALE', 'estate name');
+ case 'F':
+ /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */
+ return I18N::translateContext('FEMALE', 'estate name');
+ default:
+ /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */
+ return I18N::translate('estate name');
+ }
+ case 'immigrant':
+ switch ($sex) {
+ case 'M':
+ /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */
+ return I18N::translateContext('MALE', 'immigration name');
+ case 'F':
+ /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */
+ return I18N::translateContext('FEMALE', 'immigration name');
+ default:
+ /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */
+ return I18N::translate('immigration name');
+ }
+ case 'maiden':
+ // Only women have “maiden” names!
+ return
+ /* I18N: A woman’s name, before she marries (in cultures where women take their new husband’s name on marriage) */
+ I18N::translate('maiden name');
+ case 'married':
+ switch ($sex) {
+ case 'M':
+ /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */
+ return I18N::translateContext('MALE', 'married name');
+ case 'F':
+ /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */
+ return I18N::translateContext('FEMALE', 'married name');
+ default:
+ /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */
+ return I18N::translate('married name');
+ }
+ case 'religious':
+ switch ($sex) {
+ case 'M':
+ /* I18N: A name taken when entering a religion or a religious order */
+ return I18N::translateContext('MALE', 'religious name');
+ case 'F':
+ /* I18N: A name taken when entering a religion or a religious order */
+ return I18N::translateContext('FEMALE', 'religious name');
+ default:
+ /* I18N: A name taken when entering a religion or a religious order */
+ return I18N::translate('religious name');
+ }
+ default:
+ return $type;
+ }
+ }
- /**
- * A list of all possible values for NAME types
- *
- * @param GedcomRecord|null $record
- *
- * @return string[]
- */
- public static function getValues(GedcomRecord $record = null) {
- $values = ['' => ''];
- foreach (self::$TYPES as $type) {
- $values[$type] = self::getValue($type, $record);
- }
- uasort($values, '\Fisharebest\Webtrees\I18N::strcasecmp');
+ /**
+ * A list of all possible values for NAME types
+ *
+ * @param GedcomRecord|null $record
+ *
+ * @return string[]
+ */
+ public static function getValues(GedcomRecord $record = null)
+ {
+ $values = ['' => ''];
+ foreach (self::$TYPES as $type) {
+ $values[$type] = self::getValue($type, $record);
+ }
+ uasort($values, '\Fisharebest\Webtrees\I18N::strcasecmp');
- return $values;
- }
+ return $values;
+ }
}