Difference between revisions of "API:EPrints/Language"
Line 19: | Line 19: | ||
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 --> | ||
+ | |||
+ | |||
+ | <!-- Pod2Wiki= --> | ||
+ | </div> | ||
+ | <!-- Pod2Wiki=head_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%; '> | <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> | <span style='display:none'>User Comments</span> | ||
Line 27: | Line 36: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_new --> | <!-- Pod2Wiki=item_new --> | ||
− | === | + | ===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. | Create a new language object representing the phases eprints will use in a given language, loading them from the phrase config XML files. | ||
Line 41: | Line 51: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_phrase_info --> | <!-- Pod2Wiki=item_get_phrase_info --> | ||
− | === | + | ===get_phrase_info=== |
+ | $info = $lang->get_phrase_info( $phraseid, $session ) | ||
Returns a hash describing the phrase $phraseid. Contains: | Returns a hash describing the phrase $phraseid. Contains: | ||
Line 62: | Line 73: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_phrase_ids --> | <!-- Pod2Wiki=item_get_phrase_ids --> | ||
− | === | + | ===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). | Return a reference to an array of all phrase ids that are defined in this language (repository and system). | ||
Line 76: | Line 88: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_phrase --> | <!-- Pod2Wiki=item_phrase --> | ||
− | === | + | ===phrase=== |
+ | $xhtml = $language->phrase( $phraseid, $inserts, $session ) | ||
Return an XHTML DOM structure for the phrase with the given phraseid. | Return an XHTML DOM structure for the phrase with the given phraseid. | ||
Line 90: | Line 103: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_this_languages_repository_specific_phrases --> | <!-- 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%; '> | <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> | <span style='display:none'>User Comments</span> | ||
Line 100: | Line 114: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_phrases --> | <!-- Pod2Wiki=item_phrases --> | ||
− | === | + | ===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%; '> | <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> | <span style='display:none'>User Comments</span> | ||
Line 110: | Line 125: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_this_languages_general_phrases --> | <!-- 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%; '> | <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> | <span style='display:none'>User Comments</span> | ||
Line 120: | Line 136: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_phrases --> | <!-- 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%; '> | <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> | <span style='display:none'>User Comments</span> | ||
Line 130: | Line 147: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_failing_that_it_returns_an_xhtml_dom_encoded_error --> | <!-- 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%; '> | <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> | <span style='display:none'>User Comments</span> | ||
Line 140: | Line 158: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_has_phrase --> | <!-- Pod2Wiki=item_has_phrase --> | ||
− | === | + | ===has_phrase=== |
+ | $boolean = $language->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. | ||
Line 152: | Line 171: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_id --> | <!-- Pod2Wiki=item_get_id --> | ||
− | === | + | ===get_id=== |
+ | $langid = $language->get_id | ||
Return the ISO language ID of this language object. | Return the ISO language ID of this language object. | ||
Line 164: | Line 184: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_fallback --> | <!-- Pod2Wiki=item_get_fallback --> | ||
− | === | + | ===get_fallback=== |
+ | $lang = $language->get_fallback() | ||
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. | ||
Line 176: | Line 197: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_load_phrases --> | <!-- Pod2Wiki=item_load_phrases --> | ||
− | === | + | ===load_phrases=== |
+ | $ok = $language->load_phrases( $session, $file ) | ||
Load phrases from $file into the current language (use with care!). | Load phrases from $file into the current language (use with care!). | ||
Line 188: | Line 210: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_create_phrase_doc --> | <!-- Pod2Wiki=item_create_phrase_doc --> | ||
− | === | + | ===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. | Create and return a new, empty, phrases document. Optionally put $comment at the top. | ||
Revision as of 13:57, 25 February 2010
EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects
Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki
Contents
- 1 NAME
- 2 DESCRIPTION
- 3 METHODS
- 3.1 new
- 3.2 get_phrase_info
- 3.3 get_phrase_ids
- 3.4 phrase
- 3.5 this_languages_repository_specific_phrases
- 3.6 phrases
- 3.7 this_languages_general_phrases
- 3.8 phrases
- 3.9 failing_that_it_returns_an_xhtml_dom_encoded_error
- 3.10 has_phrase
- 3.11 get_id
- 3.12 get_fallback
- 3.13 load_phrases
- 3.14 create_phrase_doc
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, $session )
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, $session )
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
This languages repository specific phrases.
phrases
The fallback languages repository specific phrases (if there is a fallback).
this_languages_general_phrases
This languages general phrases.
phrases
The fallback languages general phrases (if there is a fallback).
failing_that_it_returns_an_xhtml_dom_encoded_error
Failing that it returns an XHTML DOM encoded error.
has_phrase
$boolean = $language->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.
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( $session, $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.