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


PHP Locale::get3LetterFrom2LetterIsoLanguage方法代码示例

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


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

示例1: get3LetterIsoFromLocale

 /**
  * Translate the PKP locale identifier into an
  * ISO639-2b compatible 3-letter string.
  * @param $locale string
  * @return string
  */
 function get3LetterIsoFromLocale($locale)
 {
     assert(strlen($locale) == 5);
     $iso2Letter = substr($locale, 0, 2);
     return Locale::get3LetterFrom2LetterIsoLanguage($iso2Letter);
 }
开发者ID:JovanyJeff,项目名称:hrp,代码行数:12,代码来源:PKPLocale.inc.php

示例2: assert

 /**
  * @see MetadataDataObjectAdapter::extractMetadataFromDataObject()
  * @param $submission Submission
  * @param $authorMarcrelatorRole string the marcrelator role to be used
  *  for submission authors.
  * @return MetadataDescription
  */
 function &extractMetadataFromDataObject(&$submission, $authorMarcrelatorRole = 'aut')
 {
     assert(is_a($submission, 'Submission'));
     $mods34Description =& $this->instantiateMetadataDescription();
     // Retrieve the primary locale.
     $catalogingLocale = Locale::getPrimaryLocale();
     $catalogingLanguage = Locale::get3LetterIsoFromLocale($catalogingLocale);
     // Establish the association between the meta-data description
     // and the submission.
     $mods34Description->setAssocId($submission->getId());
     // Title
     $localizedTitles =& $submission->getTitle(null);
     // Localized
     $this->addLocalizedStatements($mods34Description, 'titleInfo/title', $localizedTitles);
     // Authors
     // FIXME: Move this to a dedicated adapter in the Author class.
     $authors =& $submission->getAuthors();
     foreach ($authors as $author) {
         /* @var $author Author */
         // Create a new name description.
         $authorDescription = new MetadataDescription('lib.pkp.plugins.metadata.mods34.schema.Mods34NameSchema', ASSOC_TYPE_AUTHOR);
         // Type
         $authorType = 'personal';
         $authorDescription->addStatement('[@type]', $authorType);
         // Family Name
         $authorDescription->addStatement('namePart[@type="family"]', $author->getLastName());
         // Given Names
         $firstName = (string) $author->getFirstName();
         $middleName = (string) $author->getMiddleName();
         $givenNames = trim($firstName . ' ' . $middleName);
         if (!empty($givenNames)) {
             $authorDescription->addStatement('namePart[@type="given"]', $givenNames);
         }
         // Affiliation
         // NB: Our MODS mapping currently doesn't support translation for names.
         // This can be added when required by data consumers. We therefore only use
         // translations in the cataloging language.
         $affiliation = $author->getAffiliation($catalogingLocale);
         if ($affiliation) {
             $authorDescription->addStatement('affiliation', $affiliation);
         }
         // Terms of address (unmapped field)
         $termsOfAddress = $author->getData('nlm34:namePart[@type="termsOfAddress"]');
         if ($termsOfAddress) {
             $authorDescription->addStatement('namePart[@type="termsOfAddress"]', $termsOfAddress);
         }
         // Date (unmapped field)
         $date = $author->getData('nlm34:namePart[@type="date"]');
         if ($date) {
             $authorDescription->addStatement('namePart[@type="date"]', $date);
         }
         // Role
         $authorDescription->addStatement('role/roleTerm[@type="code" @authority="marcrelator"]', $authorMarcrelatorRole);
         // Add the author to the MODS schema.
         $mods34Description->addStatement('name', $authorDescription);
         unset($authorDescription);
     }
     // Sponsor
     // NB: Our MODS mapping currently doesn't support translation for names.
     // This can be added when required by data consumers. We therefore only use
     // translations in the cataloging language.
     $supportingAgency = $submission->getSponsor($catalogingLocale);
     if ($supportingAgency) {
         $supportingAgencyDescription = new MetadataDescription('lib.pkp.plugins.metadata.mods34.schema.Mods34NameSchema', ASSOC_TYPE_AUTHOR);
         $sponsorNameType = 'corporate';
         $supportingAgencyDescription->addStatement('[@type]', $sponsorNameType);
         $supportingAgencyDescription->addStatement('namePart', $supportingAgency);
         $sponsorRole = 'spn';
         $supportingAgencyDescription->addStatement('role/roleTerm[@type="code" @authority="marcrelator"]', $sponsorRole);
         $mods34Description->addStatement('name', $supportingAgencyDescription);
     }
     // Type of resource
     $typeOfResource = 'text';
     $mods34Description->addStatement('typeOfResource', $typeOfResource);
     // Creation & copyright date
     $submissionDate = $submission->getDateSubmitted();
     if (strlen($submissionDate) >= 4) {
         $mods34Description->addStatement('originInfo/dateCreated[@encoding="w3cdtf"]', $submissionDate);
         $mods34Description->addStatement('originInfo/copyrightDate[@encoding="w3cdtf"]', substr($submissionDate, 0, 4));
     }
     // Submission language
     $submissionLanguage = Locale::get3LetterFrom2LetterIsoLanguage($submission->getLanguage());
     if (!$submissionLanguage) {
         // Assume the cataloging language by default.
         $submissionLanguage = $catalogingLanguage;
     }
     $mods34Description->addStatement('language/languageTerm[@type="code" @authority="iso639-2b"]', $submissionLanguage);
     // Pages (extent)
     $mods34Description->addStatement('physicalDescription/extent', $submission->getPages());
     // Abstract
     $localizedAbstracts =& $submission->getAbstract(null);
     // Localized
     $this->addLocalizedStatements($mods34Description, 'abstract', $localizedAbstracts);
//.........这里部分代码省略.........
开发者ID:ramonsodoma,项目名称:pkp-lib,代码行数:101,代码来源:Mods34SchemaSubmissionAdapter.inc.php

示例3: testGet3LetterFrom2LetterIsoLanguage

 /**
  * @covers PKPLocale
  */
 public function testGet3LetterFrom2LetterIsoLanguage()
 {
     self::assertEquals('eng', Locale::get3LetterFrom2LetterIsoLanguage('en'));
     self::assertEquals('por', Locale::get3LetterFrom2LetterIsoLanguage('pt'));
     self::assertNull(Locale::get3LetterFrom2LetterIsoLanguage('xx'));
 }
开发者ID:ramonsodoma,项目名称:pkp-lib,代码行数:9,代码来源:PKPLocaleTest.inc.php


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