- 1 NAME
- 2 DESCRIPTION
- 3 INSTANCE VARIABLES
- 4 METHODS
- 5 COPYRIGHT
EPrints::Language - A Single Language supported by a repository.
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 ISO ID of this language.
If $self is the primary language in its repository then this is undef, otherwise it is a reference to the primary language object.
A reference to a hash. Keys are IDs for phrases, values are DOM fragments containing the phases. Contains repository specific phrases.
A reference to a hash. Keys are IDs for phrases, values are DOM fragments containing the phases. Contains generic eprints phrases.
A XML document to hold all the stray DOM elements.
$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.
Clone a language object.
$info = $language->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.
$phraseids = $language->get_phrase_ids( $fallback )
Returns 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.
$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.
1. This languages repository specific phrases.
2. The fallback languages repository specific phrases (if there is a fallback).
3. This languages general phrases.
4. The fallback languages general phrases (if there is a fallback).
5. 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.
$boolean = $language->has_phrase( $phraseid )
Returns true if the $phraseid is defined for this language. Returns false if it is only available as a fallback or unavailable.
$langid = $language->get_id
Return the ISO language ID of this language object.
$lang = $language->get_fallback
Return the fallback language for this language. Returns undef if there is no fallback.
$ok = $language->load_phrases( $file )
Load phrases from $file into the current language. Use with care!
$doc = EPrints::Language->create_phrase_doc( $session, [ $comment ] )
Create and return a new, empty, phrases document. Optionally put $comment at the top.
© Copyright 2022 University of Southampton.
EPrints 3.4 is supplied by EPrints Services.
This file is part of EPrints 3.4 http://www.eprints.org/.
EPrints 3.4 and this file are released under the terms of the GNU Lesser General Public License version 3 as published by the Free Software Foundation unless otherwise stated.
EPrints 3.4 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 3.4. If not, see http://www.gnu.org/licenses/.