Difference between revisions of "API:EPrints/Language"

From EPrints Documentation
Jump to: navigation, search
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
<!-- Pod2Wiki=_preamble_  
 
<!-- Pod2Wiki=_preamble_  
 
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
 
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=EPrints/Language.pm|package_name=EPrints::Language}}[[Category:API|LANGUAGE]][[Category:API:EPrints/Language|LANGUAGE]]<div><!-- Edit below this comment -->
+
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=perl_lib/EPrints/Language.pm|package_name=EPrints::Language}}[[Category:API|LANGUAGE]][[Category:API:EPrints/Language|LANGUAGE]]<div><!-- Edit below this comment -->
  
  
Line 8: Line 8:
 
'''EPrints::Language''' - A Single Language supported by a repository.
 
'''EPrints::Language''' - A Single Language supported by a repository.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_description -->
 
<!-- Pod2Wiki=head_description -->
 
==DESCRIPTION==
 
==DESCRIPTION==
 
The language class handles loading the "phrase" files for a single language. See the mail documentation for a full explanation of the format of phrase files.
 
The language class handles loading the "phrase" files for a single language. See the mail documentation for a full explanation of the format of phrase files.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_methods -->
 
<!-- Pod2Wiki=head_methods -->
 
==METHODS==
 
==METHODS==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
<!-- Pod2Wiki=head_new -->
<span style='display:none'>User Comments</span>
+
===new===
<!-- Edit below this comment -->
 
 
 
  
<!-- Pod2Wiki= -->
+
<source lang="perl">$language = EPrints::Language->new( $langid, $repository, [$fallback] )
</div>
 
<!-- Pod2Wiki=item_new -->
 
===new===
 
  
$language = EPrints::Language-&gt;new( $langid, $repository, [$fallback] )
+
</source>
 
Create a new language object representing the phases eprints will use in a given language, loading them from the phrase config XML files.
 
Create a new language object representing the phases eprints will use in a given language, loading them from the phrase config XML files.
  
 
$langid is the ISO language ID of the language, $repository is the  repository to which this language object belongs. $fallback is either undef or a reference to the main language object for the repository.
 
$langid is the ISO language ID of the language, $repository is the  repository to which this language object belongs. $fallback is either undef or a reference to the main language object for the repository.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_get_phrase_info -->
<!-- Pod2Wiki=item_get_phrase_info -->
 
 
===get_phrase_info===
 
===get_phrase_info===
  
$info = $lang-&gt;get_phrase_info( $phraseid, $session )
+
<source lang="perl">$info = $lang->get_phrase_info( $phraseid )
 +
 
 +
</source>
 
Returns a hash describing the phrase $phraseid. Contains:
 
Returns a hash describing the phrase $phraseid. Contains:
  
  langid - the language the phrase is from
+
<pre>  langid - the language the phrase is from
 
   phraseid - the phrase id
 
   phraseid - the phrase id
 
   xml - the raw XML fragment
 
   xml - the raw XML fragment
 
   fallback - whether the phrase was from the fallback language
 
   fallback - whether the phrase was from the fallback language
 
   system - whether the phrase was from the system files
 
   system - whether the phrase was from the system files
   filename - the file the phrase came from
+
   filename - the file the phrase came from</pre>
 
+
 
 
If $phraseid doesn't exist returns undef.
 
If $phraseid doesn't exist returns undef.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_get_phrase_ids -->
<!-- Pod2Wiki=item_get_phrase_ids -->
 
 
===get_phrase_ids===
 
===get_phrase_ids===
  
$phraseids = $language-&gt;get_phrase_ids( $fallback )
+
<source lang="perl">$phraseids = $language->get_phrase_ids( $fallback )
 +
 
 +
</source>
 
Return a reference to an array of all phrase ids that are defined in this language (repository and system).
 
Return a reference to an array of all phrase ids that are defined in this language (repository and system).
  
 
If $fallback is true returns any additional phrase ids defined in the fallback language.
 
If $fallback is true returns any additional phrase ids defined in the fallback language.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_phrase -->
<!-- Pod2Wiki=item_phrase -->
 
 
===phrase===
 
===phrase===
  
$xhtml = $language-&gt;phrase( $phraseid, $inserts, $session )
+
<source lang="perl">$xhtml = $language->phrase( $phraseid, $inserts )
 +
 
 +
</source>
 
Return an XHTML DOM structure for the phrase with the given phraseid.
 
Return an XHTML DOM structure for the phrase with the given phraseid.
  
 
The phraseid is looked for in the following order, if it's not in one phrase file the system checks the next.
 
The phraseid is looked for in the following order, if it's not in one phrase file the system checks the next.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
* This languages repository specific phrases.
<span style='display:none'>User Comments</span>
+
* The fallback languages repository specific phrases (if there is a fallback).
<!-- Edit below this comment -->
+
* This languages general phrases.
 
+
* The fallback languages general phrases (if there is a fallback).
 
+
* Failing that it returns an XHTML DOM encoded error.
<!-- Pod2Wiki= -->
+
If the phrase contains "pin" elements then $inserts must be a reference to a hash. Each "pin" has a "name" attribute. For each pin there must be a key in $inserts of the "name". The value is a XHTML DOM object which will replace the "pin" when returing this phrase.
</div>
 
<!-- Pod2Wiki=item_this_languages_repository_specific_phrases -->
 
===this_languages_repository_specific_phrases===
 
  
This languages repository specific phrases.
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_has_phrase -->
<!-- Pod2Wiki=item_phrases -->
+
===has_phrase===
===phrases===
 
 
 
The fallback languages repository specific phrases (if there is a fallback).
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_this_languages_general_phrases -->
 
===this_languages_general_phrases===
 
 
 
This languages general phrases.
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_phrases -->
 
===phrases===
 
 
 
The fallback languages general phrases (if there is a fallback).
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
  
 +
<source lang="perl">$boolean = $language->has_phrase( $phraseid )
  
<!-- Pod2Wiki= -->
+
</source>
</div>
 
<!-- Pod2Wiki=item_failing_that_it_returns_an_xhtml_dom_encoded_error -->
 
===failing_that_it_returns_an_xhtml_dom_encoded_error===
 
 
 
Failing that it returns an XHTML DOM encoded error.
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_has_phrase -->
 
===has_phrase===
 
 
 
$boolean = $language-&gt;has_phrase( $phraseid, $session )
 
 
Return 1 if the phraseid is defined for this language. Return 0 if it is only available as a fallback or unavailable.
 
Return 1 if the phraseid is defined for this language. Return 0 if it is only available as a fallback or unavailable.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_get_id -->
<!-- Pod2Wiki=item_get_id -->
 
 
===get_id===
 
===get_id===
  
$langid = $language-&gt;get_id
+
<source lang="perl">$langid = $language->get_id
 +
 
 +
</source>
 
Return the ISO language ID of this language object.
 
Return the ISO language ID of this language object.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_get_fallback -->
<!-- Pod2Wiki=item_get_fallback -->
 
 
===get_fallback===
 
===get_fallback===
  
$lang = $language-&gt;get_fallback()
+
<source lang="perl">$lang = $language->get_fallback()
 +
 
 +
</source>
 
Return the fallback language for this language. Returns undef if there is no fallback.
 
Return the fallback language for this language. Returns undef if there is no fallback.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_load_phrases -->
<!-- Pod2Wiki=item_load_phrases -->
 
 
===load_phrases===
 
===load_phrases===
  
$ok = $language-&gt;load_phrases( $session, $file )
+
<source lang="perl">$ok = $language->load_phrases( $file )
 +
 
 +
</source>
 
Load phrases from $file into the current language (use with care!).
 
Load phrases from $file into the current language (use with care!).
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_create_phrase_doc -->
<!-- Pod2Wiki=item_create_phrase_doc -->
 
 
===create_phrase_doc===
 
===create_phrase_doc===
  
$doc = EPrints::Language-&gt;create_phrase_doc( $session, [ $comment ] )
+
<source lang="perl">$doc = EPrints::Language->create_phrase_doc( $session, [ $comment ] )
 +
 
 +
</source>
 
Create and return a new, empty, phrases document. Optionally put $comment at the top.
 
Create and return a new, empty, phrases document. Optionally put $comment at the top.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_copyright -->
 
<!-- Pod2Wiki=head_copyright -->
 
==COPYRIGHT==
 
==COPYRIGHT==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #ccepadding: 0em 1em 0em 1em; font-size: 80%; '>
+
Copyright 2000-2011 University of Southampton.
<span style='display:none'>User Comments</span>
+
 
 +
This file is part of EPrints http://www.eprints.org/.
 +
 
 +
EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 +
 
 +
EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 +
 
 +
You should have received a copy of the GNU Lesser General Public License along with EPrints.  If not, see http://www.gnu.org/licenses/.
 +
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=_postamble_ -->
<!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment -->
+
<!-- Edit below this comment -->

Revision as of 09:56, 22 January 2013

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::Language - A Single Language supported by a repository.


DESCRIPTION

The language class handles loading the "phrase" files for a single language. See the mail documentation for a full explanation of the format of phrase files.


METHODS

new

$language = EPrints::Language->new( $langid, $repository, [$fallback] )

Create a new language object representing the phases eprints will use in a given language, loading them from the phrase config XML files.

$langid is the ISO language ID of the language, $repository is the repository to which this language object belongs. $fallback is either undef or a reference to the main language object for the repository.


get_phrase_info

$info = $lang->get_phrase_info( $phraseid )

Returns a hash describing the phrase $phraseid. Contains:

  langid - the language the phrase is from
  phraseid - the phrase id
  xml - the raw XML fragment
  fallback - whether the phrase was from the fallback language
  system - whether the phrase was from the system files
  filename - the file the phrase came from

If $phraseid doesn't exist returns undef.


get_phrase_ids

$phraseids = $language->get_phrase_ids( $fallback )

Return a reference to an array of all phrase ids that are defined in this language (repository and system).

If $fallback is true returns any additional phrase ids defined in the fallback language.


phrase

$xhtml = $language->phrase( $phraseid, $inserts )

Return an XHTML DOM structure for the phrase with the given phraseid.

The phraseid is looked for in the following order, if it's not in one phrase file the system checks the next.

  • This languages repository specific phrases.
  • The fallback languages repository specific phrases (if there is a fallback).
  • This languages general phrases.
  • The fallback languages general phrases (if there is a fallback).
  • Failing that it returns an XHTML DOM encoded error.

If the phrase contains "pin" elements then $inserts must be a reference to a hash. Each "pin" has a "name" attribute. For each pin there must be a key in $inserts of the "name". The value is a XHTML DOM object which will replace the "pin" when returing this phrase.


has_phrase

$boolean = $language->has_phrase( $phraseid )

Return 1 if the phraseid is defined for this language. Return 0 if it is only available as a fallback or unavailable.


get_id

$langid = $language->get_id

Return the ISO language ID of this language object.


get_fallback

$lang = $language->get_fallback()

Return the fallback language for this language. Returns undef if there is no fallback.


load_phrases

$ok = $language->load_phrases( $file )

Load phrases from $file into the current language (use with care!).


create_phrase_doc

$doc = EPrints::Language->create_phrase_doc( $session, [ $comment ] )

Create and return a new, empty, phrases document. Optionally put $comment at the top.


COPYRIGHT

Copyright 2000-2011 University of Southampton.

This file is part of EPrints http://www.eprints.org/.

EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.