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


PHP AppLocale::get3LetterFrom2LetterIsoLanguage方法代码示例

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


在下文中一共展示了AppLocale::get3LetterFrom2LetterIsoLanguage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 AppLocale::get3LetterFrom2LetterIsoLanguage($iso2Letter);
 }
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:12,代码来源:PKPLocale.inc.php

示例2: translateLanguageToLocale

 /**
  * Try to translate an ISO language code to an OJS locale.
  * @param $language string 2- or 3-letter ISO language code
  * @return string|null An OJS locale or null if no matching
  *  locale could be found.
  */
 function translateLanguageToLocale($language)
 {
     $locale = null;
     if (strlen($language) == 2) {
         $language = AppLocale::get3LetterFrom2LetterIsoLanguage($language);
     }
     if (strlen($language) == 3) {
         $language = AppLocale::getLocaleFrom3LetterIso($language);
     }
     if (AppLocale::isLocaleValid($language)) {
         $locale = $language;
     }
     return $locale;
 }
开发者ID:jalperin,项目名称:ojs,代码行数:20,代码来源:DOIExportDom.inc.php

示例3: extractMetadataFromDataObject

 /**
  * @see MetadataDataObjectAdapter::extractMetadataFromDataObject()
  * @param $submission Submission
  * @return MetadataDescription
  */
 function extractMetadataFromDataObject(&$submission)
 {
     assert(is_a($submission, 'Submission'));
     $mods34Description = $this->instantiateMetadataDescription();
     // Retrieve the primary locale.
     $catalogingLocale = AppLocale::getPrimaryLocale();
     $catalogingLanguage = AppLocale::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"]', 'aut');
         // 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
     $language = $submission->getLanguage();
     if ($language) {
         $submissionLanguage = AppLocale::get3LetterFrom2LetterIsoLanguage($submission->getLanguage());
     } else {
         $submissionLanguage = null;
     }
     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
//.........这里部分代码省略.........
开发者ID:PublishingWithoutWalls,项目名称:pkp-lib,代码行数:101,代码来源:Mods34SchemaSubmissionAdapter.inc.php

示例4: _addArticleXml


//.........这里部分代码省略.........
     }
     // We need the router to build file URLs.
     $router = $request->getRouter();
     /* @var $router PageRouter */
     // Add galley files
     $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
     $galleys = $articleGalleyDao->getBySubmissionId($article->getId());
     $galleyList = null;
     while ($galley = $galleys->next()) {
         /* @var $galley ArticleGalley */
         $locale = $galley->getLocale();
         $galleyUrl = $router->url($request, $journal->getPath(), 'article', 'download', array(intval($article->getId()), intval($galley->getId())));
         if (!empty($locale) && !empty($galleyUrl)) {
             if (is_null($galleyList)) {
                 $galleyList =& XMLCustomWriter::createElement($articleDoc, 'galleyList');
             }
             $galleyNode =& XMLCustomWriter::createElement($articleDoc, 'galley');
             XMLCustomWriter::setAttribute($galleyNode, 'locale', $locale);
             XMLCustomWriter::setAttribute($galleyNode, 'fileName', $galleyUrl);
             XMLCustomWriter::appendChild($galleyList, $galleyNode);
         }
     }
     // Wrap the galley XML as CDATA.
     if (!is_null($galleyList)) {
         if (is_callable(array($articleDoc, 'saveXml'))) {
             $galleyXml = $articleDoc->saveXml($galleyList);
         } else {
             $galleyXml = $galleyList->toXml();
         }
         $galleyOuterNode =& XMLCustomWriter::createElement($articleDoc, 'galley-xml');
         if (is_callable(array($articleDoc, 'createCDATASection'))) {
             $cdataNode = $articleDoc->createCDATASection($galleyXml);
         } else {
             $cdataNode = new XMLNode();
             $cdataNode->setValue('<![CDATA[' . $galleyXml . ']]>');
         }
         XMLCustomWriter::appendChild($galleyOuterNode, $cdataNode);
         XMLCustomWriter::appendChild($articleNode, $galleyOuterNode);
     }
     // Add supplementary files
     $fileDao = DAORegistry::getDAO('SuppFileDAO');
     $suppFiles =& $fileDao->getSuppFilesByArticle($article->getId());
     $suppFileList = null;
     foreach ($suppFiles as $suppFile) {
         /* @var $suppFile SuppFile */
         // Try to map the supp-file language to a PKP locale.
         $locale = null;
         $language = $suppFile->getLanguage();
         if (strlen($language) == 2) {
             $language = AppLocale::get3LetterFrom2LetterIsoLanguage($language);
         }
         if (strlen($language) == 3) {
             $locale = AppLocale::getLocaleFrom3LetterIso($language);
         }
         if (!AppLocale::isLocaleValid($locale)) {
             $locale = 'unknown';
         }
         $suppFileUrl = $router->url($request, $journal->getPath(), 'article', 'downloadSuppFile', array(intval($article->getId()), intval($suppFile->getId())));
         if (!empty($locale) && !empty($suppFileUrl)) {
             if (is_null($suppFileList)) {
                 $suppFileList =& XMLCustomWriter::createElement($articleDoc, 'suppFileList');
             }
             $suppFileNode =& XMLCustomWriter::createElement($articleDoc, 'suppFile');
             XMLCustomWriter::setAttribute($suppFileNode, 'locale', $locale);
             XMLCustomWriter::setAttribute($suppFileNode, 'fileName', $suppFileUrl);
             XMLCustomWriter::appendChild($suppFileList, $suppFileNode);
             // Add supp file meta-data.
             $suppFileMetadata = array('title' => $suppFile->getTitle(null), 'creator' => $suppFile->getCreator(null), 'subject' => $suppFile->getSubject(null), 'typeOther' => $suppFile->getTypeOther(null), 'description' => $suppFile->getDescription(null), 'source' => $suppFile->getSource(null));
             foreach ($suppFileMetadata as $field => $data) {
                 if (!empty($data)) {
                     $suppFileMDListNode =& XMLCustomWriter::createElement($articleDoc, $field . 'List');
                     foreach ($data as $locale => $value) {
                         $suppFileMDNode =& XMLCustomWriter::createChildWithText($articleDoc, $suppFileMDListNode, $field, $value);
                         XMLCustomWriter::setAttribute($suppFileMDNode, 'locale', $locale);
                         unset($suppFileMDNode);
                     }
                     XMLCustomWriter::appendChild($suppFileNode, $suppFileMDListNode);
                     unset($suppFileMDListNode);
                 }
             }
         }
     }
     // Wrap the suppFile XML as CDATA.
     if (!is_null($suppFileList)) {
         if (is_callable(array($articleDoc, 'saveXml'))) {
             $suppFileXml = $articleDoc->saveXml($suppFileList);
         } else {
             $suppFileXml = $suppFileList->toXml();
         }
         $suppFileOuterNode =& XMLCustomWriter::createElement($articleDoc, 'suppFile-xml');
         if (is_callable(array($articleDoc, 'createCDATASection'))) {
             $cdataNode = $articleDoc->createCDATASection($suppFileXml);
         } else {
             $cdataNode = new XMLNode();
             $cdataNode->setValue('<![CDATA[' . $suppFileXml . ']]>');
         }
         XMLCustomWriter::appendChild($suppFileOuterNode, $cdataNode);
         XMLCustomWriter::appendChild($articleNode, $suppFileOuterNode);
     }
 }
开发者ID:utlib,项目名称:ojs,代码行数:101,代码来源:SolrWebService.inc.php

示例5: testGet3LetterFrom2LetterIsoLanguage

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

示例6: getPrimaryObjectLocale

 /**
  * @see DOIExportDom::getPrimaryObjectLocale()
  * @param $suppFile SuppFile
  */
 function getPrimaryObjectLocale(&$article, &$galley, &$suppFile)
 {
     $primaryObjectLocale = null;
     if (is_a($suppFile, 'SuppFile')) {
         // Try to map the supp-file language to a PKP locale.
         $suppFileLanguage = $suppFile->getLanguage();
         if (strlen($suppFileLanguage) == 2) {
             $suppFileLanguage = AppLocale::get3LetterFrom2LetterIsoLanguage($suppFileLanguage);
         }
         if (strlen($suppFileLanguage) == 3) {
             $primaryObjectLocale = AppLocale::getLocaleFrom3LetterIso($suppFileLanguage);
         }
     }
     // If mapping didn't work or we do not have a supp file then
     // retrieve the locale from the other objects.
     if (!AppLocale::isLocaleValid($primaryObjectLocale)) {
         $primaryObjectLocale = parent::getPrimaryObjectLocale($article, $galley);
     }
     return $primaryObjectLocale;
 }
开发者ID:reconciler,项目名称:ojs,代码行数:24,代码来源:DataciteExportDom.inc.php

示例7: extractMetadataFromDataObject


//.........这里部分代码省略.........
     // Identifier(s)
     // dc:identifier: xsi:type=urn:nbn|doi|hdl (1, mandatory)
     // ddb:identifier: ddb:type=URL|URN|DOI|handle|VG-Wort-Pixel|URL_Frontdoor|URL_Publikation|Erstkat-ID|ISSN|other (many, optional)
     $pubIdPlugins = PluginRegistry::loadCategory('pubIds');
     if (isset($pubIdPlugins) && array_key_exists('DOIPubIdPlugin', $pubIdPlugins) && $pubIdPlugins['DOIPubIdPlugin']->getEnabled() == true) {
         $doi = $pubIdPlugins['DOIPubIdPlugin']->getPubId($publicationFormat);
     }
     if (isset($pubIdPlugins) && array_key_exists('URNDNBPubIdPlugin', $pubIdPlugins) && $pubIdPlugins['URNDNBPubIdPlugin']->getEnabled() == true) {
         $urn_dnb = $pubIdPlugins['URNDNBPubIdPlugin']->getPubId($monograph);
         $namespaces = explode(':', $urn_dnb);
         $numberOfNamespaces = min(sizeof($namespaces), 3);
         $scheme = implode(":", array_slice($namespaces, 0, $numberOfNamespaces));
     }
     if (isset($urn_dnb)) {
         $description->addStatement('dc:identifier', $urn_dnb . ' [@xsi:type="' . $scheme . '"]');
         if (isset($doi)) {
             $description->addStatement('ddb:identifier', $doi . ' [@ddb:type="DOI"]');
         }
     } else {
         if (isset($doi)) {
             $description->addStatement('dc:identifier', $doi . ' [@xsi:type="doi"]');
         }
     }
     $this->_checkForContentAndAddElement($description, 'ddb:identifier', Request::url($press->getPath(), 'catalog', 'book', array($monograph->getId())) . ' [@ddb:type="URL_Frontdoor"]');
     // Source (press title and pages)
     $sources = $press->getName(null);
     $pages = $monograph->getPages();
     if (!empty($pages)) {
         $pages = '; ' . $pages;
     }
     foreach ($sources as $locale => $source) {
         $sources[$locale] .= '; ';
         $sources[$locale] .= $pages;
     }
     $this->_addLocalizedElements($description, 'dc:source', $sources);
     // Language
     $language = $monograph->getLanguage();
     if (!$language) {
         $language = AppLocale::get3LetterFrom2LetterIsoLanguage(substr($press->getPrimaryLocale(), 0, 2));
     } else {
         $language = AppLocale::get3LetterFrom2LetterIsoLanguage($language);
     }
     $this->_checkForContentAndAddElement($description, 'dc:language[@xsi:type="dcterms:ISO639-2"]', $language);
     // Relation
     // Coverage
     $coverage = array_merge_recursive((array) $monograph->getCoverageGeo(null), (array) $monograph->getCoverageChron(null), (array) $monograph->getCoverageSample(null));
     $this->_addLocalizedElements($description, 'dc:coverage[@xsi:type="ddb:encoding" @ddb:Scheme="None"]', $coverage);
     // Rights
     $salesRightsFactory = $publicationFormat->getSalesRights();
     while ($salesRight = $salesRightsFactory->next()) {
         $this->_checkForContentAndAddElement($description, 'dc:rights', $salesRight->getNameForONIXCode());
     }
     // File transfer
     // Per default, only the full manuscript or a file of a custom genre
     // (set via settings form) is transferred. If several files of the same
     // genre are found for one publication format, the first is selected as
     // the transfer file per default.
     // Alternative configurations (e.g. container formats) are thinkable, but not implemented.
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     $availableFiles = array_filter($submissionFileDao->getLatestRevisions($monograph->getId()), create_function('$a', 'return $a->getViewable() && $a->getDirectSalesPrice() !== null && $a->getAssocType() == ASSOC_TYPE_PUBLICATION_FORMAT;'));
     $genreDao = DAORegistry::getDAO('GenreDAO');
     $genreId = $metadataPlugins['Xmdp22MetadataPlugin']->getData("genre:id", $monograph->getPressId());
     if (!isset($genreId)) {
         // if genre is not set, try to make monograph default
         // -- this fails if the press uses custom components and the default components
         // have been deleted
         $genreId = $genreDao->getByKey('MANUSCRIPT', $press->getId())->getId();
         if (isset($genreId)) {
             $metadataPlugins['Xmdp22MetadataPlugin']->updateSetting($monograph->getPressId(), "genre_id", $genreId);
         }
     }
     $transferableFiles = array();
     foreach ($availableFiles as $availableFile) {
         if ($availableFile->getAssocId() == $publicationFormat->getId() && $availableFile->getGenreId() == $genreId) {
             // Collect all files that belong to this publication format and have the selected genre
             $transferableFiles[] = $availableFile;
         }
     }
     // first file that fits criteria is transfered per default
     // -- another solution would be to place all files in a container here
     if ($transferableFiles) {
         $transferFile = $transferableFiles[0];
         $transferableFiles = array($transferFile);
     }
     // Number of files (will always be 1, unless a container solution is implemented)
     $this->_checkForContentAndAddElement($description, 'ddb:fileNumber', sizeof($transferableFiles));
     // File Properties and Transfer link
     if (isset($transferFile)) {
         $description->addStatement('ddb:fileProperties', '[@ddb:fileName="' . $transferFile->getServerFileName() . '" @ddbfileSize="' . $transferFile->getFileSize() . '"]');
         $description->addStatement('ddb:transfer[@ddb:type="dcterms:URI"]', Request::url($press->getPath(), 'catalog', 'download', array($monograph->getId(), $publicationFormat->getId(), $transferFile->getFileIdAndRevision())));
     }
     // Contact ID
     $contactId = $metadataPlugins['Xmdp22MetadataPlugin']->getData("ddb:contactID", $monograph->getPressId());
     $this->_checkForContentAndAddElement($description, 'ddb:contact', '[@ddb:contactID="' . $contactId . '"]');
     // Rights
     $kind = $metadataPlugins['Xmdp22MetadataPlugin']->getData("ddb:kind", $monograph->getPressId());
     $description->addStatement('ddb:rights', '[@ddb:kind="' . $kind . '"]');
     Hookregistry::call('Xmdp22SchemaPublicationFormatAdapter::extractMetadataFromDataObject', array(&$this, $monograph, $press, &$description));
     return $description;
 }
开发者ID:kadowa,项目名称:omp-xmdp-metadata-plugin,代码行数:101,代码来源:Xmdp22SchemaPublicationFormatAdapter.inc.php


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