当前位置: 首页>>代码示例>>PHP>>正文


PHP AppLocale::get2LetterFrom3LetterIsoLanguage方法代码示例

本文整理汇总了PHP中AppLocale::get2LetterFrom3LetterIsoLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP AppLocale::get2LetterFrom3LetterIsoLanguage方法的具体用法?PHP AppLocale::get2LetterFrom3LetterIsoLanguage怎么用?PHP AppLocale::get2LetterFrom3LetterIsoLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppLocale的用法示例。


在下文中一共展示了AppLocale::get2LetterFrom3LetterIsoLanguage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: assert


//.........这里部分代码省略.........
                 switch ($nameType) {
                     // Authors
                     case 'personal':
                         // Only authors go into the submission.
                         if (in_array('aut', $nameRoles)) {
                             // Instantiate a new author object.
                             $authorDao = DAORegistry::getDAO('AuthorDAO');
                             /* @var $authorDao AuthorDAO */
                             $author = $authorDao->newDataObject();
                             // Family Name
                             $author->setLastName($nameDescription->getStatement('namePart[@type="family"]'));
                             // Given Names
                             $givenNames = $nameDescription->getStatement('namePart[@type="given"]');
                             if (!empty($givenNames)) {
                                 $givenNames = explode(' ', $givenNames, 2);
                                 if (isset($givenNames[0])) {
                                     $author->setFirstName($givenNames[0]);
                                 }
                                 if (isset($givenNames[1])) {
                                     $author->setMiddleName($givenNames[1]);
                                 }
                             }
                             // Affiliation
                             // NB: Our MODS mapping currently doesn't support translation for names.
                             // This can be added when required by data providers. We assume the cataloging
                             // language for the record.
                             $affiliation = $nameDescription->getStatement('affiliation');
                             if (!empty($affiliation)) {
                                 $author->setAffiliation($affiliation, $catalogingLocale);
                             }
                             // Terms of address (unmapped field)
                             $termsOfAddress = $nameDescription->getStatement('namePart[@type="termsOfAddress"]');
                             if ($termsOfAddress) {
                                 $author->setData('nlm34:namePart[@type="termsOfAddress"]', $termsOfAddress);
                             }
                             // Date (unmapped field)
                             $date = $nameDescription->getStatement('namePart[@type="date"]');
                             if ($date) {
                                 $author->setData('nlm34:namePart[@type="date"]', $date);
                             }
                             // Add the author to the submission.
                             $authorDao->insertObject($author);
                             unset($author);
                         }
                         break;
                         // Sponsor
                         // NB: Our MODS mapping currently doesn't support translation for names.
                         // This can be added when required by data providers. We assume the cataloging
                         // language for the record.
                     // Sponsor
                     // NB: Our MODS mapping currently doesn't support translation for names.
                     // This can be added when required by data providers. We assume the cataloging
                     // language for the record.
                     case 'corporate':
                         // Only the first sponsor goes into the submission.
                         if (!$foundSponsor && in_array('spn', $nameRoles)) {
                             $foundSponsor = true;
                             $targetDataObject->setSponsor($nameDescription->getStatement('namePart'), $catalogingLocale);
                         }
                         break;
                 }
             }
             unset($nameDescription);
         }
     }
     // Creation date
     $dateSubmitted = $metadataDescription->getStatement('originInfo/dateCreated[@encoding="w3cdtf"]');
     if ($dateSubmitted) {
         $targetDataObject->setDateSubmitted($dateSubmitted);
     }
     // Submission language
     $submissionLanguage = $metadataDescription->getStatement('language/languageTerm[@type="code" @authority="iso639-2b"]');
     $submissionLocale = AppLocale::get2LetterFrom3LetterIsoLanguage($submissionLanguage);
     if ($submissionLocale) {
         $targetDataObject->setLanguage($submissionLocale);
     }
     // Pages (extent)
     $pages = $metadataDescription->getStatement('physicalDescription/extent');
     if ($pages) {
         $targetDataObject->setPages($pages);
     }
     // Abstract
     $localizedAbstracts = $metadataDescription->getStatementTranslations('abstract');
     if (is_array($localizedAbstracts)) {
         foreach ($localizedAbstracts as $locale => $abstract) {
             $targetDataObject->setAbstract($abstract, $locale);
         }
     }
     // Discipline, subject class and subject
     // FIXME: We currently ignore discipline, subject class and subject because we cannot
     // distinguish them within a list of MODS topic elements. Can we use several subject
     // statements with different authorities instead?
     // FIXME: We do not include coverage information at the moment.
     // Record identifier
     // NB: We currently don't override the submission id with the record identifier in MODS
     // to make sure that MODS records can be transported between different installations.
     // Handle unmapped fields.
     $this->injectUnmappedDataObjectMetadataFields($metadataDescription, $targetDataObject);
     return $targetDataObject;
 }
开发者ID:PublishingWithoutWalls,项目名称:pkp-lib,代码行数:101,代码来源:Mods34SchemaSubmissionAdapter.inc.php

示例2: testGet2LetterFrom3LetterIsoLanguage

 /**
  * @covers PKPLocale
  */
 public function testGet2LetterFrom3LetterIsoLanguage()
 {
     self::assertEquals('en', AppLocale::get2LetterFrom3LetterIsoLanguage('eng'));
     self::assertEquals('pt', AppLocale::get2LetterFrom3LetterIsoLanguage('por'));
     self::assertNull(AppLocale::get2LetterFrom3LetterIsoLanguage('xxx'));
 }
开发者ID:doana,项目名称:pkp-lib,代码行数:9,代码来源:PKPLocaleTest.php


注:本文中的AppLocale::get2LetterFrom3LetterIsoLanguage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。