/** * Initializes the Model object. */ public function __construct($model) { $this->model = $model; $this->negotiator = new \Negotiation\FormatNegotiator(); // Specify the location of the translation tables bindtextdomain('skosmos', 'resource/translations'); bind_textdomain_codeset('skosmos', 'UTF-8'); // Choose domain for translations textdomain('skosmos'); // Build arrays of language information, with 'locale' and 'name' keys $this->languages = array(); foreach ($this->model->getConfig()->getLanguages() as $langcode => $locale) { $this->languages[$langcode] = array('locale' => $locale); $this->setLanguageProperties($langcode); $this->languages[$langcode]['name'] = gettext('in_this_language'); $this->languages[$langcode]['lemma'] = Punic\Language::getName($langcode, $langcode); } }
/** * Return the languages present in the configured vocabularies. * @return array Array with lang codes (string) */ public function getLanguages($lang) { $vocabs = $this->getVocabularyList(false); $ret = array(); foreach ($vocabs as $vocab) { foreach ($vocab->getConfig()->getLanguages() as $langcode) { $langlit = Punic\Language::getName($langcode, $lang); $ret[$langlit] = $langcode; } } ksort($ret); return array_unique($ret); }
/** * Loads the vocabulary metadata. And wraps the result in a json-ld object. * @param Request $request */ public function labelStatistics($request) { $lang = $request->getLang(); $this->setLanguageProperties($request->getLang()); $vocab_stats = $request->getVocab()->getLabelStatistics(); /* encode the results in a JSON-LD compatible array */ $counts = array(); foreach ($vocab_stats['terms'] as $proplang => $properties) { $langdata = array('language' => $proplang); if ($lang) { $langdata['literal'] = Punic\Language::getName($proplang, $lang); } $langdata['properties'] = array(); foreach ($properties as $prop => $value) { $langdata['properties'][] = array('property' => $prop, 'labels' => $value); } $counts[] = $langdata; } $ret = array('@context' => array('rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', 'skos' => 'http://www.w3.org/2004/02/skos/core#', 'void' => 'http://rdfs.org/ns/void#', 'void-ext' => 'http://ldf.fi/void-ext#', 'onki' => 'http://schema.onki.fi/onki#', 'uri' => '@id', 'id' => 'onki:vocabularyIdentifier', 'languages' => 'void-ext:languagePartition', 'language' => 'void-ext:language', 'properties' => 'void:propertyPartition', 'labels' => 'void:triples'), 'uri' => '', 'id' => $request->getVocab()->getId(), 'title' => $request->getVocab()->getConfig()->getTitle($lang), 'languages' => $counts); if ($lang) { $ret['@context']['literal'] = array('@id' => 'rdfs:label', '@language' => $lang); } return $this->returnJson($ret); }
/** * Get the languages supported by this vocabulary * @return array languages supported by this vocabulary (as language tag strings) */ public function getLanguages() { $langs = $this->resource->allLiterals('skosmos:language'); $ret = array(); foreach ($langs as $lang) { $langlit = Punic\Language::getName($lang->getValue(), $this->getEnvLang()); $ret[$langlit] = $lang->getValue(); } ksort($ret); return $ret; }
/** * Gets the values for the property in question in all other languages than the ui language. * @param string $property */ public function getAllLabels($property) { $labels = array(); if (EasyRdf_Namespace::shorten($property) !== null) { // shortening property labels if possible $property = EasyRdf_Namespace::shorten($property); } else { $property = "<{$property}>"; } // EasyRdf requires full URIs to be in angle brackets foreach ($this->resource->allLiterals($property) as $lit) { $labels[Punic\Language::getName($lit->getLang(), $this->getEnvLang())][] = new ConceptPropertyValueLiteral($lit, $property); } ksort($labels); return $labels; }
function getName($key, $locale) { switch (@$_GET['type'] ?: 'country') { case 'language': return Punic\Language::getName($key, $locale); case 'currency': return Punic\Currency::getName($key, null, $locale); default: return Punic\Territory::getName($key, $locale); } }